20M2 using multitask how generate a variable accurate frequency

jyb

Senior Member
hi every body

i use a 20M2 for control and drive a little cnc mill in a board of my own conception
the picaxe have
one task for survey 6 end of run switches (for 3 axis) plus a lot of general usage switches(total = 32), on other part, picaxe have to drive 32 leds for indications to operator , and a potentiometer to control motors 's speed
the second task , is very short and just generate a frequency output which follows the potentiometer's value
what i need is to get , like the pwm familly commands (which vary the duty,not frequency by (h)pwmduty),a program loop pulse generator wich works in background, as it will not be interrupted by tasks switching

i will take all ideas
here the program (sorry: french comments)
View attachment FRAISEUSE led , switches ,encodeur20M2 V02 ed09.bas
 

jyb

Senior Member
oops
i forget some things as i use a leadshine driver md 882 coupled with its power supply leadshine 68v/300w
 

womai

Senior Member
Would maybe the servo command do what you are looking for?

The multitasking on the new Picaxes is NOT running on a very strict schedule, so generating a clean, constant frequency output would be rather tricky.
 
Last edited:

jyb

Senior Member
Would maybe the servo command to what you are looking for?

The multitasking on the new Picaxes are NOT running on a very strict schedule, so generating a clean, constant frequency output would be rather tricky.
you are right, it's fot that i am looking for the use of a timer running on background which only satisfy my need
 

womai

Senior Member
What is the frequency and the range of duty cycles you need? How much variation can you tolerate?
 

jyb

Senior Member
i have to send to the controller a signal which is a pulse of min 2.5 µs at a variable frequency of 10 hz to 10 khz
duty cycle is not important but linearity to avoid shocks and step lost
each pulse make stepper motor progress of one step
leadshine controller can drive the stepper from 400pulses per revolution(which give high speed and low accuracy positionning) to 10000 pulses per revolution which give very slow speed but very high accuracy positionning
 

womai

Senior Member
That would be pretty easy to achieve with a "normal" PIC - set up a timer interrupt at the appropriate frequency and each time the interrupt routine gets called it would generate a 2.5us pulse.

But with a Picaxe I'm afraid this is not trivial - the fastest time interrupt it can do is around 1 kHz. Maybe you can use a timer interrupt for slower speeds and PWM for faster speeds.
 
Top