Newbie - Help, Stamp PLC
JBean
Posts: 3
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
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
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:
The same for the other 6 bits, then just refer to the last two inputs (9 & 10) like:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
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.
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