Two Props Communicating?
Kirk Fraser
Posts: 364
I have my first two propellers wired according to the diagram in the Propeller Manual. I'm wondering how to wire them for communication. Is it correct to just wire the 4 lines GND, RST, Tx, Rx from each chip together in parallel? Should the Tx and Rx be reversed? What if there are 10 Propellers?
The Alternative Serial Port Connection in the Data Sheet like the Prop Plug would put the communication all in a PC having many ports. I want one computer port accessing my Propeller net with individual access to the cogs by software, if possible. How do I accomplish that?
Thank you.
The Alternative Serial Port Connection in the Data Sheet like the Prop Plug would put the communication all in a PC having many ports. I want one computer port accessing my Propeller net with individual access to the cogs by software, if possible. How do I accomplish that?
Thank you.
Comments
You need a separate RST connection from each Propeller to the PC's DTR line and you need a separate Tx connection from each Propeller to the PC's Rx line. You can connect all the Rx lines from the Propellers together to the Tx line from the PC.
NOTE: When I talk about a connection between a PC and a Propeller, I don't mean a direct connection. You'll need some kind of voltage translation interface, either the 3 transistor circuit downloadable from Parallax or an interface using a MAX3232 to interface the PC's serial port's RS232 signals to the 3.3V logic signals of the Propeller. If you leave this out, you'll destroy the Propeller(s).
The above is about connecting one or more Propellers to a PC for programming purposes. If you're just going to send data back and forth among the Propellers, you don't need the RST connection. You can also use an open-collector non-inverting buffer in the Tx leads to make a party line so that any Propeller can send to any other as long as only one is sending at a time. You can also use RS-485. This is similar to what's shown in the Nuts and Volts columns (#55 and #56 here) for use with a Stamp. The same idea can work with a Propeller.
I once communicated between a BS1 and my computer with one wire using something very simple like the Serin and Serout commands. It didn't do much, only transmit a string, but that would be enough. I'm concerned about the short problem Mike mentioned using that approach. I could daisy chain the network using serin on one pin and serout on the other, then pass legal data but process packets with the correct address. That might make the network slow but it should take care of trying to overwrite data as it's passing through without an interrupt. Would a one wire daisy chain work as good as the RS-485? I suppose not, I'd need at least a second pin to tell if the cog is ready to receive.
I don't know how to detect errors lower than the character level. Should I add the CRC object to reduce packet errors?
Basically my project is a robot with lots of joints. I want the computer to display each position in real time and take position commands too. So my data will be brief but often continuously changing. I'm not sure what speed it would need to communicate at but getting around the whole network seems like a bottle-neck.
The below goes into one Propeller.
The below goes into the other Propeller.
To communicate with a computer without using the Parallax Serial Terminal (or other terminal programs), you could use the same code used for communicating with LabView. Just remember that the Computer will be acting like the Master and the Propeller is the Slave, so the Computer program you will be using needs to send the "sync" pulse first. Here's what the code looks like on the Propeller.
The computer program needs to transmit the string "!v=" and then transmit data and then it receives data.
Interconnecting several Propellers.....not too sure how to do that, maybe 1-wire or an I2C setup. I agree with Mike that you have to be careful about shorting the pins.
EDIT: Most errors are caused by collisions which are usually caused by incorrect timing. If the timing is dead on then there shouldn't be a lot errors, you will have to deal with errors cause by outside noise. I've tried using a CRC yet was unsuccessful with it.
If I wait for the sync on each chip interpreting it as a clear to send it would still potentially have collisions. So it looks like I'll need to lock out all but one at a time in a sequential pattern like the cog hub switch.
I'll have to read the RS-485 article more carefully too.