PSU controller - program help
qazxsw21000
Posts: 13
Here is my program:
What happens is that the basic stamp stops executing code towards the beginning. I have to hold the "on" switch down to keep the PSU on. Can anyone help me? I can't find the problem.
' {$STAMP BS2} ' {$PBASIC 2.5} a: 'label a HIGH 0:LOW 1 'hold PSU off and red LED off IF IN15=1 THEN 'if on button pressed LOW 0 'turn PSU on PAUSE 1000 'wait one second ELSEIF IN14=1 OR IN13=0 THEN 'else, if off button is pressed or ok signal absent GOSUB b 'goto sub label b GOTO a 'goto a ELSE 'else GOTO a 'goto a ENDIF 'end if-then statement GOTO a 'goto a b: 'sub label b IF IN13=0 THEN 'if ok signal absent HIGH 0 : HIGH 1 'turn PSU off and turn red LED on END 'stop running ELSEIF IN13=1 THEN 'if ok signal is present LOW 0 : LOW 1 'turn red LED off and PSU on ENDIF 'end if-then statement RETURN 'go back to main program
What happens is that the basic stamp stops executing code towards the beginning. I have to hold the "on" switch down to keep the PSU on. Can anyone help me? I can't find the problem.
Comments
It looks like if the button is pressed it turns on the power supply, waits a second and starts over "GOTO a" where it turns the power supply back off.
Can you expain what you want it to do?
EDIT:
the program I was basing my code on, which does not support coding BASIC, had a BASIC viewer which, on the program, gave this: If I edited that, it should say this right?:
Edit: I think the formatting is okay now.
This should let you turn the PSU on and off with the program waiting for the on button after it has been turned off.
This program always stays running. If the ok signal is lost the LED will come on and the PSU will turn off. When the PSU is turned on again and it finds the ok signal, then the LED will be turned back off.
So if the LED is on, it means the last time the power supply was turned off was because of the ok signal had been lost.
Again, this program will let you use the same button for both on and off if you wanted.
No, no, no. It just means you need more practice. Like so many things, programming gets easier the more you pactice at it.
And, you're very welcome.