I'm sure I'm making a silly mistake......
cthomas
Posts: 17
This is driving me crazy. My thanks in advance for holding my hand here.
Read_pushbuttons runs in it's own cog and is supposed to monitor the state of four different buttons.
Two work and two don't. Edit: The nested repeats don't post correctly. Dang.
Everything else besides this little area works as planned but see my comments....
Here it is; pushing any of the buttons applies 3.3v to it's respective input pin. All pins have 10k pulldowns.
Pub Read_pushbuttons
Repeat
Repeat while (Stop_state == 1)
If ina[Edge_button] == 1
Edge_targets 'Never happens, even when button is pushed
If ina[Face_button] == 1
Face_targets 'Never happens, even when button is pushed
If ina[start_button] == 1
Stop_state :=0 'Works perfectly when the start button is pushed
Repeat while (stop_state == 0)
If ina[Stop_button] == 1
Stop_state :=1
Reboot Works perfectly when the Stop button is pushed
Pub Edge_targets 'Called by other parts of the program and works fine
OutA[Relay_targets] :=0
Pub Face_targets
OutA[Relay_targets] :=1 'The same, called by other parts of the program and works fine
Thanks,
Craig
Read_pushbuttons runs in it's own cog and is supposed to monitor the state of four different buttons.
Two work and two don't. Edit: The nested repeats don't post correctly. Dang.
Everything else besides this little area works as planned but see my comments....
Here it is; pushing any of the buttons applies 3.3v to it's respective input pin. All pins have 10k pulldowns.
Pub Read_pushbuttons
Repeat
Repeat while (Stop_state == 1)
If ina[Edge_button] == 1
Edge_targets 'Never happens, even when button is pushed
If ina[Face_button] == 1
Face_targets 'Never happens, even when button is pushed
If ina[start_button] == 1
Stop_state :=0 'Works perfectly when the start button is pushed
Repeat while (stop_state == 0)
If ina[Stop_button] == 1
Stop_state :=1
Reboot Works perfectly when the Stop button is pushed
Pub Edge_targets 'Called by other parts of the program and works fine
OutA[Relay_targets] :=0
Pub Face_targets
OutA[Relay_targets] :=1 'The same, called by other parts of the program and works fine
Thanks,
Craig
Comments
Please use [noparse] [/noparse] tags for any code posting.
I'm not familiar with the tags? If it's easy to explain how to use them, I will.
Thanks for looking.
Just put the [ code] [ /code] tags at the beginning and end of the code (remove the spaces).
This:
is the pub I wanted to run in it's own separate cog 1. I have commented out the commands that won't run here but do run perfectly when placed where they run in the cog 0 running most of the program.
Any thoughts? Thanks everybody.
I can see the point, and somehow I missed altogether that spin running in different cogs needs it's own local declarations on the pins it's using? That would explain my difficulty.
Drat.. I was thinking the one set of declarations in cog 0 took care of it.
I have the Propeller Education Kit Labs book and I see that the example on page 71 works as you are suggesting but does the book ever spell this out?
Thanks for helping.