PICAXE outputting PWM at the wrong frequency??

dmaxben

Member
After making do with a cheap chinese multimeter for years, I finally decided to treat myself to a "real" multimeter. So I picked up a nice shiny Fluke 87-V.

I was eager to try out the frequency and duty-cycle readout capabilities of the 87-V so first thing I did when I opened up the box was try it out on a little PICAXE PWM circuit that I have been using/running successfully for a long time.

The simple circuit I have here drives a small 12v PWM solenoid with an ST-Micro P20NF06L MOSFET via a PWM output on a Picaxe 14m2. The circuit works perfectly fine and the solenoid operates normally... The circuit is just running on the bench, off a proper/regulated DC power supply. I have the DC bench power supply set to 12.0 volts (to run the solenoid), and then stepped down with an LM2940t with the proper input/output caps to insure stable 5v operation for the PICAXE itself.

But after putting my new Fluke across the terminals of the solenoid, the duty cycle % reads normally (ramps up from 0% to 98% steady-state)...but when I set the multimeter to read frequency, it shows that the frequency of my PWM circuit is running at ~400hz. My code/program, as written, says it should be running the PWM at 100hz...

Using the PWM Wizard, this is what I came up with.

Code:
main:
pause 25
pwmout pwmdiv64, B.2, 155, 612
goto main
The above code 'should' result in 98% duty cycle at 100hz...but my multimeter shows the thing running at 400hz.

I am doing some "multi-tasking" on this program...I have the 14m2 doing the solenoid PWM while simualtaniously monitoring some button presses and 2 ADC inputs. This might be a stupid question that I completely missed when reading the details about how exactly the "multiple tasks" feature works on the M2 chips...but perhaps does the chip run faster when "multi-tasking", thus altering the PWM-out frequency? Or am I being a bonehead and simply not using my fancy new multimeter correctly? :confused:

I tried searching on the forum, but couldnt really find anything...

thanks
Ben
 

papaof2

Senior Member
You need to look at the voltage across the solenoid with a scope - there could very well be spikes produced when the PWM pulse turns off and the frequency meter is counting the spikes as well as the PWM pulses.
 

inglewoodpete

Senior Member
The above code 'should' result in 98% duty cycle at 100hz...but my multimeter shows the thing running at 400hz.

I am doing some "multi-tasking" on this program...I have the 14m2 doing the solenoid PWM while simualtaniously monitoring some button presses and 2 ADC inputs. This might be a stupid question that I completely missed when reading the details about how exactly the "multiple tasks" feature works on the M2 chips...but perhaps does the chip run faster when "multi-tasking", thus altering the PWM-out frequency? Or am I being a bonehead and simply not using my fancy new multimeter correctly?
I think you're spot on the money. When the M2s do their multitasking, their default speed is automatically increased to 16MHz. Um, that's 4 times the default speed! Did someone say 4 times?
 

Technical

Technical Support
Staff member
Please take a read of the 'parallel tasks' section in part 1 of the PICAXE manual, this explains about this 16MHz speed and effect on pwm
 
Top