Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 01:24 19 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PWM gaps?

     Page 5 of 5    
Author Message
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 145
Posted: 08:17pm 15 Aug 2018
Copy link to clipboard 
Print this post

Crikeys Geoff, you're more tenacious than I am!

Let me wake up a little and I'll give it a try out; report back soon

John
 
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 145
Posted: 10:40pm 15 Aug 2018
Copy link to clipboard 
Print this post

100% perfect.
The code (with a few comments)
Const PauseVal = 0.1 '<<-- Higher number = slower ramp
Const StepVal = 250 '<<-- Lower number = faster ramp
' Ramp time = (MaxHz/StepVal)*PauseVal : (266667/250)*0.0001 = 0.106 Seconds
Const MaxHz = 266667 '<<-- RPM = (MaxHz/6400)*60
' Calculated 266667 = 2500RPM ... Measured 2504RPM ... 0.16% error

do
print "Up"
for i = 20 to MaxHz step StepVal
pwm 1,i,50
pause PauseVal
next i
print "Hold"
Pause 5000 '<<-- Pause time to check RPM Value
print "Down"
for i = MaxHz to 20 step -StepVal
pwm 1,i,50
pause PauseVal
next i
pwm 1, stop
pause 150
loop

I ran this many, many times with various iterations on the CONST values... What's here is really fast ramp up and ramp down times (From the calculations, it's 0 to 2500RPM in 1/10th of a second). I tried other times, even with StepVal=1 and PauseVal=50... but I wasn't going to wait 4 hours to check the results.
Any variation on the numbers made no difference to the rotational steps, and they all ran smooth right through the speed range.
There's a 0.16% error on the top speed, but I put that down to either Crystal tolerance and/or Tacho error. It's nothing, just trying to be thorough!
MaxHz is shown at 266667 (2500RPM) and the motor comfortably runs at that speed (disregard the real-world torque), and I also pushed it higher but began to run into trouble at around 2800RPM (I guess from magnetic saturation? The motor was on the verge of stalling - but it still kept going)
I just pushed my thumb against the motor shaft as a load, and it still had a surprising amount of torque, even during the ramp up stage. I eventually stalled it, but I was pushing pretty hard (which left a dimple in my thumb)
The proof's in the pudding and without hooking up any instruments, the 'tone' from the motor tells me it's perfect all the way up the range, no matter what values I use in the FOR:NEXT loop.
This particular test code uses twice the speed, and 10 times the ramp times that I want. If it can handle these boundaries, it will more than do what i need it to! If anyone want's to drive steppers harder than this, then steppers are not the way to go.

You nailed it Geoff, absolutely 100% perfect!
Many thanks thrown your way, and one day when you've got time I'd love to hear the cause of the problems that I got you into!

As a comment, it seems to be questionable in using PWM to control steppers, and in its strictest use, I'd agree. 'Normal' PWM has a set frequency and the mark/space ratio varied as needed (as said, simulating an analogue output) and for that use, it's perfect.
If you think of my use of the PWM as a variable frequency, while keeping the mark/space at 50%, what you end up with is just a 'variable frequency out' signal. Exactly the thing that a STEP/DIR drive is looking for in steppers. This is all done in one line of code and for me, it couldn't be easier!

(Post Note: I haven't tried this on the main code that I've been working on, but I don't see that it will be a problem)
EDIT: Just flashed the original board with Beta9 and loaded my 900 lines of code... perfect Edited by Malibu 2018-08-17

John
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 11:41pm 15 Aug 2018
Copy link to clipboard 
Print this post

Wonderful news, we can all rest easy. Thanks for your help John, the Micromite is just a bit more polished now.

Now I need to eat humble pie for telling you that the problem was at your end

BTW If you are using a 28 or 44-pin MM the speed error could be caused by drift in the internal RC oscillator.Edited by Geoffg 2018-08-17
Geoff Graham - http://geoffg.net
 
Azure

Guru

Joined: 09/11/2017
Location: Australia
Posts: 446
Posted: 12:07am 16 Aug 2018
Copy link to clipboard 
Print this post

  Geoffg said  BTW If you are using a 28 or 44-pin MM the speed error could be caused by drift in the internal RC oscillator.


I am pretty sure he is using MM Plus 64.
 
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 145
Posted: 12:18am 16 Aug 2018
Copy link to clipboard 
Print this post

All good Geoff, you're the one that needs to rest easy!
... and believe me, I was more then happy (albeit, embarrassed) to accept that it WAS my end so don't give it a second thought! Glad to see it's all sorted and as you say, a little more polished.
As Azure says, I'm running an MM+64Edited by Malibu 2018-08-17

John
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 12:08pm 16 Aug 2018
Copy link to clipboard 
Print this post

  Malibu said  
believe me, I was more then happy ... to accept that it WAS my end


yep, we should all be happy to be proved wrong - a haughty spirit has no place in science (or it's closely related threads; engineering and biology/medicine) Edited by CaptainBoing 2018-08-17
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 06:55pm 17 Aug 2018
Copy link to clipboard 
Print this post

Here's a motor rotor coil winder machine that might be inspirational. Uses an arduino.

How many turns go into a guitar pick-up coil?
Visit Vegipete's *Mite Library for cool programs.
 
Malibu
Senior Member

Joined: 07/07/2018
Location: Australia
Posts: 145
Posted: 10:38pm 17 Aug 2018
Copy link to clipboard 
Print this post

An interesting way to wind a dc motor!
I'm not sure about the efficiency of the motor with windings so loose, but a cool way to do it
  Quote  How many turns go into a guitar pick-up coil?

There's no set amount and depends on what sort of output you're looking for.
Usually, the range is from 6500 to 10000 turns, but can go lower or higher. Most are around the 8000 to 9000 mark.

John
 
Tendor
Newbie

Joined: 14/12/2017
Location: Australia
Posts: 6
Posted: 07:33am 23 Feb 2020
Copy link to clipboard 
Print this post

Perhaps someone can help me with this please? (Geoff?)

I'm using an original monochrome MM (firmware V4.5C)to implement an analogue time delay (bucket brigade style) with the output via PWM. The PWM command is therefore re-issued at each sampling period, the frequency being proportional to the delayed signal amplitude (being careful to not cross any silly frequency vs sample time boundaries).

However, each re-issue of the PWM generates an audible 'click' (when unfiltered and driving a speaker) rather than a seamless transition to the revised frequency.  I have only an old analogue CRO.  I can see something at the transition but don't have capture facilities to show you an image.

Is this the same problem discussed in this thread, rearing its head in the Maximite V4.5C firmware?
I see that it was tracked down and overcome' in the Micromite firmware.
Did/Does the same problem exist in the Monochrome MM firmware? (Geoff?)

Many thanks for any help.
Rod.
 
     Page 5 of 5    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024