prop communication and pc connexion ?
henrib75
Posts: 9
in Propeller 1
Hello,
I have a parallax propeller for years but I am not a specialist. And I apologize for my English, I'm French. In short, I try to communicate several propeller together (not necessarily just two). And ideally with other platforms (pc, arduino, ...). Which protocol / connection do you recommend? I looked on the ethernet side (see ethercat) (it would be convenient to have a single network socket and use a switch) but it seems complex without a dedicated external component (ideally I would not want any other component and use only one cog). Without having to make a connection it would probably be better (like UDP). I want to be able to exchange short messages (like 32 bits) at low speeds. A transmitter and all receivers. No wireless. What would you use? THANK YOU
I have a parallax propeller for years but I am not a specialist. And I apologize for my English, I'm French. In short, I try to communicate several propeller together (not necessarily just two). And ideally with other platforms (pc, arduino, ...). Which protocol / connection do you recommend? I looked on the ethernet side (see ethercat) (it would be convenient to have a single network socket and use a switch) but it seems complex without a dedicated external component (ideally I would not want any other component and use only one cog). Without having to make a connection it would probably be better (like UDP). I want to be able to exchange short messages (like 32 bits) at low speeds. A transmitter and all receivers. No wireless. What would you use? THANK YOU
Comments
The simplest link will be UART Async Serial, and for modest/local lengths TTL-Serial is ok.
For higher distances, you could look at RS485 links, which are just better differential line drivers/buffers, and direction control allowing multiple nodes from one master.
There are many USB-UART (TTL) modules, and fewer with RS485 drivers, but I see
BOB-09822 SparkFun Electronics
TEL0070 DFRobot
XR21V1410IL-0C-EB MaxLinear, Inc.
XR21B1411IL-0A-EB MaxLinear, Inc.
XR21B1420IL28-0A-EVB MaxLinear
(etc) look suitable.
If you just need one transmitter and everybody else is just receiving you can basically tie TX from your transmitter to RX of all receivers.
All receivers will receive the same data and you would need to make a transmission 'packet' with a address followed by you data, so the receiver knows that the data is for himself.
What you have to take care of are voltage differences, the Propeller is 3.3 volt the Arduino usually 5 volt. But you can put a resistor between the 5 volt transmission line and the propeller pin to take care of that.
On the propeller side I would advise you to leave pins 30/31 for USB and programming and chose another pin for receiving, you can use serial on any pin.
Enjoy!
Mike
Since it is only 32-bits I'm guessing the speed needn't be all that high and the only concern with a lower baud-rate is the latency from when you send the message until it fully received which improves by increasing the baud-rate. If all this is inconsequential then just use a low baud rate and send the 32-bits as ASCII HEX if you like including a terminator just so it is easy to debug. So $CAFEBABE<cr> with a $ sign for message "preamble" is one example.
BTW, some will argue that you need RS-485/422 for long runs but if your long run is only 10's of meters and relatively noise free then there is nothing wrong with this scheme. Many will connect fast 1-wire 3.3V networks over 100's of feet without too much of a problem and TTL or RS232 serial is no different. If you need RS485 then that is also very simple but each Prop will need a RS485 or RS422 receiver although a comparator + resistors is way cheaper.
I usually use Maxim's MAX3160E(where unsure)/MAX3161E(where sure), a transceiver whic can pair a single ttl serial port to RS232 or RS485/422 lines.
With the MAX3160E I usually provide a single DB9 (or RJ45 for PCB space saving) connector while with MAX3161E I use both a DB9 for RS232 and 2 RJ45 (or 4 pin screw terminal) for RS485/422.
But as you mentioned also Ethernet have also a look over this converters which are now my first choice and I use them also to update Microchip PIC and Parallax P1 firmwares from remote locations: EM510 or EM2000 (EM2001) both with or without WiFi/BLE addon
It was late last night (in France) so I realize that my message was not very clear ... Thank you for your answers in any case. Some precisions.
I want to communicate several P1, like a bus (no routing and point to point). All can send to everyone (and everyone sort of what concerns him). That's why I talked about ethernet and switch. It is also necessary that a computer can be connected to read and to emit also (without special privilege).
Ideally I would like the least component possible in addition to the P1. Except for connecting them (switch type) or to connect / convert the PC. Ideally a modern PC without serial (or parallel) output ...
I know RS232, RS485, etc. But I only used them between 2 terminals. You can connect x machines without having to multiply connections (I understand 2 ring for example but if you want a single plug?).
THANK YOU
Still how far apart are these units? Is it really multi-master or is the PC the communications master?
Many modern PCs have a serial port for the reason that unlike USB serial, there is no latency and no special drivers required, but I just mentioned this previously to show that a solution could be that simple. However I am unsure of your requirements but if it were in close proximity then a single unbalanced half-duplex line would suffice with a simple circuit on the PC end.
Here is a video of multiple Propellers connected together over RS485 and although the Props are bunched together they could just as easily be 100's of meters apart if need be.
How about one pullup resistor for the bus and one current limiting safety resistor for each P1 pin that connects to the bus? Carrier Sense Multiple Access and Collision Detection code required, but not too hard to do. Down side is it needs 2 pins. Another option is to use a token passing scheme.
That gets a bit more complex, as usually someone in these connected nodes, acts as a master.
With no master, you need to detect collisions, and retry if not the same, with some random wait period..
A P1 can detect and release inside a single bit, but a computer cannot do the same.
The CAN bus transceivers are better at collision detect than RS485 designs are, however you can re-wire a RS485 so the TX enables the driver, and pre-bias the RS485 bus, to get to 'CAN-like' operation.
The board I linked above looks like it can do that, via their nifty BUS SP339 driver which has RS232/RS485/RS422 in 8 possible modes.
https://www.maxlinear.com/document?id=21620&languageid=1033&type=Schematics&partnumber=XR21B1420
You would bridge TXD to DIR1 and use INVDIR pin to have drive-enable active-low.
The PC can send short packets, and check if the address-part echos undamaged. If yes, and your echo is larger than your send, the appended data is the reply.
In this case the PC is interrogate originator, it is probably not nimble enough to be interrogate immediate echo. (maybe if your rate is slow enough ?)