Picaxe resetting or stuck in fatal loop


I'm reprogramming Robot Leader, and I'd like to be able to use PWM to pulse his LED eyes. The only problem is, I also have to command a servo to turn his head, and the Picaxe28x1 does not allow you to use PWM while you are using the servo command. They both rely on the same timer.

So I tried turning off the servo whenever I wasn't using it. This seemed like a good idea anyway, as it should reduce some noise and power consumption. The problem is that when I try to turn off the servo by setting the servo pin LOW, my program seems to malfunction.

It passes the syntax check, and the Picaxe simulator runs it without an issue. However, in operation the program never seems to complete the init block and enter the main loop. I don't know if the picaxe is actually constantly resetting itself or what.

Here's the initial code block.


#picaxe 28x1
setfreq m4 ' set frequency to 4MHz

Symbol servopin = 0 ' Defines output pin to which the servo turning the head is connected
Symbol soundpin = 3 ' Defines output pin to which a speaker is connected
symbol pirpin = 1  ' Defines analog input pin for signal pin of the Parallax PIR
symbol led1pin = 7 ' Defines the LED pin for one eye
symbol led2pin = 6 ' Defines the LED pin for one eye

symbol right = 80
symbol shakeright = right + 20
symbol center = 150
symbol left = 220
symbol shakeleft = left - 20

symbol pircount = b0 ' count the number of times the PIR is triggered
symbol pirstate = b1 ' store the pirstate (adc value)
symbol flashcount = b3 ' store the number of times to flash the LEDs
symbol remember = w2  ' Temporary variable just used in routines


sound soundpin,(left,20)
servo servopin,left
pause 1200

sound soundpin,(right,20)
servopos servopin,right
pause 1200

sound soundpin,(center,20)
servopos servopin,center
pause 500
low servopin

pause 60000 'wait 60 seconds for PIR to initialize
high led1pin: high led2pin

pircount = 0 ' initialize pircount
pirstate = 0 ' initialize pirstate
flashcount = 0 ' initialize flashcount



The robot just keeps scanning his head through the three servo positions in the init code block. His LED eyes never go on, so the code is never getting pased the pause 60000 statement. Can anyone figure out what is going on?


I checked the Program Editor, and my Picaxe28x1 is running firmware version A.6. So I guess that confirms Ro-Bot-X's findings that multiple versions of the 28x1 have this bug.

I changed my code to deal with the problem. The pause during the init block is only 10 seconds now, and the LEDs will blink on and off each second when this happens. I also eliminated the head movements during the init block. So whenever the servos are shut off, the reset will result in a 10 second blinky light display. That is acceptable.

am also having the same

am also having the same problem while using 8 servos with picaxe 28X1…all the servos either turn to their maximum positions(even when given  how much to turn) or the picaxe resets…

I am wondering if it is

I am wondering if it is related to the bug reported in this post. I’ll check my firmware version (somehow) tomorrow. The reported servo bug affected firmware version A.4.

Stupid question

Since you have LEDs installed could you use them to help debug the program? For example after each line of code executes you turn a LED on for 1 second.

I’ve noticed the same thing too

I’ve noticed the same thing too. I’m pretty sure that I’ve got this working on 28x1 too at some point (I mean stopping servo by setting the output pin low). I did some tests to find out what’s the problem. I tried 3 different versions of Programming Editor (5.2.7, 5.2.11 and 5.3.1, all had syntax DLL 262144) to see if there’s a ProgEdit related problem (compiler bug perhaps). I ran test code on 28x1 (firmware A.6) and 28x2 (firmware B.1) chips mounted on 28 project board. I used oscilloscope to check states of two output pins when running this code:
high 0
pause 1000
low 0
pause 500

servo 1, 150
pause 1000
low 1
  high 0
  pause 500
  low 0
  pause 500
  goto main

High/low on pin 0 at the beginning is used to trigger oscilloscope. Then servo pulse is started on pin 1 for one second and then turned of by setting the pin low. Lastly main loop toggles pin 0 high and low at 500ms intervals. Oscilloscope’s channel 1 is connected to output pin 0 and channel 2 to pin 1. So the expected output is like this: 1 second pulse on channel 1. Both channels low for 500 ms. Servo pulses for 1 second on channel 2. Channel 2 low and channel 1 toggling at 500ms intervals.

Picaxe 28x1 seemed to do something weird and reset after setting the servo pin (output pin 1) low. 28x2 on the other hand worked just fine. Programming Editor version didn’t make any difference. Here’s some pictures of what I saw on the scope:


28x1: There’s something weird going on. (500ms/div on x axis)


28x1: I think the narrow downward spike on CH1 is when reset happens. (2s/div on x axis)


28x2: Looking good. (500ms/div on x axis)


28x2: Looking very good. It works just as expected. (2s/div on x axis)

So it seems me memory wasn’t correct. This just doesn’t work on 28x1 (at least the ones I have, all with firmware A.6). Channel 1 goes high at the beginning of main like expected (unless this is how ‘the bug works’) but the following pause is screwed up. 28x2 seems to work just fine. Maybe I’ll try this later on 08M too just to see if it works or not.


Your question is not stupid.

Your question is not stupid. I have LEDs and a speaker, and they are very helpful while programming to indicate where in the code you are. Although I didn’t post this part of the code, the main loop includes a case select statement. Depending on how many times the IR motion sensor is triggered, different LED and sound behavior is exibited. So I always know where in the main loop I am.

Also, there is a three tone sound in the init block of code. Since I am hearing that right after the servo stops (I can also hear that the servo buzz stops), I know that the code is back in the init section. This shouldn’t happen unless the Picaxe is reset.