Proton Tutorial - DS275


You will require Microsoft Visual Basic, Download it here! (free download)

The IC used in this example is the DS275, the MAX232 are far more popular, and there are many more guides for them, but I chose the DS275 due to its wiring simplicity.

You'll notice in the following diagram that the DS275 only requires a single power supply of 5 volts, most RS232 adaptors require dual supply's (positive and negative), usually 10-12VDC, the DS275 utilizes the power available from the data lines on the PC side to deliver its negative voltage requirements, handy feature. .


This is the view of a COM port from the back of your PC;


  • Pin 2 - RX data for PC. Connect the 275's TXout to this pin
  • Pin 3 - TX data from PC, Connect the 275's RXin to this pin
  • Pin 5 - Common Earth - Be sure that the 275 and the PIC's earth are connected to this pin

I used the DB9 PCB adaptor available at Futurlec, and modified it slightly so that it could be used on protoboards. The DB9 com leads can be brought at almost any electrical retailer, or built by yourself. You will need a standard male to female DB9 lead, and don't be to concerned about its length as RS232 is generally good for 15+ meters

The modification is done by cutting off the pins that are not required, and cutting the 2 mounting supports on either side, now the DB9 PCB adaptor can fit on a protoboard without any hassles, and the whole process takes no time at all. The pins not required are circled below (note that this resembles the underside/PCB side of the DB9 adaptor);




With Pins 6 to 9 removed, the DB9 PCB adaptor can be soldered onto any Proto PCB board. Its quite easy to make your own DB9 cable, just buy the following connectors from and ribbon cable. Simply snip one wire off so that you can fit 9 wires into the adaptor, and then press the clips together. (Part Numbers for DB9 Cable/PCB Adaptor/Female, Male Connectors: GRCABLE10, DSUBPCF9, DSUBIDCF9 DSUBIDCM9)


Its important to define you MSCOMM settings in VB. Double click anywhere on the form so that your in the Sub called "Private Sub Form1_Load". Then assign the following properties with these values;

MSCOMM1.PortName = "COM1"
MSCOMM1.BaudRate = 9600
MSCOMM1.Parity = IO.Ports.Parity.None
MSCOMM1.DataBits = 8
MSCOMM1.StopBits = 1
MSCOMM1.ReadTimeout = 1000
MSCOMM1.Handshake = IO.Ports.Handshake.None
MSCOMM1.DtrEnable = False


Now your port is ready to go. The following example displays how to send data to a PIC;

Dim Data_Sample as Long
Data_Sample = 5555
MSCOMM1.Write("Z" & Data_Sample & "A")


Notice that the number is being sent with 2 identifiers, one on the start and one at the end ("Z" & "A"). This is for the PIC. With Z being placed before piece of information, the PIC knows when the data begins, as it waits for the letter "Z" to be received (its like a header for the information). It starts, and keeps building the number until it receives the next non-numeric value, in this case it will always be the letter "A". Having different identifiers like this ensures that the data is always validated as real information with known starts and ends.

Here's an example of the PIC awaiting the data from the PC with the above code;

RSIn {Time_Out}, Wait("Z"), Dec Number


To receive information on the PC from the PIC, the program would look like this;

Dim Sample_Data as String
Try ' Attempt to read data from the MSCOMM control
  Sample_Data = MSCOMM1.ReadLine()
 Catch e As TimeoutException ' It will come to here if an error occurs
  Errors = Errors + 1
End Try

This will attempt to read from the COM port, and it will wait until it has received the Line Feed code (ASCII Character 10) before continuing. Should the VB program not recieve anything before the time period defined earlier, it will go to "Catch e As TimeoutException" and execute any code in that part of the routine. If no errors occur, than the program will go to the following line after "End Try".

The PIC micro part of the program is fairly self explanatory - the only real catch I could think of is being sure that you not only define how the compiler deals with the RSIN/RSOUT commands - but to be sure to set the RSOUT pin as an OUTPUT and make it HIGH. By not doing so, the first piece of data to be transmitted from the PIC will be corrupted as its not actually in the RS232 default state.

The work package for this project consists of a Visual Basic program and the required basic files for your 16F877, note that almost any PIC can be used as I have used the software equivalents (RSIN and RSOUT), just be sure to modify the RSIN/RSOUT declarations as required.

Download the Work Package: 9600 Baud


Forum Activity

  • No posts to display.

Member Access