WAITPEQ etc., What am I doing incorrectly?
Hugh
Posts: 362
Hi,
I may be being thick here, but I have a bit of problem with WAITPEQ, etc.,
My first version of the code looked like this:
Not very difficult and when the input pin went low (via an opto-isolator and lots of other stuff) the outputs (LEDs) would light.
The next stage was to try and use WAITPEQ to wait until the input went low, then use WAITPEQ again until it went high. The code I tried was to replace the content of the repeat loop with:
which doesn't work. All I am doing (or attempting) is to wait for pin 23 to be in one state then the other.
What have I missed?
Thanks
Hugh
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
I may be being thick here, but I have a bit of problem with WAITPEQ, etc.,
My first version of the code looked like this:
CON INPUT_PIN = 23 SD_DATA = 12 ECH_PIN =8 PUB doStuff dira[noparse][[/noparse]INPUT_PIN]~ dira[noparse][[/noparse]SD_DATA]~~ dira[noparse][[/noparse]ECHO_PIN]~~ repeat if ina[noparse][[/noparse]INPUT_PIN] outa[noparse][[/noparse]SD_DATA]~ outa[noparse][[/noparse]ECHO_PIN]~~ numBytes++ else outa[noparse][[/noparse]SD_DATA]~~ outa[noparse][[/noparse]ECHO_PIN]~
Not very difficult and when the input pin went low (via an opto-isolator and lots of other stuff) the outputs (LEDs) would light.
The next stage was to try and use WAITPEQ to wait until the input went low, then use WAITPEQ again until it went high. The code I tried was to replace the content of the repeat loop with:
repeat waitPEQ (%10000000000000000000000, %10000000000000000000000, 0) outa[noparse][[/noparse]SD_DATA]~ outa[noparse][[/noparse]ECHO_PIN]~ waitPEQ (%10000000000000000000000, %10000000000000000000000, 1) outa[noparse][[/noparse]SD_DATA]~~ outa[noparse][[/noparse]ECHO_PIN]~~
which doesn't work. All I am doing (or attempting) is to wait for pin 23 to be in one state then the other.
What have I missed?
Thanks
Hugh
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
Comments
Should this not be
·"waitPEQ·(%0000000000000000000000,·%10000000000000000000000,·0)" 'test for·low state
·waitPEQ·(%1000000000000000000000,·%10000000000000000000000,·0)"· ' test for high state
regards
Gerry
Post Edited (Gerry Keely) : 2/24/2010 9:28:39 AM GMT
Thanks - I had a TIA last week so am not as with-it as I normally am!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
In your first code you set PIN 23 as input-pin. But your waitpeq waits for PIN 22 ..... remember, pin numbers start with 0
It's safer to say !<23 instead ... or define a constant that you use in both, the dira and the waitxxx-statement.