Stemp acting eraticaly after several hours of operation
LuXo12
Posts: 31
Hi everyone
I am new to basic stamp so please be gentle.
Here is a description of what I am trying to do
I am currently working on a project where my basic tamp has to detect a status of another device (status of that device is determined by that device's led being on or off)
and based on the status the basic stamp should perform two functions.
The high signal is supplied to pin 0 by a relay (i used relay instead of a dip switch) that is controlled by a photo-resistor that is hooked up to the led it is monitoring.
The device my basic stamp is to monitor would be powered for close to 12hrs in day and off for another 12 hrs therefore the signal on pin 0 would be either high for 12 hrs or low for 12 hrs.
My program seems to be working fine for about first 2 hr after that it seems to be "restarting" and detects a low at pin 0 even though pin 0 is reeving high signal, only does that for about a minute as minute later (pin 0 detects high when pin 0 is receiving high)
This application has to be running 24/7 so my question is: Is it OK for pin 0 to be receiving a high impulse for about 12 hrs non-stop and then low for another 12 hrs?
OR
Is it does my code contain some sort of a syntax error that causes this behavior?
Here is my code
CounterOn VAR Bit 'To indicate status of Led 1= led On | 0 Led = Off
CounterOnOff VAR Bit 'This variable is used to display status Off - ONLY AFTER DEVICE HAS BEEN TURNED ON BEFORE
CounterXOn VAR Nib 'This variable is used to prevent program from constantly performing function when device is ON
I forgot to mention that once the status changes program is to perform the function only once!
CounterXOff VAR Nib 'This variable is used to prevent program from constantly performing function when device is OFF
I forgot to mention that once the status changes program is to perform the function only once!
DO
IF CounterXOn=13 THEN 'Puts the variable CounterXON at 2 so it never goes above the max NIB value
CounterXOn=2
ELSE
ENDIF
IF CounterXOff=13 THEN 'Puts the variable CounterXON at 2 so it never goes above the max NIB value
CounterXOff=2
ELSE
ENDIF
IF (IN0=1)THEN 'Detects status of device (in this case device is ON)
CounterOn =1 'Sets a value in a variable ConterOn (this variable is used later in the code)
CounterXOn = CounterXOn +1 'This counter will be used to control the number of times the functions that would be performed
CounterOnOff=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
CounterXOff=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
ELSE
ENDIF
IF (IN0=0) AND CounterOn=1 THEN 'IF Pin0 is at low and CounterON variable holds 1 then it means device was turned ON
CounterOnOff =1 'and CounterOnOff is set to 1 so it can be used later on in a program
CounterXOff = counterXOff +1 'This counter will be used to control the number of times the functions that would be performed
CounterOn=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
CounterXOn=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
ELSE
ENDIF
'This is where the magic takes place
IF CounterOn=1 AND CounterXOn=1 THEN 'IF pin0 is at high and CounterXOn is also equal to 1 (meaning this is the first and only time the following function
DEBUG "Status ON", CR 'would be perforemed)
GOSUB GetTemp_Subroutine 'Performs subroutine
GOSUB Read2Go_Subroutine 'Performs subroutine
Counterxon = CounterXOn +1 'Modifies CounterXOn value so this function will be only performed once.
ELSE
ENDIF
IF CounterOnOff=1 AND CounterXOff=1 THEN 'Because Pin0 is now at low and it was at high before it can now perform the following subroutines.
DEBUG "Status OFF", CR 'Sends a debug message to pc
GOSUB GetTemp_Subroutine 'Performs subroutine
GOSUB Six_Subroutine 'Performs subroutine
GOSUB Read2Go_Subroutine 'Performs subroutine
CounterXOff = CounterXOff+1 'Modifies CounterXOff value so this function will be only performed once.
ENDIF
PAUSE 75
LOOP
All subroutines perform same functions that is they control other relays.
One_Subroutine:
HIGH 15
PAUSE 100
LOW 15
PAUSE 100
RETURN
Three_Subroutine:
HIGH 8
PAUSE 100
LOW 8
PAUSE 100
RETURN
Five_Subroutine:
HIGH 10
PAUSE 100
LOW 10
PAUSE 100
RETURN
Six_Subroutine:
HIGH 11
PAUSE 100
LOW 11
PAUSE 100
RETURN
Seven_Subroutine:
HIGH 12
PAUSE 100
LOW 12
PAUSE 100
RETURN
Nine_Subroutine:
HIGH 14
PAUSE 100
LOW 14
PAUSE 100
RETURN
SR_Subroutine:
HIGH 14
PAUSE 100
LOW 14
PAUSE 100
RETURN
BegCall_Subroutine:
GOSUB Nine_Subroutine
GOSUB One_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
RETURN
GetTemp_Subroutine:
GOSUB Nine_Subroutine
GOSUB One_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
RETURN
Read2go_subroutine:
GOSUB One_Subroutine
GOSUB Five_Subroutine
GOSUB Five_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Seven_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
RETURN
CallAll_Subroutine:
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
RETURN
I am new to basic stamp so please be gentle.
Here is a description of what I am trying to do
I am currently working on a project where my basic tamp has to detect a status of another device (status of that device is determined by that device's led being on or off)
and based on the status the basic stamp should perform two functions.
The high signal is supplied to pin 0 by a relay (i used relay instead of a dip switch) that is controlled by a photo-resistor that is hooked up to the led it is monitoring.
The device my basic stamp is to monitor would be powered for close to 12hrs in day and off for another 12 hrs therefore the signal on pin 0 would be either high for 12 hrs or low for 12 hrs.
My program seems to be working fine for about first 2 hr after that it seems to be "restarting" and detects a low at pin 0 even though pin 0 is reeving high signal, only does that for about a minute as minute later (pin 0 detects high when pin 0 is receiving high)
This application has to be running 24/7 so my question is: Is it OK for pin 0 to be receiving a high impulse for about 12 hrs non-stop and then low for another 12 hrs?
OR
Is it does my code contain some sort of a syntax error that causes this behavior?
Here is my code
CounterOn VAR Bit 'To indicate status of Led 1= led On | 0 Led = Off
CounterOnOff VAR Bit 'This variable is used to display status Off - ONLY AFTER DEVICE HAS BEEN TURNED ON BEFORE
CounterXOn VAR Nib 'This variable is used to prevent program from constantly performing function when device is ON
I forgot to mention that once the status changes program is to perform the function only once!
CounterXOff VAR Nib 'This variable is used to prevent program from constantly performing function when device is OFF
I forgot to mention that once the status changes program is to perform the function only once!
DO
IF CounterXOn=13 THEN 'Puts the variable CounterXON at 2 so it never goes above the max NIB value
CounterXOn=2
ELSE
ENDIF
IF CounterXOff=13 THEN 'Puts the variable CounterXON at 2 so it never goes above the max NIB value
CounterXOff=2
ELSE
ENDIF
IF (IN0=1)THEN 'Detects status of device (in this case device is ON)
CounterOn =1 'Sets a value in a variable ConterOn (this variable is used later in the code)
CounterXOn = CounterXOn +1 'This counter will be used to control the number of times the functions that would be performed
CounterOnOff=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
CounterXOff=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
ELSE
ENDIF
IF (IN0=0) AND CounterOn=1 THEN 'IF Pin0 is at low and CounterON variable holds 1 then it means device was turned ON
CounterOnOff =1 'and CounterOnOff is set to 1 so it can be used later on in a program
CounterXOff = counterXOff +1 'This counter will be used to control the number of times the functions that would be performed
CounterOn=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
CounterXOn=0 'Resets value of CounterOnOff to 0 (so later function won't be perfomred)
ELSE
ENDIF
'This is where the magic takes place
IF CounterOn=1 AND CounterXOn=1 THEN 'IF pin0 is at high and CounterXOn is also equal to 1 (meaning this is the first and only time the following function
DEBUG "Status ON", CR 'would be perforemed)
GOSUB GetTemp_Subroutine 'Performs subroutine
GOSUB Read2Go_Subroutine 'Performs subroutine
Counterxon = CounterXOn +1 'Modifies CounterXOn value so this function will be only performed once.
ELSE
ENDIF
IF CounterOnOff=1 AND CounterXOff=1 THEN 'Because Pin0 is now at low and it was at high before it can now perform the following subroutines.
DEBUG "Status OFF", CR 'Sends a debug message to pc
GOSUB GetTemp_Subroutine 'Performs subroutine
GOSUB Six_Subroutine 'Performs subroutine
GOSUB Read2Go_Subroutine 'Performs subroutine
CounterXOff = CounterXOff+1 'Modifies CounterXOff value so this function will be only performed once.
ENDIF
PAUSE 75
LOOP
All subroutines perform same functions that is they control other relays.
One_Subroutine:
HIGH 15
PAUSE 100
LOW 15
PAUSE 100
RETURN
Three_Subroutine:
HIGH 8
PAUSE 100
LOW 8
PAUSE 100
RETURN
Five_Subroutine:
HIGH 10
PAUSE 100
LOW 10
PAUSE 100
RETURN
Six_Subroutine:
HIGH 11
PAUSE 100
LOW 11
PAUSE 100
RETURN
Seven_Subroutine:
HIGH 12
PAUSE 100
LOW 12
PAUSE 100
RETURN
Nine_Subroutine:
HIGH 14
PAUSE 100
LOW 14
PAUSE 100
RETURN
SR_Subroutine:
HIGH 14
PAUSE 100
LOW 14
PAUSE 100
RETURN
BegCall_Subroutine:
GOSUB Nine_Subroutine
GOSUB One_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
RETURN
GetTemp_Subroutine:
GOSUB Nine_Subroutine
GOSUB One_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
RETURN
Read2go_subroutine:
GOSUB One_Subroutine
GOSUB Five_Subroutine
GOSUB Five_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Six_Subroutine
GOSUB Five_Subroutine
GOSUB Seven_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
RETURN
CallAll_Subroutine:
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
GOSUB BegCall_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Six_Subroutine
GOSUB Three_Subroutine
PAUSE 30000
GOSUB Nine_Subroutine
GOSUB Nine_Subroutine
RETURN
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Another thing you could do to trim your code:
whichLED var byte
whichLed = *whichever LED you want to light"
led_sub:
high whichLED
pause 100
low whichLED
pause 100
return
There are some other ways you could trim your program as well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
As for the relay that is being used in place of a dip switch (monitoring status of led) i need it as the led that is being monitored is in a remote location several yards away and there is no way for me to move either device closer
The power supply I am using to power the stamp has the output of 5.0 volts and 1.98 Amps
The voltage on the input Pin0 is 5.0 volts and 0.01 Amp
Is it possible that the stamp gets too hot and that's why it acts that way?
Is it possible that the supply has two many amps?
Thanks in advance.
It's possible the Stamp can get too hot.· If devices are connected to the I/O pins that draw a lot of current, the processor chip can get warmer.· Usually, the processor chip will be damaged before it gets significantly hot from this.· The maximum current per I/O pin is roughly 20mA.· Groups of 8 I/O pins can provide roughly 50mA and the whole processor chip can handle about 150mA.· The processor chip will normally get warm as well.
There's a voltage regulator on the Stamp module that gets warm when it's used.· If you're supplying 5V to the Stamp to the Vdd pin, the regulator is bypassed.· If you're trying to power the Stamp with 5V to the Vin pin, it won't work because 5V is too low for the regulator on the module.· Vin needs to be at least 6V.
·
Based on Mike's reply I assume that the power supply is OK
Could it be that there is a logic error in my code, especially in the loop portion of it?
Thanks in advance
2. It's not clear what the relay is doing for you. If it's merely closing a switch, you may need a 'pull-up' resistor of 10 Kohms to give you a reliable 'one' when the switch is open.
I have had the same type of problem with using relay that draw over 30 mill amps @ 12 volts
·What·I had to do is use a Optic Sensor· like a 4N25 and a··
transistor like a·2N2222A or you could use a UNL2803 as well
If you need any help in how use this set up just let me know
These set ups work great and do not give any trouble
Here is a link where·I post a code routine that check to see if you are hang up
because of the set up using a relay
http://forums.parallax.com/showthread.php?p=748879
I hope that you find it use full· it has worked for me
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 9/6/2008 2:05:16 AM GMT