Pulsing an output under hardware timer control

pjrebordao

Senior Member
Using a 28X1, is there a way to set an output pin pulsing in the background, without having to go through an :interrupt service routine ? Maybe by directly setting some hardware registers ?

I need pulses every 1ms - 1.5ms
 

hippy

Ex-Staff (retired)
You could use PWMOUT. That normally only works down to around 4kHz but by poking prescaler SFR's people have had it running slower so around 1kHz should be achievable.

Have a search on the PICAXE forum for previous discussion ( as PWM is less than four letters, use PWM* as a search term ).

An alternative is to use another smaller PICAXE ( 08 perhaps ) and use that to generate the pulsing, enabled and disabled by the 28X1, and you may even be able to make it programmable by the28X1 to set a specific pulsing rate.
 

pjrebordao

Senior Member
I'll have a look at the SFR possibilities. The 08M doesn't seem an option if I understand you , as I need more accuracy. I'm using a 20Mhz ressonator with the 28X1.
 

hippy

Ex-Staff (retired)
The 08 is entirely capable of generating a pulse every 1ms to 1.5ms. Are there additional requirements which you have not stated ?
 

pjrebordao

Senior Member
Frequency: 1-1.5 Khz
Duration: approx 50% duty cycle
Accuracy / Stability: The one you can get from a quartz oscillator (1% ?)
 

pjrebordao

Senior Member
Haven't tried yet, just looked at code...
But how does the 5 (as in poke $12, 5) translates into 4 (as in freq/4) ?
 

hippy

Ex-Staff (retired)
Frequency: 1-1.5 Khz
That's a pulse rate of 6.66ms to 1ms, not the earlier 1ms to 1.5ms.

Are you saying you want to vary the pulse rate frequency between 1kHz and 1.5kHz ( by what amount of stepping ) or just want to produce a single rate between those frequencies ?

Accuracy / Stability: The one you can get from a quartz oscillator (1% ?)
About 0.003% with a 30ppm accurate crystal. Do you really need that accuracy or is 1% acceptable ?
 

pjrebordao

Senior Member
The purpose of this frequency is to "drive" a stepper driver IC for a turntable that I'm building / upgrading. As such, accuracy (as from a crystal) is paramount, or else I'll get some warbly tunes...

Anyway, I'm now confident that by changing the transmission ratio to the platter and changing the clock for the picaxe, I can get pwmout (by poking $12) achieve the rates I need. I'll need two different ones, for 33rpm and 45rpm records.
 

BeanieBots

Moderator
The 'rumble' you will get from using a stepper motor will be orders of magnitude more noticeable than any "wow & flutter" you'll get from frequency drift even using a homemade RC oscillator!
 

pjrebordao

Senior Member
Actually no. The stepper is driven by microstepping thus "approximating" a sinewave and greatly reducing vibrations.
I'm just getting some small w&f because the belt tension isn't right. I forgot to add the means to adjust it !
 
Top