Help! My program doesn't work as expected.
Chuck E.
Posts: 14
Attached is the code. I have 10 relays that connect a sensor array to an amplifier, the output of which is connected to an ADC.
I have commented out the save routine until I can get this part working. The way it's SUPPOSED to work is to energized each relay in turn, convert the result and load it into a slot on the RTC RAM. It should do each relay in turn, wait a minute, then start over. On the Debug window it only writes this:
RTC RAM cleared
0
Then adds "getting signal" to the line after the "0". This repeats every 2 seconds instead of incrementing through the relays.
So, all you software gurus, what did I do wrong?
After this is working I will add the data save routine that will read the data from RTC RAM and load it into a data logger.
Thanks,
Chuck
I have commented out the save routine until I can get this part working. The way it's SUPPOSED to work is to energized each relay in turn, convert the result and load it into a slot on the RTC RAM. It should do each relay in turn, wait a minute, then start over. On the Debug window it only writes this:
RTC RAM cleared
0
Then adds "getting signal" to the line after the "0". This repeats every 2 seconds instead of incrementing through the relays.
So, all you software gurus, what did I do wrong?
After this is working I will add the data save routine that will read the data from RTC RAM and load it into a data logger.
Thanks,
Chuck
txt
5K
Comments
What you're showing is a classic symptom of "brown-out reset" -- meaning your power supply doesn't have sufficient current capacity to power both the BS2 and the relay at the same time (relays are a bit power hungry). As a result, the voltage from your power supply 'drops', the BS2 detects this and resets itself. This turns off the relay, the BS2 comes back up, tries to run the program again, and voila -- another brown-out reset.
Chuck
Chuck
So, if the power supply is up to the task, and the program seems to make sense (which it does ), then its back to a straight electrical probelm. Have you got diodes around each relay coil to handle the back EMF when the relays shut-off? I suspect everything works fine until the first relay shuts off.
You could also test this simply by not providing any power to the relay circuits and running the Stamp through its paces, as reported on your DEBUG screen.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
Disconnecting all the electronics didn't do anything. I also added some debug lines to try and figure out where exactly the problem lies. It just seems to stop executing at the return line from the stabilize subroutine, then the whole thing resets about 2 seconds later and does the same thing. Is there a problem with the RAM address that stores the value for the next instruction maybe? How would I test that. I guess I'll write some test code and see what I can figure out.
Chuck
In your 'main' routine, you're using "GOTO" to go to subroutines, then the subroutines are using a "RETURN". If you "RETURN" from someplace you didn't use "GOSUB" to get to, the BS2 tries to get a 'return' address from the "GOSUB" stack. If there ISN'T a return address there, it resets the processor, as you're seeing.
Convert those "GOTO" to "GOSUB", and it should work much better.
THANKS!
Chuck
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·