Shop OBEX P1 Docs P2 Docs Learn Events
Newbie - Help, Stamp PLC — Parallax Forums

Newbie - Help, Stamp PLC

JBeanJBean Posts: 3
edited 2007-06-20 21:17 in BASIC Stamp
I just bought the Stamp PLC and I am going to use it as a pre-processor in a traffic signal controller cabinet. Bascially I want to allow up to 10 imputs, do some if-thens and send out appropriate outputs. I do not need any clock function for this use.

I want to read the 10 digital inputs and assign each to a variable. The manual does not explain how to do this very clearly. Can any one help?

thanks

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-20 20:34
    JBean,

    The manual (page 8) covers how to read the inputs and gives some sample code. Eight of the inputs are handled through a shift register while the other two are read from I/O pins. It is possible to alias each bit of the byte variable from the shift register as well as the 2 extra inputs to do what you want. In the Memory and Variables section of the Help File or BASIC Stamp Manual you can read about aliasing variable names. If your return input byte from the shift register is called, “inBits” (as per the example) then you could do something like:

    [color=#000000]inBits   VAR   Byte[/color]
    [color=#000000]Inp1    VAR   inBits.BIT0[/color]
    [color=#000000]Inp2    VAR   inBits.BIT1[/color]
    
    

    The same for the other 6 bits, then just refer to the last two inputs (9 & 10) like:
    [color=#000000]Inp9   VAR  IN6[/color]
    
    [color=#000000]Inp10 VAR  IN7[/color]
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • JBeanJBean Posts: 3
    edited 2007-06-20 20:41
    Thanks. But on the example on page 8, do I need to do the following?

    HIGH Load
    SHIFTIN Dat, Clk, MSBPRE, [noparse][[/noparse]inBits]

    If so, then in my case is the variables, Dat, Clk just dummy variables?

    Thanks for your quick response.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-20 21:14
    JBean,

    My example was how to alias the variables…You do·need the rest of the code to read the shift register. Dat and Clk are not variables…They are constants that refer to the SPI bus that the clock and data use. Load is the line that latches the data into the shift register.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • JBeanJBean Posts: 3
    edited 2007-06-20 21:17
    Thanks, my crew is building a test board for me, so now I'll have some code to work with.
Sign In or Register to comment.