Prop 2 Prop Communication Which way should I go?
Shawna
Posts: 508
I have been reading the forums for the last couple of hours and cannot decide which direction to go.
I have 2 propellers that I want to hook together. I am thinking a master and slave configuration will work. I want the master to request data from the slave once a second at max. The amount of data will probably be around 100 longs max. The master will also have to be able to write data to the slave. The props will be on 2 different boards tied together with a 6 inch ribbon cable. It doesn't need to be a master slave configuration, but I think a master slave combo might be easier to do.
What is the simplest way to do this. I looked at Beau's High Speed demo but I think that it is over kill, and to be honest I don't fully understand it.
Should I use the full duplex object or should I use I2C.
Also memory on my master prop is about maxed out and I am already using 4 cogs.
If someone could point me in a direction that would be awesome.
Thanks
Shawn
I have 2 propellers that I want to hook together. I am thinking a master and slave configuration will work. I want the master to request data from the slave once a second at max. The amount of data will probably be around 100 longs max. The master will also have to be able to write data to the slave. The props will be on 2 different boards tied together with a 6 inch ribbon cable. It doesn't need to be a master slave configuration, but I think a master slave combo might be easier to do.
What is the simplest way to do this. I looked at Beau's High Speed demo but I think that it is over kill, and to be honest I don't fully understand it.
Should I use the full duplex object or should I use I2C.
Also memory on my master prop is about maxed out and I am already using 4 cogs.
If someone could point me in a direction that would be awesome.
Thanks
Shawn
Comments
I guess 1 other difference would be that I need 4 pins for the I2C and 2 for the full duplex object. I think I have plenty of pins left over.
Thanks for the input guys.
You can get by quite fine with a single half-duplex asynch line. The slave cog will always be listening so that could just be simple Spin code which btw will take up a lot less memory than a PASM object. The master can have a bit of simple Spin code to transmit the command and then switch to Spin code to receive the response. The beauty about this is that it takes very little memory. Of course you can get as complicated as you like with multi-port objects and buffers and such but really a single I/O and a bit of Spin code is all you need. If you take this course it will be functional in no time and then if you want you can consider other options later.
Or just leave a series resistor in of at least 100R and it doesn't matter if there is one at either end so you don't even have to worry about switching to open-drain because open-drain on a Prop is never really open-drain. So this pin could also source current due to a software glitch perhaps in which case you want to current limit either way.
@Shawna
But yes, don't try to over think it, half-duplex is all that really happens on most full-duplex lines due to operation of master/slave software in that the slave is always listening and when the master talks it responds then and there only - so half-duplex is all that is ever needed. It does all you need and it's KISS. (don't make the beginner's mistake of thinking that the more complicated solution is the best, or that it's needed just in case).
IMHO I2C is overkill.
http://obex.parallax.com/object/266
Is this the one you guys would recommend.
I agree I don't need anything too fancy, I would like something that runs fairly quickly, does its thing and moves on.
I need easy and small. The only reason I am running 2 Props is because the first props code space is full.
I appreciate all your advice guys, I don't want to over kill this task but it is nice to see all the options available.
Thanks
Shawn
Shawna, I'm not sure why you would need 4 pins for I2C. On the Propeller, pin 28 is SCL and pin 29 is SDA (the prop uses I2C to access the EEPROM, if present).
You could reuse these pins since I2C devices are individually addressed. Unless, of course, you're using them for some other (non-I2C) purpose after boot.
Walter
Seems that object only goes up to 19.2k baud (and @96MHz!) so if that is fast enough for you then fine. I looked back in my old files and I have half duplex PASM drivers, so that means they will consume a cog but they do run at megabaud rates. At those speeds you can get a response back a lot faster too so that there is no waiting around if that's what your software would be doing.
I know in Tachyon I can get 250k baud rates with the equivalent of the simple Spin object so neither requires a dedicated PASM cog, but I am always surprised at how slow Spin is when it comes to bit-banging.
Let me know if you want a PASM driver as I can dress it up before posting. While it's possible to use FDS for this kind of thing you don't really need it to buffer the transmit because when you operate at high speed it's better to bang it out right there and then after which you can switch the line around back to receive.
But by all means try out Kye's driver first, it only consumes 84 longs total.
That would be awesome if you could post a PASM version. I was hoping to run it as fast as possible. I will probably play with Kyes example. I have 4 extra cogs available on the Prop that is about out of code space. Spin is great but not when you need speed, I was hoping to get speeds of at least 115K baud. Faster would be great to, if the ribbon cable can handle it.
Thanks
Shawn
Your right, about the 2 pin thing on I2C, Im not sure what I was thinking about. Does SPI use 4 pins?
Is the data you need to send from the master created or pre-defined strings? if it's pre-defined you wouldn't need an out buffer either that would also help save ram space since you are almost maxed out.
I wouldn't overcomplicate it with any other protocol, serial is probably the smallest codewise, would probably get it smaller than 84 longs and that's including two 100 byte buffers.
That's assuming you don't have a lot of space left to use Kye's driver or even the simple serial driver.
Yes, SPI uses 4 pins. That's probably what you were thinking about.
Walter
That's just a loop counter, and as long as both ends agree, you can use something more useful, like 18* or 19 etc
*18 would allow a single message to load S and D fields of an opcode, as a jmp-adr & param.
That allows the Host to call procedures in the slave, and they echo-when-done.
Maybe PST would no be acceptable for Prop to Prop communication anyways.
Or maybe I should change the w5200 server object to use a different serial object.
You could substitute the four port object for the PST serial object, use port 0 for debugging on P30/31 and one of the 3 remaining ports for prop to prop communications. This is what I do, and why I use the four port object as the default choice. Don't forget to put resistors on all the serial pins as suggested in a previous post. That way you will not risk damaging them with a program or wiring mistake. You can also reduce the size of the spin portion of the code by removing unused subroutines as well.
BTW, half duplex serial would be fine for a master/slave setup, but full duplex is better for peer/peer communications. If the props have to share some data there may be times when having them capable of sending and receiving simultaneously will be necessary.
Thanks Again Guys
Shawn
It uses the four port serial object and implements packet style communications
I actually use it to communicate between a raspberry pi and the prop
It compiles without errors and I am sure you could modify it quite easily for your own use
Is this the four duplex serial you use in your example?
http://obex.parallax.com/object/248
The mods I made to the object just added things like ShoText(Port,Row,Col,StrPtr)
Which combined positioning and text display. You should be able to drop it in and go.
I quite literally spent five minutes removing it from a much larger routine and making sure it compiles ok.
Ill attach my fourportserial object here for you to use.
Thanks
Shawn
I changed this line from this.
Debug.dec(slavetoken[0])
To this.
Debug.dec(~~slavetoken[0])
I think I only need to do this for the terminal display, I have never had to do this before.
This code does work. When I send a byte from the slave to the master the master receives the proper value.
When I try to transmit with the slave cog instead of receive, I get garbage.
Pins 1 and 2 are tied together with a 330 ohm resistor and pins 0 and 3 are tied together with a 330 ohm resistor. I don't have any pull-up or pull-down resistors attached. I believe I am using the original fullduplexserial object.
Thanks
Shawn