Strange results when using objects in SPIN
Hello all,
I am a fairly new user of the propeller processor technology, and I am having a problem with some of my SPINcode that I was hoping someone could help me out with.
I·created some code in a routine that resets an input pin and then tests it to see if that pin is still low:
····· PUB Scanner
1)···ina[noparse][[/noparse]4] := 0
2)· ·IF ina[noparse][[/noparse]4] == 0
3)···· Beep
(where Beep is·a call to a routine that activates a beeper)
When I run this code directly, the processor beeps as·expected. However, when I run·a·separate object that calls this method, the circuit does not beep.
If I change line 2 of the code to read:
IFNOT ina[noparse][[/noparse]4] == 0
Then the circuit beeps. If I change the·line to read
IFNOT ina[noparse][[/noparse]4] == 1
The circuit still beeps. In other words, the circuit is telling me that pin 4 is neither a 1 nor a 0. However, if I change the line to read
IF ina[noparse][[/noparse]4] == 0 OR ina[noparse][[/noparse]4] == 1
The circuit beeps, telling me that pin 4 is either a 1 or 0 (or both?).
Does anyone know why this is happening? Why does the·system·operate correctly when I run the method directly, but then give confilcting results when I·run the method by calling it through a different object? Any help would be grealtly appreciated. Thanks.
--Eli
··
I am a fairly new user of the propeller processor technology, and I am having a problem with some of my SPINcode that I was hoping someone could help me out with.
I·created some code in a routine that resets an input pin and then tests it to see if that pin is still low:
····· PUB Scanner
1)···ina[noparse][[/noparse]4] := 0
2)· ·IF ina[noparse][[/noparse]4] == 0
3)···· Beep
(where Beep is·a call to a routine that activates a beeper)
When I run this code directly, the processor beeps as·expected. However, when I run·a·separate object that calls this method, the circuit does not beep.
If I change line 2 of the code to read:
IFNOT ina[noparse][[/noparse]4] == 0
Then the circuit beeps. If I change the·line to read
IFNOT ina[noparse][[/noparse]4] == 1
The circuit still beeps. In other words, the circuit is telling me that pin 4 is neither a 1 nor a 0. However, if I change the line to read
IF ina[noparse][[/noparse]4] == 0 OR ina[noparse][[/noparse]4] == 1
The circuit beeps, telling me that pin 4 is either a 1 or 0 (or both?).
Does anyone know why this is happening? Why does the·system·operate correctly when I run the method directly, but then give confilcting results when I·run the method by calling it through a different object? Any help would be grealtly appreciated. Thanks.
--Eli
··
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
-Phil
dira:=0
and in the other cog, it's set to an output.
dira:=1
By default they are inputs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Play Defender - Propeller version of the classic game
Prop Room Robotics - my web store for Roomba spare parts in the UK