I have an 08M2 picaxe that is acting quite strangely and I’m starting to think it’s a problem with the picaxe and not me. I know the odds are against me but ...
The attached is a slight variant of a program that I’m currently using to monitor a water meter fitted with a reed switch that opens after every ½ a litre of flow. The version currently operating suffers from the occasional random reset every few days (which I can live with) but the attached one should reset within 8 minutes. The difference between the two versions is line 181 (nap 2) has been commented out and the HC-12 sleep test in the SleepMod subroutine has been altered so that the program can run on an 08M2 that isn’t connected to an HC-12 transceiver - so you can check it out.
The program simple transmits some numbers (incremental pulse counter and battery voltages) every time the reed switch in the meter opens. It also periodically checks that the 2 * 25 mA solar panels aren’t overcharging the battery and if the battery voltage is high, it doesn’t put the HC-12 to sleep.
The program worked fine while I was simulating water meter reed switch pulses for high flow rates through the meter using a relay and another 08m2 but when I was checking for periods of no water use, the program kept continually resetting while the relay was open but not when it was closed. And the resetting was occurring at regular precise times (about every 14 minutes). I initially suspected it was something to do with my periodic battery overvoltage checking although I wondered how that could ever get the program to reset.
Anyway, I played around with a number of things trying to isolate the problem and changed a few things and added sertxd statements at various points in the program. Making these changes sometimes made the problem disappear and other times changed the resetting period. For example, changing the nap period in the section of code where its looping around step 9, from “nap 3” to “nap 2” halved the reset period down to a regular 7 minutes while changing it to “nap 1” made a problem disappear as did substituting 2 lots of “nap 2” (which is the version I’m currently using). Also adding a sertxd as it entered the bit of code that checks for battery over-voltage in step 9 stopped the resets.
I don’t think its hardware related as I’ve tried it on a couple of 08M2’s with different power supplies and the behaviour is the same. I had a similar problem way back in early 2007 soon after I first used an 08m2. Then it involved the use of the sleep command which caused the 08m2 to restart at fixed intervals – just like this present case. I wrote to the forum about it and you fixed it. I can’t refer to that thread as they don’t go back that far. I just wondered if the” nap” command had anything to do with it. Certainly, changing it to “pause” appeared to stop the restarts but as I say, other program changes that I would have thought should have no effect on the restarts also stopped it. I’d prefer to use “nap” in order to minimize power use as in winter, solar input could be quite low.
I’m using PE5 (version 5.5.5) as I’ve not got around to upgrading to PE6. I realize that you regard PE5 as obsolete but hopefully you’ll still consider this problem.
Actually, it looks like I can't include the code here as it make the submission too big so I'll send it in the next post.
The attached is a slight variant of a program that I’m currently using to monitor a water meter fitted with a reed switch that opens after every ½ a litre of flow. The version currently operating suffers from the occasional random reset every few days (which I can live with) but the attached one should reset within 8 minutes. The difference between the two versions is line 181 (nap 2) has been commented out and the HC-12 sleep test in the SleepMod subroutine has been altered so that the program can run on an 08M2 that isn’t connected to an HC-12 transceiver - so you can check it out.
The program simple transmits some numbers (incremental pulse counter and battery voltages) every time the reed switch in the meter opens. It also periodically checks that the 2 * 25 mA solar panels aren’t overcharging the battery and if the battery voltage is high, it doesn’t put the HC-12 to sleep.
The program worked fine while I was simulating water meter reed switch pulses for high flow rates through the meter using a relay and another 08m2 but when I was checking for periods of no water use, the program kept continually resetting while the relay was open but not when it was closed. And the resetting was occurring at regular precise times (about every 14 minutes). I initially suspected it was something to do with my periodic battery overvoltage checking although I wondered how that could ever get the program to reset.
Anyway, I played around with a number of things trying to isolate the problem and changed a few things and added sertxd statements at various points in the program. Making these changes sometimes made the problem disappear and other times changed the resetting period. For example, changing the nap period in the section of code where its looping around step 9, from “nap 3” to “nap 2” halved the reset period down to a regular 7 minutes while changing it to “nap 1” made a problem disappear as did substituting 2 lots of “nap 2” (which is the version I’m currently using). Also adding a sertxd as it entered the bit of code that checks for battery over-voltage in step 9 stopped the resets.
I don’t think its hardware related as I’ve tried it on a couple of 08M2’s with different power supplies and the behaviour is the same. I had a similar problem way back in early 2007 soon after I first used an 08m2. Then it involved the use of the sleep command which caused the 08m2 to restart at fixed intervals – just like this present case. I wrote to the forum about it and you fixed it. I can’t refer to that thread as they don’t go back that far. I just wondered if the” nap” command had anything to do with it. Certainly, changing it to “pause” appeared to stop the restarts but as I say, other program changes that I would have thought should have no effect on the restarts also stopped it. I’d prefer to use “nap” in order to minimize power use as in winter, solar input could be quite low.
I’m using PE5 (version 5.5.5) as I’ve not got around to upgrading to PE6. I realize that you regard PE5 as obsolete but hopefully you’ll still consider this problem.
Actually, it looks like I can't include the code here as it make the submission too big so I'll send it in the next post.