rf relay control
Archiver
Posts: 46,084
Very new to stamps and failing at a simple task. Have five button rf
key fob and trying to control five relays. Reseiver outputs +5v when
button is pushed, want first push to turn on and leave on
relay,second push to turn off. Tried if in=1then toggle out15 get
expected label.I'm a 45year old auto tech who isn't learning as fast
as I was. Can someone rec. a good beg. programing book and or code,I
know this has to be a common program. Have built and tested hardware
from cookbook. thanks jeff
key fob and trying to control five relays. Reseiver outputs +5v when
button is pushed, want first push to turn on and leave on
relay,second push to turn off. Tried if in=1then toggle out15 get
expected label.I'm a 45year old auto tech who isn't learning as fast
as I was. Can someone rec. a good beg. programing book and or code,I
know this has to be a common program. Have built and tested hardware
from cookbook. thanks jeff
Comments
IF IN1 = 0 THEN Skip1
' else, in1 is 1, so toggle it.
TOGGLE OUT15
SKIP1:
The BS2 'IF' ONLY does 'GOTO' at the end of it.
Note another problem you might have is 'double
triggers' -- that is, if you hold down the
button, the relay kicks in, then out, then in...
You may have to store a state, and do some small
state machine:
0 == Relay off, waiting for first 1.
1 == Got first 1, turn relay on, now wait for first 0.
2 == Got first 0, leave relay on, wait for next 1.
3 == Got first 1, turn relay off, wait for next 0.
( After 3, next 'state' should be 0)
The syntax error is complaining about the 'Toggle',
which isn't a label in your program.
--- In basicstamps@yahoogroups.com, "jeff_carruthers2000"
<jeff_carruthers2000@y...> wrote:
> Very new to stamps and failing at a simple task. Have five button
rf
> key fob and trying to control five relays. Reseiver outputs +5v
when
> button is pushed, want first push to turn on and leave on
> relay,second push to turn off. Tried if in=1then toggle out15 get
> expected label.I'm a 45year old auto tech who isn't learning as
fast
> as I was. Can someone rec. a good beg. programing book and or
code,I
> know this has to be a common program. Have built and tested
hardware
> from cookbook. thanks jeff
IF-THEN to behave more like desktop version of BASIC. So, you can now
do this:
IF IN1 = 1 THEN TOGGLE 15
The only *problem* with the code above is it is just as mysterious as
all the bad BASIC code written since the language was developed. As
desktop versions of BASIC have evolved, so has PBASIC. With a couple of
simple declarations, that line of code can be made to look like this:
IF (RelayCtrl = Pressed) THEN TOGGLE RelayOut
which, at least, gives us some indication of what the code is doing.
I bring this up because I am frequently asked for assistance with fixing
broken programs and most of the time is spent weeding through mystery
code just trying to figure out what's going on. To that end, we've
developed a document called "The Elements of PBASIC Style" that
describes the format that we [noparse][[/noparse]Parallax] have developed and adopted for
our programs. Yes, not everything in publication today matches this
format -- we're working on int (and with all the code we've published in
the 10 years BASIC Stamps have been around it will take some time to
sort through).
"The Elements of PBASIC Style" is available on our web site in PDF for
and is included in the Help file with the latest version of the BASIC
Stamp compiler.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Allan Lane [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=8V4nQzv5riWeknGN_cACERCoyi6U1PTU-ZzW26okTO6OFaQGXaeZcG-uIKJygvGmpdihCT5qNA9xMqJfLFODHK7lPA]allan.lane@h...[/url
Sent: Monday, September 01, 2003 5:57 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: rf relay control
Your example needs:
IF IN1 = 0 THEN Skip1
' else, in1 is 1, so toggle it.
TOGGLE OUT15
SKIP1:
The BS2 'IF' ONLY does 'GOTO' at the end of it.
Note another problem you might have is 'double
triggers' -- that is, if you hold down the
button, the relay kicks in, then out, then in...
You may have to store a state, and do some small
state machine:
0 == Relay off, waiting for first 1.
1 == Got first 1, turn relay on, now wait for first 0.
2 == Got first 0, leave relay on, wait for next 1.
3 == Got first 1, turn relay off, wait for next 0.
( After 3, next 'state' should be 0)
The syntax error is complaining about the 'Toggle',
which isn't a label in your program.
--- In basicstamps@yahoogroups.com, "jeff_carruthers2000"
<jeff_carruthers2000@y...> wrote:
> Very new to stamps and failing at a simple task. Have five button
rf
> key fob and trying to control five relays. Reseiver outputs +5v
when
> button is pushed, want first push to turn on and leave on
> relay,second push to turn off. Tried if in=1then toggle out15 get
> expected label.I'm a 45year old auto tech who isn't learning as
fast
> as I was. Can someone rec. a good beg. programing book and or
code,I
> know this has to be a common program. Have built and tested
hardware
> from cookbook. thanks jeff
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....