Shop OBEX P1 Docs P2 Docs Learn Events
need guidance, how to communicate and update variables between propellers — Parallax Forums

need guidance, how to communicate and update variables between propellers

laser-vectorlaser-vector Posts: 118
edited 2010-08-20 12:48 in Propeller 1
I have two propellers
the first one is running a touchscreen display with graphics, numbers and other objects. its pretty much maxed out on memory. so i have a second propeller that i want to read all of the sensors in my project and transfer that data to the first propeller.

where should i start learning about multi-propeller communication?? what different methods are available (eg. prop #2 updates prop #1's variables <or> prop #1 reads from prop #2...)
what types of communication methods (protocols) are easy to start learning this (eg. asynchronous RS232 or clocked serial data..)??

any help would be great!

Thx

Comments

  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-17 16:51
    If you only need half-duplex, this is easy. The method I use uses a proprietary asynchronous communication at 2 PASM instructions per long. This can only be used if both propellers are operating at the same speed. All variables are loaded into a block on the TX propeller and transferred all at once to a block on the RX propeller. The protocal is fast enough that over 256 longs can be updated every millisecond. All that needs to happen is either you have a list of consecutive longs that are the same on both Props, or just have an array, then use address numbers to get the byte/word/long you want in the array. The object I use is in my signature.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-17 16:54
    It'd help if I had a signature (love the new forum, but not everything transferred over). Maybe I have one now?
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-08-17 17:32
    One way to do this would be to start with the RS232 code. That exists already in the obex and is easy to setup. You don't need RS232 signal levels between propeller chips - indeed you could just join them with 1k resistors (you could join them directly but two pins configured as outputs might upset the prop).

    RS232 at the TTL level is "off=3.3V, on=0V) so you can put a led on the line with a dropping resistor and the anode of the led on the 3V line, so it flashes when data goes through. That makes debugging a whole lot easier.

    The RS232 code has big buffers, so you can send a burst of data and the other prop can read it out when it is ready. This is where the propeller really shines compared with so many other microcontrollers - you can have a cog buffering all that data all in the background.

    At times I've even resorted to silly slow baud rates (110 baud, anyone?) to debug things. Then ramp up the speed when it is working. You can make it as fast as pasm will go (or until problems like line capacitance and reflection start becoming a problem, but that is up in the megahertz).
  • laser-vectorlaser-vector Posts: 118
    edited 2010-08-18 14:56
    Bobb Fwed wrote: »
    If you only need half-duplex, this is easy. The method I use uses a proprietary asynchronous communication at 2 PASM instructions per long. This can only be used if both propellers are operating at the same speed. All variables are loaded into a block on the TX propeller and transferred all at once to a block on the RX propeller. The protocal is fast enough that over 256 longs can be updated every millisecond. All that needs to happen is either you have a list of consecutive longs that are the same on both Props, or just have an array, then use address numbers to get the byte/word/long you want in the array. The object I use is in my signature.

    i gave that code in your sig a try,

    i loaded the Prop_Comm_Demo onto two props,

    made sure that prop 1's rx went to prop 2's tx and vise verse.

    installed the two 10k pull-down resistors.

    propcommdemo004.jpg

    connected a 200mhz scope to the tx pin on prop 1.

    i see the data flow but when running at PLL 16x i see a lot of transiant voltage spikes (like little inductive peaks on the leading edge of the square waves..) and to me the data doesn't look very clean...
    propcommdemo003.jpg

    when i turn the PLL down to 4x the transient peaks are still present but the square waves are much more defined!!
    propcommdemo001.jpg

    so, aside from all that, when i run this code and debug it on the parallax serial terminal all i get are warnings
    warn.jpg

    what should it be debugging if information did not differ??
    IF (?seed <> long[rx_buff][i])                    ' if information differs from what it is supposed to be
            DEBUG.str(string("Warning",$D)) 
    

    by different does it mean corrupt or nothing is there???
    i was really hoping someone could shed some light on this issue
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-18 15:11
    The demo program assumes both RX and TX cogs are loaded at nearly the same time. If they aren't the seeds won't line up. With two separate propellers this is much more difficult than the demo loading two cogs on the same propeller.

    It is best for you to load some known data into the TX propeller and just make sure it is coming over to the RX propeller. Because you are getting movement on the line my guess is that the data is being sent, but the seeds won't sync.

    Keep in mind that both propellers must be the same clock speed (+/- 0.2%) which shouldn't be a problem with most crystals, but you just need to keep that in mind when reprogramming them to slower speeds.
  • LeonLeon Posts: 7,620
    edited 2010-08-18 19:45
    Those funny signals could be caused by using a solderless breadboard. I never use them.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2010-08-18 23:21
    I presume the prop at the top has bypass caps etc, but the one on the breadboard doesn't seem to have any. Try a couple of 0.1uFs across the supply pins, and maybe a 33uF tantalum as well. There is a lot of ringing on those lines. Maybe it isn't the data line - maybe it is the ground line ringing because of a lack of bypass caps. Just guessing here. But I'm used to seeing very square square waves on my cro...
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-19 08:58
    Plus, I don't see power going to both sides of the propeller on the breadboard (don't know if that makes a bit difference, but it is highly recommended).

    Here is a photo of my propeller. Also on a breadboard. I have decoupling caps and 1000µF cap on power, a pulldown resistor on the line I am measuring. There is still a bit of a spike, but nothing like you are seeing.

    attachment.php?attachmentid=72611&stc=1&d=1282233445
    800 x 478 - 39K
  • laser-vectorlaser-vector Posts: 118
    edited 2010-08-19 10:48
    It was the probe...

    i was originally using some skinny volt meter probes but once i replaced them with a nice insulated probe the square waves were apparent.


    propcommdemo008.jpg
    propcommdemo.jpg

    as you can see: Ch1 (yellow) is the crappy volt meter probes while Ch2 (blue) is the probe designed for the oscilloscope
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2010-08-20 12:48
    Nice scope, laser-vector
Sign In or Register to comment.