TTL to RS232 Converter board

Updated 4/5/15

Key Search Words: PIC Microcontroller, CCS C Compiler, PIC Projects

 This project is one I have wanted to do for years, to be able to send serial micro controller data directly to the PC into a terminal program. The heart of this board is the Maxim 232 chip, which by use of 1uF capacitors will generate double the input voltage to a level of +/- 10v to send to the serial port on my laptop. As you may remember, micro controllers put out a TTL level signal which is 0 to 5v and this must be converted to +/- 10v inverted to put into the computer. The board works great, and can be easily tested by connecting pins 2 and 3 of the output connector to feed the serial data back in and be recieved by the terminal program. As you type, it appears on the display as it comes in from the loop through.
Click images for a larger more detailed view
Here is the board, with its own 5v regulator, the DB9-F connector to connect to the PC, and a 110v/12v dc power supply.
Here the Cbot is connected to the PC and sending it data! The screen is at least 80 charecters wide, depending on the font used, and infinitely long. A perfect application is data logging of temperatures, lighting conditions and analog data to be imported into the chart wizard in Excel for graphing.
Schematic (click to enlarge). many of the data books I consulted confuse pins 2 and 3 on the PC for xmit or recieve. I finally took an oscilloscope and looked for the data as I pressed the keyboard.

Sample code to send text and various types of numbers to the PC screen:

 //for LCD / Terminal:
#use rs232(baud=9600, xmit=Pin_B1, bits=8, parity=N,stream=TERMINAL)

int8 n = 255;
int16 x = 50000;
float y = 65000.123; //only 7 digit precision will truncate last digit
float z = 3.14159;

//----------------------------------------------------------------

//MAIN PROGRAM:

while (true) {

//First flash lamp

output_high(Pin_B0);
delay_ms(250);
output_low(Pin_B0);
delay_ms(250);

//Now send messages to Terminal:

delay_ms(1000);

fprintf(TERMINAL,"Hello World"); //text plus integer8 (Byte)
fprintf(TERMINAL,"\n\r"); //New line, Carrige Return

delay_ms(250);

//Displays: ROBOT BOARD= 255
fprintf(TERMINAL,"ROBOT BOARD= %u"n); //text plus integer8 (Byte)
fprintf(TERMINAL,"\n\r"); //New line, Carrige Return

delay_ms(250);

//Displays: Value= 50000
fprintf(TERMINAL,"Value= %Lu"x); //text plus Integer 16 (word)
fprintf(TERMINAL,"\n\r"); //New line, Carrige Return

delay_ms(250);

//Displays: floating= 65000.120
fprintf(TERMINAL,"floating= %8.3f"y); //text plus floating point
fprintf(TERMINAL,"\n\r"); //New line, Carrige Return

delay_ms(250);

//Displays: floating= 65000.12
fprintf(TERMINAL,"floating= %f"y); //text plus floating point DEFAULT float
fprintf(TERMINAL,"\n\r"); //New line, Carrige Return

delay_ms(250);

//Displays: floating= 3.14159
fprintf(TERMINAL,"floating= %6.5f"z); //text plus floating point
fprintf(TERMINAL,"\n\r"); //New line, Carrige Return

delay_ms(250);
} //elihw

} //niam

  HOME