PWM & GoSub Delay

Lord Grezington

New Member
Hi All

A few questions.

When is the 14M2 Launched?

I Need to charge stepper motor coils very quickly, the problem i have is the shortest wait is only 1ms. Is there a way this is possible using the 08M?

I have noticed a very short time delay when a GoSub procedure is called (I cant measure it as i have no scope), does this delay exist?

Thanks
Graham
 

Jamster

Senior Member
I have noticed a very short time delay when a GoSub procedure is called (I cant measure it as i have no scope), does this delay exist?
Graham
I would expect the PICAXE has to look through your code to find the subroutine each time it is called, meaning a short delay whilst it is located.

Technical will be able to give you a definate answer.
 

Lord Grezington

New Member
I have found the PulseOut command which I cant find in the manuals, this looks interesting. this means i can pulse a 10us (micro second?) pulse out of one pin, use a spare output pin (either left loose or connected to ground through a resistor) as my wait time. Varying the different times, should technically give be a very crude low frequency PWM. I have not done the maths yet. Does anyone know of any reason that this should'nt work?

I have blown all my FETS so i cat test until the next few come in.

Graham
 
Last edited:

lbenson

Senior Member
You can pulse a 10us (micro second?) pulse, but the picaxe will still take something on the order of 250 microseconds to execute the command--half that at 8mHz.
 

MartinM57

Moderator
Unfortunately not, as it is variable depending on:
- the type of PICAXE
- the speed of the PICAXE
- the position of the command in the code
- the parameters that might be associated with the command

Many have asked before, many have measured before and there are many posts about it on the forum.

Have a search and a good read...maybe via Google with "execution time site: picaxeforum.co.uk" and look at the first set of results returned
 

Lord Grezington

New Member
This may still work

I need scope to do some callibration to get the exact timing right, i have upped the frequency to 8Mhz, I have done a few quick experements. Using the Pulse out command, varying the time, i can obtain a range of potential difference from the pin from near 0V right up to near 5V.

as long as the execution time is consistant (which i will need a scope for, i will need to invest in one at some point). i should be able to both obtain a shorter pulse than 1ms as well manipulate the voltage going into the motor phase.

Any thoughts are welcome

Graham
 

vttom

Senior Member
Have you considered using one of the pwm commands? Those run in the background and have very good regularity and granularity.
 

lbenson

Senior Member
I'm not sure exactly what is required, but for instance, the code "high 1: low 1" will take about 500 microseconds to execute at 4mHz on an 08M, and will produce a pulse of about 250 microseconds. You would need a scope to measure it accurately. As suggested, depending on your needs, PWM might provide what you want.
 

westaust55

Moderator
This may still work

I need scope to do some callibration to get the exact timing right, i have upped the frequency to 8Mhz, I have done a few quick experements. Using the Pulse out command, varying the time, i can obtain a range of potential difference from the pin from near 0V right up to near 5V.

as long as the execution time is consistant (which i will need a scope for, i will need to invest in one at some point). i should be able to both obtain a shorter pulse than 1ms as well manipulate the voltage going into the motor phase.

Any thoughts are welcome

Graham
A schematic, existing program code and a functional description details what and why you are trying to achieve then folks can provide specific assistance.

In the meantime you mention creating a PWM type pulse. As Vttom has mentioned, are the inbuilt PWM functions useful to you?
See PWM, PWMOUT and the PWMDUTY (only for some latest chips) commands
 

Lord Grezington

New Member
The problem i am having is that i need 4 PWM channels to drive a bipolar stepper. the space thai have got is small and the PCB needs to be as small as possible. I started off using the 08M but i think i may need to upgrade to the 14M (waiting for 14M2 so that i can use the 4 built in PWM channels on there). i done have the space on the board for the space for the 20X2.

I am trying use the PWM to limit the current going into the motor phases at lower speeds (so i dont blow the fets). Thiss means i can use a stepper wwith a low inductance which means i can get a better performance from at higher speeds (when the full voltage is used).

This is why i assumed the pulse out command will be ok (in a loop incrementing a vartiable until the required time is reached).

I have only had a quick look, but i think the PDF "westaust55" posted looks like it may be helpful.

Graham
 

westaust55

Moderator
The question remains as per my response to your post in another thread, being:
Why do you think you need 4 separate PWM signals to control a single stepper motor?
Please advise the motor specs (current In particular)
 
Last edited:

Lord Grezington

New Member
Hi

I need 1 PWM channel for one motor coil in one direction
another fpr he pwm of hte motor coil in the opposite direction (see bipolar sepper full step sequence).

that will be for one coil, i will need another 2 PWM channels for the second coil.

Now, i have thought about using some NOT gates (inverters). This works and i had the motor running, but this added axtra space on the board which i a trying to get rid of.

I have attached my schematic (I used NOR gates in this and connected the inputs, so acts as an inverter).

Graham
 

Attachments

Lord Grezington

New Member
The program is attached, it may look strange due to the inverter (it doesent quiet follow the standed stepping sequence). also not that i have elliminated the GoSub commands to illiminate execution time. (program will be much shorter when they were used).

the attached PDF is hte motor range, but the exact resistance is around 26 Ohms (its one we use in work as a special), we often fun it over 300 RPM (1KHz). I need the PWM at low speeds because even though the current should only technically pe 0.9A i get spikes (i assume so) and these destroy the FET chip. so at low speeds especially i want to PWM the voltage down to keep the current down (V=IR).

symbol varA = b0
symbol varB = b1
symbol varC = b2
symbol varD = b3
symbol varE = b4
symbol varF = b5
symbol varG = b6
symbol varH = b7


let dirs = %00010111


main:
read 0,varA
label_131:
if pin3 = 1 then label_132 'Decision command
label_231:
if pin3 = 1 then label_131 'Decision command
if varA = 1 then label_236 'Compare command
label_232:
if pin3 = 1 then label_131 'Decision command
if varA = 2 then label_240 'Compare command
label_233:
if pin3 = 1 then label_131 'Decision command
if varA = 3 then label_249 'Compare command
label_258:
if pin3 = 1 then label_131 'Decision command
if varA = 4 then label_260 'Compare command
label_269:
if pin3 = 1 then label_131 'Decision command
if varA = 5 then label_271 'Compare command
label_280:
if pin3 = 1 then label_131 'Decision command
if varA = 6 then label_282 'Compare command
if varA > 6 then label_303 'Compare command
goto label_131

label_303:
let varA = 0 'Expression command
write 0,varA
goto label_131

label_282: high 0
high 1
pause 1 'Wait command
low 0
pause 1 'Wait command
low 1
pause 1 'Wait command
high 0
pause 1 'Wait command
goto label_280

label_271: high 0
high 1
pause 1 'Wait command
low 0
pause 2 'Wait command
low 1
pause 1 'Wait command
high 0
pause 2 'Wait command
goto label_269

label_260: high 0
high 1
pause 2 'Wait command
low 0
pause 2 'Wait command
low 1
pause 2 'Wait command
high 0
pause 2 'Wait command
goto label_258

label_249: high 0
high 1
pause 3 'Wait command
low 0
pause 3 'Wait command
low 1
pause 3 'Wait command
high 0
pause 3 'Wait command
goto label_233

label_240: high 0
high 1
pause 5 'Wait command
low 0
pause 5 'Wait command
low 1
pause 5 'Wait command
high 0
pause 5 'Wait command
goto label_232

label_236: high 0
high 1
pause 10 'Wait command
low 0
pause 10 'Wait command
low 1
pause 10 'Wait command
high 0
pause 10 'Wait command
goto label_231

label_132: pause 100 'Wait command
if pin3 = 1 then label_134 'Decision command
goto label_231

label_134: let varA = varA + 1 'Inc command
write 0,varA
goto label_231
 

Attachments

eclectic

Moderator
I'm FAR from expert, but the graphs on page 2
show a massive drop in torque over 1kHz.


Secondly, try to use the

[ code ]
program
[ /code ]

method to make listings more readable.

3. FET's? Where?

e
 

Lord Grezington

New Member
as you go to high speed, due to the inductance in the motor coils (resistance to current) you dont get all the current into the coils, the pulse length time is too short. so if the current does not get into the coils you loose torque (current is proportional to torque). this is why the steppers will stall at high speeds, there is too little current in the coils to produce enough torque go get over hte detent torque in the motor.

I refer to the Drive chip as the FETS, the chip is a Quad half bridge.
 

eclectic

Moderator
as you go to high speed, due to the inductance in the motor coils (resistance to current) you dont get all the current into the coils, the pulse length time is too short. so if the current does not get into the coils you loose torque (current is proportional to torque). this is why the steppers will stall at high speeds, there is too little current in the coils to produce enough torque go get over hte detent torque in the motor.

I refer to the Drive chip as the FETS, the chip is a Quad half bridge.
In your original query, you wanted the stepper to turn faster.

Is that still your aim?
 

Lord Grezington

New Member
Yes, i have 2 Aims, both require a shorter pulse.

1. to get a shorter pulse so that i can run faster than a theoretical 1Khz (1ms pulse + execution time).

2. to PWM the voltage down at low speeds to reduce the current.
 

eclectic

Moderator
Yes, i have 2 Aims, both require a shorter pulse.

1. to get a shorter pulse so that i can run faster than a theoretical 1Khz (1ms pulse + execution time).

2. to PWM the voltage down at low speeds to reduce the current.
I think it's starting to become clearer?

1. You do not require high torque.

2. You just want faster rotation.

How about reducing the supply voltage from 24 to 12?

Secondly, I think that there's a lot
that could be achieved by tweaking the program.
(Flowchart/logicator?)

e
 

Lord Grezington

New Member
Varying the voltage on a stepper will not change the speed, it will only limit the top end speed. This is why chopper drives drive from high voltages (30 or 40V) detect the current via a sense resistor and then cut the voltage to the motor when the required current level is achieved. chopper drives can achieve much higher speeds because the higher voltage forces the current into the coils faster.

I am doing some experements with my now half quad bridge (until more FETS come in from canada) using the PulseOut command as i am sure this will work well.

I am not too sure if the Inverter will work though, it think it operates some sort of shmit trigger.

One other question (as your UK based not too far) where would the best place be to get a PCB made and populated? (a 5 year old can solder better than me)
 

eclectic

Moderator
Varying the voltage on a stepper will not change the speed, it will only limit the top end speed. This is why chopper drives drive from high voltages (30 or 40V) detect the current via a sense resistor and then cut the voltage to the motor when the required current level is achieved. chopper drives can achieve much higher speeds because the higher voltage forces the current into the coils faster.

I am doing some experements with my now half quad bridge (until more FETS come in from canada) using the PulseOut command as i am sure this will work well.

I am not too sure if the Inverter will work though, it think it operates some sort of shmit trigger.

One other question (as your UK based not too far) where would the best place be to get a PCB made and populated? (a 5 year old can solder better than me)
Totally confused by your answer. :-(

1. You want to limit current? Therefore limit voltage?

2. I'll be interested to know why you've blown your "FET"'

I'll retire temporarily.

e
 

MartinM57

Moderator
One other question (as your UK based not too far) where would the best place be to get a PCB made and populated? (a 5 year old can solder better than me)
Cheap, 10 off, takes 3 weeks, China, good quality (solder mask, screen printing included) - the iStore at http://iteadstudio.com

Expensive, 1 off, takes a day, UK, qood quality (for prototyping service, no solder mask or screen printing) - http://www.pcbtrain.com/

PCBTrain will populate but will be v.expensive to do so in small quantities. They might populate SMD resistors/caps for nothing.

You will have to do the larger component soldering yourself/find a friend.

You will have to send Gerber-274 files to either - does that mean anything to you?
 

Lord Grezington

New Member
Yes, I know we need the Gerber an "Macnine" files?
I am using a free version of ExpressSchematic and ExpressPCB to build the shematics and desing the PCB, it was good and easy to learn. but it was desinged by some company in america as free software so you buy the boards from them. but they are expensive and the shipping is silly money (especially for small volumes).

i have heard that you can get it converted, some manufactures i have heard will do it for you.
 

WHITEKNUCKLES

New Member
LG,

The test conditions for the Enables on the datasheet for the SN754410 pulse generator is 5khz, so it could be possible to apply the PWM available on GPIO2 (leg5) 08M to the EN pins 1 and 9 that you are holding high on the SN754410 in your diagram on post # 18.

My own efforts to use PWM on a stepper might interest you as there are links to Application Notes covering PWM for steppers.

Dave

http://www.picaxeforum.co.uk/showthread.php?t=18372

http://www.picaxeforum.co.uk/showthread.php?t=18473
 

westaust55

Moderator
LG,

The test conditions for the Enables on the datasheet for the SN754410 pulse generator is 5khz, so it could be possible to apply the PWM available on GPIO2 (leg5) 08M to the EN pins 1 and 9 that you are holding high on the SN754410 in your diagram on post # 18.

My own efforts to use PWM on a stepper might interest you as there are links to Application Notes covering PWM for steppers.

Dave
Correct (i.e. gating the H bridge Enable pins) and basically the same as I had proposed earlier to the Lord G. in post 19 here: http://www.picaxeforum.co.uk/showthread.php?t=18216&page=2
 

Lord Grezington

New Member
LG,

The test conditions for the Enables on the datasheet for the SN754410 pulse generator is 5khz, so it could be possible to apply the PWM available on GPIO2 (leg5) 08M to the EN pins 1 and 9 that you are holding high on the SN754410 in your diagram on post # 18.

My own efforts to use PWM on a stepper might interest you as there are links to Application Notes covering PWM for steppers.

Dave

http://www.picaxeforum.co.uk/showthread.php?t=18372

http://www.picaxeforum.co.uk/showthread.php?t=18473
Knuckles, your a genious. sorry i missed your post "westaust55".

I was just going to up the frequency up to 8Mhz, change the stepper to a 3.6 degree step rather than a 1.8, i could then use use std I/O to attempt to get my duty at the lower speeds as i had more time per pulse to play with.

I think using the EN pins on the FETS is a fantastic idea.

Thanks knuckles, you have jsut made my week!!
 
Top