08M2 Programming Conundrum

TinkerJim

Member
I encountered a very perplexing 08M2 programming problem. To put it in simple isolated form consider this program:

Main:
High C.1
Pause 2000
Low C.1

High C.2
Pause 2000
Low C.2

High C.4
Pause 2000
Low C.4

For troubleshooting the problem, the ports are each connected to a red LED through a 1K resistor to ground.

It works fine. The Led at C.1 goes on for 2 secs, then C.2 , and then C.4.

But if I interchange the last two 3-line blocks of the program, expecting first C.1 to light, then C.4 and then C.2 - it doesn't work that way ! Instead, C.1 goes on, then C.4, but C.2 doesn't turn on next. In fact C.2 never goes on. The setup just keeps toggling between C.1 and C.4 - as if the last 3 lines were not there and a "goto Main" was at the end.

The circuit is running on batteries which now measure about 4V. I am using Prog.Ed v 5.5.4, and tried 3 different new 08M2 chips (from same batch).

Can anyone please help?
 

Rick100

Senior Member
Does each LED have it's own resistor or do all 3 LEDs share the same resistor ? Also , could you post your code to show exactly where the GOTO MAIN line is . You can also use the scroll bar on the bottom of the editor screen to make sure you don't have any code off the visible portion of the screen .
 
Last edited:

russbow

Senior Member
Have tried this on a breadboard with an 08m2. Added #picaxe directive and goto main

Code:
#picaxe08m2

Main:
High C.1
Pause 2000
Low C.1

High C.4
Pause 2000
Low C.4

High C.2
Pause 2000
Low C.2



goto main
works fine in any order 1,2,4 / 1,4,2 / 2,1,4 et sec
 

TinkerJim

Member
Does each LED have it's own resistor or do all 3 LEDs share the same resistor ? Also , could you post your code to show exactly where the GOTO MAIN line is . You can also use the scroll bar on the bottom of the editor screen to make sure you don't have any code off the visible portion of the screen .
The LEDs share the resistor. All three LEDs have their cathodes tied and the resistor is connected to that node and then to ground.

There is no "Goto Main". The execution should end, but goes on as if there was a goto main (in both versions BTW). In the Simulator, both versions terminate after one run through the steps.

There is no code (visible) off the screen, and I even wrote a new identical program from scratch to make sure nothing else was in it !
 

nick12ab

Senior Member
Yes, the standard .01 across legs 1 and 8.
0.01 what?

Do you also have a bulk capacitor with that? 100uF should be enough. Battery connections are not always 100% reliable.

What is the value of the resistor you're using with the LEDs?
 

hippy

Ex-Staff (retired)
If you do 1 - 2 - 4 it works but restarts and repeats.

If you do 1 - 4 - 2 it works until 4 then restarts and repeats.

That suggests something about pin 4 on your hardware is causing the PICAXE to reset and restart.

Add some SERTXD commands so you can trace where the code is getting to in the program, starting with SERTXD("Restarted") at the top of the program.
 

BeanieBots

Moderator
Sounds like your PICAXE is being reset every time C.4 is activated.
Look for shorts to that pin. Maybe to serin?

EDIT:
Pipped to the post by hippy!
 

TinkerJim

Member
Sounds like your PICAXE is being reset every time C.4 is activated.
Look for shorts to that pin. Maybe to serin?

Yes, I found a short (about 10 ohms) in the solderless breadboard between where serin and C.4 were plugged in.

New breadboard setup is working fine.

Thanks so much !!!
 

TinkerJim

Member
If you do 1 - 2 - 4 it works but restarts and repeats.

If you do 1 - 4 - 2 it works until 4 then restarts and repeats.

That suggests something about pin 4 on your hardware is causing the PICAXE to reset and restart.

Add some SERTXD commands so you can trace where the code is getting to in the program, starting with SERTXD("Restarted") at the top of the program.
Good logic ! Yes, it must be resetting, and of course it is not noticed when programmed in the 1-2-4 sequence.

I duplicated the setup on another breadboard and it works fine. All the chips work fine, even those originally programmed on the original board.

I have to check the faulty breadboard now.

Thanks so much !!!
 

srnet

Senior Member
One of the tests I do on a new layout or PCB is to check for continuity between pins.

Put one probe of the continuity tester on pin 1, then test on pins 2,3,4,5,6,7,8. Move the probe to pin 2, then test on pins 3,4,5,6,7,8 etc.

Takes a minute or so on an 8 pin.
 
Top