Shop OBEX P1 Docs P2 Docs Learn Events
can one sx28 store a number that another sx28 can access? — Parallax Forums

can one sx28 store a number that another sx28 can access?

mspeediemspeedie Posts: 12
edited 2009-10-22 05:39 in General Discussion
I'm sure this has been addressed before but I couldn't find anthing in this forum helping me figure out how to have one sx28 store a numeric value (1-6) that another sx28 can access at certain intervals. I am using SX-B (no assembly skills unfortunately).

Can this all be done within the two sx28's or do I need an external memory chip?

Any help is appreciated.

Thanks, Mike

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-17 20:12
    If you have a block of 3 I/O pins free on each SX28, you can simply hook the 3 I/O pins from one SX28 to the other using a 330 Ohm resistor on each pin. You'd declare the I/O pins as inputs on one SX28 and as outputs on the other SX28 (where the output register would work like a variable). You'll need to initialize the I/O pins appropriately by declaring the individual pins as INPUT or OUTPUT. One example of the declarations is "4 bit Parallel LCD Display with SX28 (SX/B 2.0)" here http://forums.parallax.com/showthread.php?p=642725.

    If you use pins 0-2 of one of the byte I/O ports, you'll have an easier time setting and checking the 3-bit value. If the port is called Comm, you'd set a new value (NewValue) by using something like:
    Temp = Comm & %11111000
    Temp = Comm | NewValue
    Comm = Temp
    


    To test the value on the other SX28:
    Temp = Comm & %00000111
    IF Temp = 3 THEN
    
  • mspeediemspeedie Posts: 12
    edited 2009-10-22 05:24
    Mike:

    Thanks for the reply. That's definitely more efficient than my original solution which was:

    first sx chip:
    if x=..., then high pin 1
    else if x = ..., then high pin 2
    else if x = ..., then high pin 3
    else if x = ..., then high pin 4
    else if x = ..., then high pin 5
    else if x = ..., then high pin 6

    I had pins 1-6 on the first sx chip connected respectively to pins 1-6 on the second sx chip. So the second sx chip was scanning all six pins looking for the high. I wasn't using a 330-ohm resister between them though. It seemed that after my code triggered one of the pins 1-6 high, when the pin was set back to low, it occasionally remained high. I solved this by connecting a 1-Mohm resister between the two chips and ground to instantly discharge any remaining charge between the two. Have you experienced this before? Is that what the 330-ohm resistor takes care of?

    Mike
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-22 05:39
    You were probably setting the pins back to input mode rather than setting them to low output. That way you have two inputs tied together and the state of that is dependent on stray electrical fields around the pins. If there's significant capacitance where you have them connected, it's quite possible that the voltage would stay high until "bled off".
Sign In or Register to comment.