View previous topic :: View next topic |
Author |
Message |
argosy
Joined: 07 Sep 2003 Posts: 5 Location: Scotland
|
Multidrop RS232 |
Posted: Thu Jul 17, 2003 4:39 pm |
|
|
Hi I have project where I have to communicate with 2 pic16f876's via the rs232 connection from the one computer. I have used the 16f876 and rs232 in the past but only singly. On checking the past posts I have seen articles on using 9 data bits to indicate the presence of an address, unfortunately I have to use visual basic for the computer side of the project, and according to the comm control only a maximum of 8 data bits can be used. I thought of emmbedding the address in the data and downloading it to the two micros then decoding it but this seems wasteful, the other method I thought of was to use one micro to receive/transmit the rs232 the data then communicate between the two using the spi interface(they are on the same board). If anybody has any suggestions I would wellcome them as I work mainly with hardware and dip into the software/micro side of things on occasion.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516113 |
|
|
Steve H. Guest
|
What I do... |
Posted: Thu Jul 17, 2003 10:05 pm |
|
|
I have a VHF Source and Network Analyzer project that can have 4 instruments on one serial line. I send a packetized message where the first byte is the address. This wastes one byte but it is easily done. Another thintg that could be done is to embed the address into the first byte with the command to preform. This would save a byte. At anyrate you can download the code from my site at the link below.
Steve H.
Web Page: www.AnalogHome.com
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516123 |
|
|
Sherpa Doug Guest
|
Re: Multidrop RS232 |
Posted: Fri Jul 18, 2003 8:12 am |
|
|
:=Hi I have project where I have to communicate with 2 pic16f876's via the rs232 connection from the one computer. I have used the 16f876 and rs232 in the past but only singly. On checking the past posts I have seen articles on using 9 data bits to indicate the presence of an address, unfortunately I have to use visual basic for the computer side of the project, and according to the comm control only a maximum of 8 data bits can be used. I thought of emmbedding the address in the data and downloading it to the two micros then decoding it but this seems wasteful, the other method I thought of was to use one micro to receive/transmit the rs232 the data then communicate between the two using the spi interface(they are on the same board). If anybody has any suggestions I would wellcome them as I work mainly with hardware and dip into the software/micro side of things on occasion.
Two established protocols for this that I have used, but not with PICs, are SAIL (Serial Ascii Intereface Loop) which is an old protocol adapted from 4-20mA to voltage driven, and VISCA which is used by high end video equipment especially Sony cameras.
You might also look at Modbus, though I have never used it.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516141 |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: Multidrop RS232 |
Posted: Fri Jul 18, 2003 8:36 am |
|
|
:=Hi I have project where I have to communicate with 2 pic16f876's via the rs232 connection from the one computer. I have used the 16f876 and rs232 in the past but only singly. On checking the past posts I have seen articles on using 9 data bits to indicate the presence of an address, unfortunately I have to use visual basic for the computer side of the project, and according to the comm control only a maximum of 8 data bits can be used. I thought of emmbedding the address in the data and downloading it to the two micros then decoding it but this seems wasteful, the other method I thought of was to use one micro to receive/transmit the rs232 the data then communicate between the two using the spi interface(they are on the same board). If anybody has any suggestions I would wellcome them as I work mainly with hardware and dip into the software/micro side of things on occasion.
Have a look at the spec for Modbus at www.modbus.org. Modbus uses addressed packets to comunicate between a master and slave devices. This is not hard to implement with VB through a serial port. If you two pics are in the same circuit you can use some and/or gates to allow them both access to the same RS232 driver. This is a cheep and effective solution. They would not be able to transmit at the same time but master slave protocol means slaves only transmit in responce to a masters request.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516144 |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: Multidrop RS232 |
Posted: Mon Jul 21, 2003 6:26 pm |
|
|
If you want to fake the 9 data bits, then you could do it by using even or odd parity. You would have to change the parity setting based on each byte. You would also have to make sure that the data had been sent before changing the parity from within VB. It is kinda tricky but a savy programmer can figure it out. If you want an easy way to detect an address, send it as your first byte. To signal the start of a new message, send a "break" signal. This will appear as a framing error on the pic with the data being 0x00.
Regards,
Mark
:=Hi I have project where I have to communicate with 2 pic16f876's via the rs232 connection from the one computer. I have used the 16f876 and rs232 in the past but only singly. On checking the past posts I have seen articles on using 9 data bits to indicate the presence of an address, unfortunately I have to use visual basic for the computer side of the project, and according to the comm control only a maximum of 8 data bits can be used. I thought of emmbedding the address in the data and downloading it to the two micros then decoding it but this seems wasteful, the other method I thought of was to use one micro to receive/transmit the rs232 the data then communicate between the two using the spi interface(they are on the same board). If anybody has any suggestions I would wellcome them as I work mainly with hardware and dip into the software/micro side of things on occasion.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144516236 |
|
|
|