Previous in Forum: The Rights of Speaker or the Rights of Listener?   Next in Forum: Electrical Characteristics
Close
Close
Close
4 comments
Rate Comments: Nested
Active Contributor

Join Date: Jan 2012
Posts: 21

Serial Communication

03/14/2012 12:53 PM

I want to do serial communication between two computers using laser. for that i wish to write a c program for fixing baud rate, number of parity bits etc and i also want to include my data to be transfered in that program. where i should load my program in my computer?

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Guru
Engineering Fields - Electrical Engineering - Been there, done that. Engineering Fields - Control Engineering - New Member

Join Date: Dec 2008
Location: Long Island NY
Posts: 15600
Good Answers: 981
#1

Re: Serial Communication

03/14/2012 1:25 PM

You won't need a C program to do this. A program will just consider all of these parameters as just numbers to be loaded into a register.

__________________
"Don't disturb my circles." translation of Archimedes last words
Register to Reply
Guru

Join Date: Dec 2008
Location: Cd. Juarez, Chihuahua, Mexico.
Posts: 1023
Good Answers: 69
#2
In reply to #1

Re: Serial Communication

03/14/2012 5:24 PM

That is correct, what he can do is add a transistor to the TX driver to pulse a laser diode, and connect a phototransistor to the RX input to receive the laser beams, will need two such circuits.

I wander how's he gonna manage to aim the two transceivers...

Regards

__________________
No hay conocimiento ni herramienta que sustituya al sentido comun.
Register to Reply
Guru

Join Date: Mar 2007
Location: by the beach in Florida
Posts: 33392
Good Answers: 1817
#3

Re: Serial Communication

03/14/2012 5:29 PM

Figure 7. A sample code listing in Borland C++ 3.1 that can be used for full-

duplex communication between two computers. The program can be used to test a

single transceiver simply by pointing the laser at the photo-transistor.

/****************************************************

**

** Laser Pointer RS-232 Transceiver

** Copyright (c) 1997 GKDesign

** 24th May 1997 George Katz

** Data Transmitted @ 9600 bps

**

*****************************************************/

#include <dos.h>

#include <stdlib.h>

#include <conio.h>

#include <bios.h>

#include <stdio.h>

#define COM1 0

#define COM2 1

#define DATA_READY 0x100

#define TRUE 1

#define FALSE 0

#define ESC_KEY '\x1b'

#define SETTINGS ( _COM_9600 | _COM_CHR8 | _COM_NOPARITY | _COM_STOP1)

void clear_line(int line)

{

int i;

gotoxy(1,line); // clear a whole line

for(i=0;i<80;i++)

printf(" ");

}

int main(int argc, char *argv[])

{

int in, out, status, done = FALSE;

int curs_rx=0,curs_ry=15,curs_tx=0,curs_ty=4;

int com_port=COM1;

if (!(argc == 2 && (argv[1][0] == '2' || argv[1][0] == '1')))

{

printf("Usage: LASER [1|2]\nwhere 1 = Com port 1\n 2 = Com port

2\n");

exit(-1);

}

if (argv[1][0]=='2') // select com port

com_port = COM2;

else

com_port = COM1;

bioscom(_COM_INIT, SETTINGS, com_port); // Initialize serial port

clrscr();

printf(" GKDesign (c) 1997 Laser Transceiver Communicator

V1.1\n");

printf(" Press [ESC] to exit program\n");

printf("__________________________________ Sent Data

___________________________________");

gotoxy(1,13);

printf("________________________________ Recieved Data

_________________________________");

while (!done) {

dUmMy= bioscom(_COM_STATUS, 0, com_port); // recieved data?

if (status & DATA_READY)

if ((out = bioscom(_COM_RECEIVE, 0, com_port) & 0x7F) != 0) { //

get data

if (curs_rx < 78) // move cursor

curs_rx++;

else {

curs_rx = 1; // at end of line

if (curs_ry < 23)

curs_ry++;

else

curs_ry = 15;

clear_line(curs_ry);

}

gotoxy(curs_rx,curs_ry); // goto correct screen location

putch(out); // print the character

}

if (kbhit()) {

if ((in = getch()) == ESC_KEY) // check for ESC key

done = TRUE;

if(!in) // read an extended character

in = getch();

if (curs_tx < 78) // position cursor

curs_tx++;

else {

curs_tx = 1; // at end of line

if (curs_ty < 12)

curs_ty++;

else

curs_ty = 4;

clear_line(curs_ty);

}

gotoxy(curs_tx,curs_ty); // goto correct screen location

putch(in); // print the character

bioscom(_COM_SEND, in, com_port); // output data

}

}

clrscr();

return (0);

}

http://www.qsl.net/n9zia/wireless/laser/laser.htm

__________________
All living things seek to control their own destiny....this is the purpose of life
Register to Reply Score 1 for Good Answer
Active Contributor

Join Date: Jan 2012
Posts: 21
#4
In reply to #3

Re: Serial Communication

04/03/2012 2:48 AM

sir, if i am using ubuntu terminal for executing above code in transmitter pc then where i can view in the receiver pc?

Register to Reply
Register to Reply 4 comments

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

neenajoy09 (1); redfred (1); SolarEagle (1); Yahlasit (1)

Previous in Forum: The Rights of Speaker or the Rights of Listener?   Next in Forum: Electrical Characteristics

Advertisement