Totally befuddled
Hi,
I have a very simple application for a BS1. I have a signal coming from an
inverter that goes HIGH for 20 seconds, then goes LOW again. I want to take
this signal in on pin0 and change the output of pin4 to LOW for 100ms. My
program is as follows:
'*****************************
pins = 00011000
dirs = 11111110
CHECK0: if pin1 = 0 then GOLOW
goto CHECK0
GOLOW: pin4 = 0
pause 100
pin4 = 1
goto CHECK0
'*****************************
What's been happening is when pin0 goes LOW, pin4 goes LOW and stays there
until pin0 goes HIGH. The program seems to hang on the [noparse][[/noparse]pause] statement.
If I comment out the [noparse][[/noparse]pause] statement, pin4 will start to go LOW but will
pop right back to HIGH.
I have a pull-down resistor connected to pin0. I thought of trying the
BUTTON command, but didn't think it would help since the input signal is
digital.
Thanks.
Telle
_______________________________________________________
Send a cool gift with your E-Card
http://www.bluemountain.com/giftcenter/
I have a very simple application for a BS1. I have a signal coming from an
inverter that goes HIGH for 20 seconds, then goes LOW again. I want to take
this signal in on pin0 and change the output of pin4 to LOW for 100ms. My
program is as follows:
'*****************************
pins = 00011000
dirs = 11111110
CHECK0: if pin1 = 0 then GOLOW
goto CHECK0
GOLOW: pin4 = 0
pause 100
pin4 = 1
goto CHECK0
'*****************************
What's been happening is when pin0 goes LOW, pin4 goes LOW and stays there
until pin0 goes HIGH. The program seems to hang on the [noparse][[/noparse]pause] statement.
If I comment out the [noparse][[/noparse]pause] statement, pin4 will start to go LOW but will
pop right back to HIGH.
I have a pull-down resistor connected to pin0. I thought of trying the
BUTTON command, but didn't think it would help since the input signal is
digital.
Thanks.
Telle
_______________________________________________________
Send a cool gift with your E-Card
http://www.bluemountain.com/giftcenter/
Comments
Kind of early for me to be venturing a guess -- not much of a morning
person.
However, it looks to me like your dirs is incorrect. The dirs register makes
pins outputs (1) or inputs (0). You have a few problems. First, the
rightmost bit is pin0, not pin1. Also, you need a binary prefix on those
numbers (maybe that's a typo?):
pins = %00011000
dirs = %00010000 ' pin 4 output, pin 1 input (all other pins inputs BTW)
You could avoid manipulating the dirs altogether if you take advantage of
the fact that a) the default is inputs, and b) the HIGH and LOW commands set
the direction automatically:
HIGH 4
CHECK0: if pin1=0 then GOLOW
goto CHECK0
GOLOW: LOW 4
pause 100
HIGH 4
GOTO CHECK0
Something like that.
Regards,
Al Williams
AWC
* Floating point math for the Stamp, PIC, SX, or any microcontroller:
http://www.al-williams.com/awce/pak1.htm
>
Original Message
> From: Brian Fay [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=-dPiZX62TZgqtXouCihMbq1_clfo0sLbaXKU9oOWc78W1MC-aqjfNNO4aLrFay9zIPiYgo_dfJi_nScdgA]keithtelle@e...[/url
> Sent: Friday, February 02, 2001 7:48 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Totally befuddled
>
>
> Hi,
>
> I have a very simple application for a BS1. I have a signal
> coming from an
> inverter that goes HIGH for 20 seconds, then goes LOW again. I
> want to take
> this signal in on pin0 and change the output of pin4 to LOW for 100ms. My
> program is as follows:
>
> '*****************************
> pins = 00011000
> dirs = 11111110
>
> CHECK0: if pin1 = 0 then GOLOW
> goto CHECK0
>
> GOLOW: pin4 = 0
> pause 100
> pin4 = 1
> goto CHECK0
> '*****************************
>
> What's been happening is when pin0 goes LOW, pin4 goes LOW and stays there
> until pin0 goes HIGH. The program seems to hang on the [noparse][[/noparse]pause]
> statement.
> If I comment out the [noparse][[/noparse]pause] statement, pin4 will start to go LOW but will
> pop right back to HIGH.
>
> I have a pull-down resistor connected to pin0. I thought of trying the
> BUTTON command, but didn't think it would help since the input signal is
> digital.
>
> Thanks.
>
> Telle
>
>
>
>
>
> _______________________________________________________
> Send a cool gift with your E-Card
> http://www.bluemountain.com/giftcenter/
>
>
>
>
I think that this is your problem:
The first time pin0 goes low you jump to GOLOW, set pin4 low for 100ms, set
it high again
and jump to CHECK0.
But as you said the input signal on pin0 goes low for 20 seconds so it's
still low when you
come back from GOLOW and therefor your program jumps to GOLOW again.
That will keep on happening until pin0 goes high again.
Did that make any sense??
/Henrik Olsson.
Original Message
> Hi,
> I have a very simple application for a BS1. I have a signal coming from
an
> inverter that goes HIGH for 20 seconds, then goes LOW again. I want to
take
> this signal in on pin0 and change the output of pin4 to LOW for 100ms. My
> program is as follows:
>
> '*****************************
> pins = 00011000
> dirs = 11111110
>
> CHECK0: if pin1 = 0 then GOLOW
> goto CHECK0
>
> GOLOW: pin4 = 0
> pause 100
> pin4 = 1
> goto CHECK0
> '*****************************
>
> What's been happening is when pin0 goes LOW, pin4 goes LOW and stays there
> until pin0 goes HIGH. The program seems to hang on the [noparse][[/noparse]pause] statement.
> If I comment out the [noparse][[/noparse]pause] statement, pin4 will start to go LOW but will
> pop right back to HIGH.
>
> I have a pull-down resistor connected to pin0. I thought of trying the
> BUTTON command, but didn't think it would help since the input signal is
> digital.
>
> Thanks.
>
> Telle
a meter?
The reason I say is that if you bring the pin 1 low and hold it low, you'll
keep pulsing pin 4 and on a meter, it may never read the little 100mS pulse.
If you wanted a single trigger, you'd need to say:
CHECK0: if pin1 = 1 then CHECK0 ' save a command by reversing the sense of
this
GOLOW: pin4 = 0
pause 100
pin4 = 1
GOWAIT: if pin1=0 then GOWAIT
goto CHECK0
If the contact on pin1 has "bounce' You might need more than that.
Regards,
Al Williams
AWC
* Control 8 servos at once: http://www.al-williams.com/awce/pak8.htm
>
Original Message
> From: Brian Fay [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=7NQoGpKFQjpOtalXUBWLAQlTNj3QPuqVhwtCer-CdhEYB8adQcsz4CZQXUi109kGAnehBZcNUlPq6vIa]keithtelle@e...[/url
> Sent: Friday, February 02, 2001 7:48 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Totally befuddled
>
>
> Hi,
>
> I have a very simple application for a BS1. I have a signal
> coming from an
> inverter that goes HIGH for 20 seconds, then goes LOW again. I
> want to take
> this signal in on pin0 and change the output of pin4 to LOW for 100ms. My
> program is as follows:
>
> '*****************************
> pins = 00011000
> dirs = 11111110
>
> CHECK0: if pin1 = 0 then GOLOW
> goto CHECK0
>
> GOLOW: pin4 = 0
> pause 100
> pin4 = 1
> goto CHECK0
> '*****************************
>
> What's been happening is when pin0 goes LOW, pin4 goes LOW and stays there
> until pin0 goes HIGH. The program seems to hang on the [noparse][[/noparse]pause]
> statement.
> If I comment out the [noparse][[/noparse]pause] statement, pin4 will start to go LOW but will
> pop right back to HIGH.
>
> I have a pull-down resistor connected to pin0. I thought of trying the
> BUTTON command, but didn't think it would help since the input signal is
> digital.
>
> Thanks.
>
> Telle
>
>
>
>
>
> _______________________________________________________
> Send a cool gift with your E-Card
> http://www.bluemountain.com/giftcenter/
>
>
>
>
pulsed pin 4 once and don't need to pulse it again until the next '1' to
'0' transition on pin 1. Try something like this.
HIGH 4
CHECK0: if pin1=0 then GOLOW
goto CHECK0
WAITFOR1:
if pin1 = 1 then CHECK0
goto WAITFOR1
GOLOW: LOW 4
pause 100
HIGH 4
GOTO WAITFOR1
This will wait for pin 1 to a '1' before again checking for a '0'.
Hope this helps,
Bob Baxter
At 08:57 AM 2/2/01 -0600, Al Williams wrote:
>Hi Brian,
>
>Kind of early for me to be venturing a guess -- not much of a morning
>person.
>
>However, it looks to me like your dirs is incorrect. The dirs register makes
>pins outputs (1) or inputs (0). You have a few problems. First, the
>rightmost bit is pin0, not pin1. Also, you need a binary prefix on those
>numbers (maybe that's a typo?):
>
>pins = %00011000
>dirs = %00010000 ' pin 4 output, pin 1 input (all other pins inputs BTW)
>
>You could avoid manipulating the dirs altogether if you take advantage of
>the fact that a) the default is inputs, and b) the HIGH and LOW commands set
>the direction automatically:
>
>HIGH 4
>CHECK0: if pin1=0 then GOLOW
>goto CHECK0
>
>GOLOW: LOW 4
>pause 100
>HIGH 4
>GOTO CHECK0
>
>Something like that.
>
>Regards,
>
>Al Williams
>AWC
>* Floating point math for the Stamp, PIC, SX, or any microcontroller:
>http://www.al-williams.com/awce/pak1.htm
>
>
>
>>
Original Message
>> From: Brian Fay [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=g8PrqYdm9lBfcgEbkSI2GsQUYJ4GVzQaM_1mfiStA_GpZd9vcfxhGZ4HIRip7tvwaugLv_nJ2PYIV6I]keithtelle@e...[/url
>> Sent: Friday, February 02, 2001 7:48 AM
>> To: basicstamps@yahoogroups.com
>> Subject: [noparse][[/noparse]basicstamps] Totally befuddled
>>
>>
>> Hi,
>>
>> I have a very simple application for a BS1. I have a signal
>> coming from an
>> inverter that goes HIGH for 20 seconds, then goes LOW again. I
>> want to take
>> this signal in on pin0 and change the output of pin4 to LOW for 100ms. My
>> program is as follows:
>>
>> '*****************************
>> pins = 00011000
>> dirs = 11111110
>>
>> CHECK0: if pin1 = 0 then GOLOW
>> goto CHECK0
>>
>> GOLOW: pin4 = 0
>> pause 100
>> pin4 = 1
>> goto CHECK0
>> '*****************************
>>
>> What's been happening is when pin0 goes LOW, pin4 goes LOW and stays there
>> until pin0 goes HIGH. The program seems to hang on the [noparse][[/noparse]pause]
>> statement.
>> If I comment out the [noparse][[/noparse]pause] statement, pin4 will start to go LOW but will
>> pop right back to HIGH.
>>
>> I have a pull-down resistor connected to pin0. I thought of trying the
>> BUTTON command, but didn't think it would help since the input signal is
>> digital.
>>
>> Thanks.
>>
>> Telle
>>
>>
>>
>>
>>
>> _______________________________________________________
>> Send a cool gift with your E-Card
>> http://www.bluemountain.com/giftcenter/
>>
>>
>>
>>
>
>
>
>
>
> > coming from an
> > inverter that goes HIGH for 20 seconds, then goes LOW again. I
> > want to take
> > this signal in on pin0 and change the output of pin4 to LOW for 100ms. My
> > program is as follows:
> > '*****************************
> > pins = 00011000
> > dirs = 11111110
> >
> > CHECK0: if pin1 = 0 then GOLOW
> > goto CHECK0
> >
> > GOLOW: pin4 = 0
> > pause 100
> > pin4 = 1
> > goto CHECK0
> > '*****************************
Hi Telle,
Just to add a bit to what Al and Henrk said...
Here is an approach that uses the XOR logic operator (^ on the Stamp)
to detect the transition. bit0 is used as an internal "state
variable" to store the prior state of pin0. The program loop runs
once every 100 milliseconds (98 ms pause plus about 2 milliseconds
for the program code). There is no IF-THEN logic in this approach.
pins=00011000
'76543210
dirs=11111110
check0:
bit0=bit0^pin0&pin0 ' bit0 is high only on 0->1 edge of pin0
pin4=bit0^1 ' make pin4 low at the transition
' note that ^1 is the NOT function on the BS1
bit0=pin0 ' update the prior state
pause 98 ' hold it
goto check0 ' do it again in 100ms cycle
Here is a variation that uses the pulsout command to get a more
precise 100 milllisecond output pulse, and the check0 loop runs
faster. (Caveat--I think the BS1 does okay with zero as a pulsout
time argument.)
pins=00011000
'76543210
dirs=11111110
x var word ' for pulsout
check0:
bit0=bit0^pin0&pin0 ' bit0 is high only on 0->1 edge of pin0
x=bit0*10000 ' either 0 or 10000*10 microseconds
bit0=pin0 ' update the prior state
pulsout 4,x ' invert pin4 for either 0.0 or 0.1 second
goto check0 ' do it again
Tracy Allen
electronically monitored ecosystems
http://www.emesystems.com
open with toothpicks. Another stab at it...
BS1 program (as state machine) to make output pin4 low for 100
milliseconds when input pin0 see the 0->1 transition:
pins=00011000
'76543210
dirs=11111110
' bit0 will be used as prior-state variable
check0:
pin4=bit0^pin0&pin0^1 ' pin4 is low only on 0->1 edge of pin0
' note that ^1 is the NOT function on the BS1
bit0=pin0 ' update the prior state
pause 98 ' hold it
goto check0 ' do it again in 100ms cycle
Variation, using PULSOUT command:
pins=00011000
'76543210
dirs=11111110
' bit0 and bit1 will be used as state variables
' w1 will be used for timer
check0:
bit1=bit0^pin0&pin0 ' bit1 is high only on 0->1 edge of pin0
w1=bit1*10000 ' either 0 or 10000*10 microseconds
bit0=pin0 ' update the prior state
pulsout 4,w1 ' invert pin4 for either 0.0 or 0.1 second
goto check0 ' do it again
-- Tracy Allen
electronically monitored ecosystems
http://www.emesystems.com
> > > I have a very simple application for a BS1. I have a signal
> > > coming from an
> > > inverter that goes HIGH for 20 seconds, then goes LOW again. I
> > > want to take
> > > this signal in on pin0 and change the output of pin4 to LOW for
>100ms. My
> > > program is as follows:
> > > '*****************************
> > > pins = 00011000
> > > dirs = 11111110
> > >
> > > CHECK0: if pin1 = 0 then GOLOW
> > > goto CHECK0
> > >
> > > GOLOW: pin4 = 0
> > > pause 100
> > > pin4 = 1
> > > goto CHECK0
> > > '*****************************
>
>Hi Telle,
>
>Just to add a bit to what Al and Henrk said...
>
>Here is an approach that uses the XOR logic operator (^ on the Stamp)
>to detect the transition. bit0 is used as an internal "state
>variable" to store the prior state of pin0. The program loop runs
>once every 100 milliseconds (98 ms pause plus about 2 milliseconds
>for the program code). There is no IF-THEN logic in this approach.
>
> pins=00011000
> '76543210
> dirs=11111110
>
> check0:
> bit0=bit0^pin0&pin0 ' bit0 is high only on 0->1 edge of pin0
> pin4=bit0^1 ' make pin4 low at the transition
> ' note that ^1 is the NOT function on the BS1
> bit0=pin0 ' update the prior state
> pause 98 ' hold it
> goto check0 ' do it again in 100ms cycle
>
>
>Here is a variation that uses the pulsout command to get a more
>precise 100 milllisecond output pulse, and the check0 loop runs
>faster. (Caveat--I think the BS1 does okay with zero as a pulsout
>time argument.)
>
> pins=00011000
> '76543210
> dirs=11111110
> x var word ' for pulsout
>
> check0:
> bit0=bit0^pin0&pin0 ' bit0 is high only on 0->1 edge of pin0
> x=bit0*10000 ' either 0 or 10000*10 microseconds
> bit0=pin0 ' update the prior state
> pulsout 4,x ' invert pin4 for either 0.0 or 0.1 second
> goto check0 ' do it again
>
> -- Tracy