Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: PWM gaps? Post ReplyPost New Topic
<< Prev Page of 8 Next >>
Author
Message << Prev Topic | Next Topic >>
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2443
Posted: 05 August 2018 at 5:29pm | IP Logged Quote Geoffg

I have updated the beta version to fix the PWM gaps issue (it is now at beta 5).

It can be downloaded from: http://geoffg.net/micromite.html#Downloads
Look for "Micromite Firmware V5.04.10 Beta Test Version"

I have done a lot of testing on it and it runs smoothly on both ascending and descending frequencies. Please give it a run and let me know if you find anything else (fingers crossed that that will not happen).

Geoff


Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Malibu
Regular Member
Regular Member


Joined: 07 July 2018
Location: Australia
Online Status: Offline
Posts: 87
Posted: 06 August 2018 at 9:38am | IP Logged Quote Malibu

Thanks for the effort you put in Geoff!
I've hammered your new version pretty hard this morning and it's a BIG improvement!
I started off with Ramp Up, Hold Speed, Ramp Down, Hold Speed in a DO: LOOP routine. I kept my eyes on the DSO and it all seemed good, but I could still hear a tiny <clunk> in the motor occasionally.
I figured that it was probably my hardware and/or code that I had, but as I was going glassy-eyed watching the pulses, I THOUGHT that I saw a glitch...
I whittled down the code and ran this...
Const mStep=48, mDirection=50, mEnable=54 <<- Set Constants

SetPin 50, dout <<-- Set Pins
SetPin 51, dout
SetPin 52, dout
SetPin 53, dout
SetPin 54, dout

Pin(mDirection)=Low <<-- CW Rotation
Pin(mEnable)=High <<-- Enable DRV882
Port (51,3)= &B101 <<-- Set to 1/32 Mode

do
  for i = 20 to 25000
    pwm 1, i, 50
    pause 1
  next i
loop

Most is to setup the DRV8825 board and I have limited the mode to 1/32 micro-stepping. I've also upped the PWM frequency to 25K, but that's because I've set 1/32 mode.

I kept my eyes glued to the DSO, ready to pounce on the pause icon and finally here's the capture I got.


This is at around 3.7Khz and 1.45mS wide, but I've also captured 1.3mS at various other frequencies too
Again, there seems to be no set pattern or frequency for the gap. Edit: Again, only low, never highs.
With my USB DSO, it could be a limitation of that setup. It could also be my hardware/code, so I'll keep going and see where it ends up.
No doubt, a big improvement on what was prior with a much smoother and sweeter sounding stepper motor.


Edited by Malibu on 06 August 2018 at 9:39am


__________________

John
Back to Top View Malibu's Profile Search for other posts by Malibu
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2443
Posted: 06 August 2018 at 9:54am | IP Logged Quote Geoffg

Thanks, I can guess what is causing this one and it is a bit more complicated. I will have a go at it over the next day or two and report back.
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Malibu
Regular Member
Regular Member


Joined: 07 July 2018
Location: Australia
Online Status: Offline
Posts: 87
Posted: 06 August 2018 at 9:58am | IP Logged Quote Malibu

A little more...
Here's the code - an adaption of your test code Geoff
Do
  PWM 1, 3000, 25
  PWM 1, 3010, 25
Loop

That should be (3000/200PPR)*60 = 900RPM... confirmed by the digital tacho.

While I run the code, the motor goes crazy by stopping, starting, hunt forward, run reverse, stop, hunt backward... and so on (It's hard to explain, but it does what motors shouldn't do!)
So, clicking ^C in MMchat, will do one of two things:
1) the Motor runs perfectly sweet.
2) the Motor squeals in a stalled position.
Whichever one happens, the frequency continues smooth and steady at 3Khz and physically, the motor runs according to what it was doing when I actually click ^C.

Still fiddling - I'll keep you updated!

__________________

John
Back to Top View Malibu's Profile Search for other posts by Malibu
 
Malibu
Regular Member
Regular Member


Joined: 07 July 2018
Location: Australia
Online Status: Offline
Posts: 87
Posted: 06 August 2018 at 10:26am | IP Logged Quote Malibu

Geoffg wrote:
and it is a bit more complicated

MORE complicated?
I though it was complicated on the last one!

Thanks Geoff



__________________

John
Back to Top View Malibu's Profile Search for other posts by Malibu
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2443
Posted: 06 August 2018 at 1:52pm | IP Logged Quote Geoffg

OK, I have had another shot at this (beta 6). As before it can be downloaded from: http://geoffg.net/micromite.html#Downloads.

The issue comes about because of the way the PWM output is generated. A counter counts upwards and on each increment it is compared to a register. If they are equal the counter is reset to zero and starts counting up again - this is what controls the frequency. The problem occurs when you increase the frequency. For example, the counter might be at 900 and the register is set to 1000. If you change the register to 800 there will be no match and the counter will continue to its limit (65535) before resetting and during this time the output will not change (ie, the "gap").

The simple answer is wait for the counter to reset to zero and then update the register. The problem with this is that at low frequencies it could be up to 50ms before this happens and MMBasic will freeze while waiting, so a more complicated solution is required. On top of this there is another issue at higher frequencies - the counter might be at zero for such a short time that the firmware cannot see it (which is the current problem).

I have tested beta 6 and it seems good but I think that your steppers are more sensitive to these momentary glitches so I would be grateful if you could test beta 6 and report back.

BTW, there is a change in the counter setup (and the update algorithm) at 1250Hz or above, so there could be a glitch when moving up or down through this frequency. Please let me know if you see it.

Thanks,
Geoff

Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Malibu
Regular Member
Regular Member


Joined: 07 July 2018
Location: Australia
Online Status: Offline
Posts: 87
Posted: 06 August 2018 at 2:59pm | IP Logged Quote Malibu

All I can say is "Brilliant!"

Quote:
Const mStep=48, mDirection=50, mEnable=54
Const MinSpeed = 320, MaxSpeed = 160000 ' 320=6RPM, 160000=3000RPM
Const SetRPM=2900

dim CurSpeed, SetSpeed as integer

SetPin 50, dout
SetPin 51, dout
SetPin 52, dout
SetPin 53, dout
SetPin 54, dout

Pin(mDirection)=High
Pin(mEnable)=High
Port (51,3)= &B001 '<<-- 1/16 Step

SetSpeed = (SetRPM/60)*200*16

do
pwm 1, MinSpeed, 25
pause 100
for i = MinSpeed to MaxSpeed Step 10
pwm 1, i, 25
if i => SetSpeed then exit for
next i
CurSpeed = i
pause 5000
for i = CurSpeed to MinSpeed step - 10
pwm 1, i, 25
next i
loop


I didn't even bother to hook up the DSO to check the pulses because it ran so sweet out of the box, there was no need.
Notice in the code that my set RPM is 2900?
I have the stepper ramping up and down between 6 and 2900RPM and in 100+ cycles, it hasn't skipped a beat. (Actual speed is 2901 RPM - the fastest I've driven a stepper)
There's no sign of the 1250Hz problem - if it's there, the motor cruises through it with no problems.
I even set the STEP between 1 and 50 without any problems.

I suspect I could push the motor parameters a little more and still get away with it (...and I might, just for the fun of it ).

Thanks Geoff, that's a brilliant piece of work

__________________

John
Back to Top View Malibu's Profile Search for other posts by Malibu
 
Malibu
Regular Member
Regular Member


Joined: 07 July 2018
Location: Australia
Online Status: Offline
Posts: 87
Posted: 06 August 2018 at 3:51pm | IP Logged Quote Malibu

Just for interest, I pushed things a little harder and managed to get a no-load speed of 3860RPM out of the motor. (Mostly regular with only around 10% of cycles missing steps causing a stall)
That's a PWM frequency of 205Khz and 50% duty
I only realised I wouldn't get much more when I hooked up the DSO and saw a pulse width of 2.2uS - the driver board needs 1.9uS minimum so it's really running on the limit!
I'm impressed


__________________

John
Back to Top View Malibu's Profile Search for other posts by Malibu
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2443
Posted: 06 August 2018 at 5:43pm | IP Logged Quote Geoffg

Thanks John, great news.

Another bug squashed.
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Azure
Guru
Guru
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 446
Posted: 06 August 2018 at 11:00pm | IP Logged Quote Azure

Great news. Those ramps up and down are very accelerated and should show up the problem if it exists.

Just for completeness you should run it with a pause in between steps to make sure it is also smooth on a slower ramping.

And out of curiosity what does the latest firmware do with Geoff's short step up/down loop.
Back to Top View Azure's Profile Search for other posts by Azure
 
Malibu
Regular Member
Regular Member


Joined: 07 July 2018
Location: Australia
Online Status: Offline
Posts: 87
Posted: 07 August 2018 at 7:53am | IP Logged Quote Malibu

A little further testing this morning...
Quote:
And out of curiosity what does the latest firmware do with Geoff's short step up/down loop.

PWM 1, 3000, 25
PWM 1, 3010, 25

No problems at all. The same code in Beta5 had the motor ready to leap off the table. Beta6 and it runs smooth as silk.
Quote:
pause in between steps to make sure it is also smooth on a slower ramping.

I did all that yesterday and couldn't fault any of the ramping in slow speeds right through to fast speeds with long pauses, short pauses and a whole bunch of variations of a theme. I even tried STEP 500 and it reached top speed virtually instant.
Eventually, I could get the motor to stall, but that was pushing things WAY beyond what should be considered 'normal' (ie: STEP 160000 is a little too much, but defeats the purpose of adding any Ramp Up anyway)

Quote:
BTW, there is a change in the counter setup (and the update algorithm) at 1250Hz or above, so there could be a glitch when moving up or down through this frequency. Please let me know if you see it.

I see it.
Having said that, it wasn't noticable on yesterdays testing, but that was a speed range of dead-slow up to super-fast.
I knocked up some code this morning for testing (complete with my notes)
print "1250Hz Range"
'Notes:
'BaseHz=1246; Good signal > Motor growly, but probably magnet click. 19 Good Pulses
'BaseHz=1247; Good signal > Motor growly, but probably magnet click. 19 Good Pulses
'BaseHz=1248; Signal Chopped > Wide 1st Pulse, 10 good pulse, 1 slightly narrower pulse, 1 spike, 4 good pulse | Regular Pattern
'BaseHz=1249; Signal Chopped > Wide 1st pulse, 4 good pulse, 1 narrower pulse, 1 spike, 11 good pulses | Regular Pattern
'BaseHz=1250; Good Signal > Motor Growly (Magnet click?), 20 good pulses.
'BaseHz=1251; Good Signal > Motor Growly (Magnet click?), 20 good pulses.
  BaseHz=1249
  for j = 1 to 500
    for i = BaseHz to (BaseHz+2)
      pwm 1, i, 50
      pause 5
    next i
    pwm 1, stop
    pause 10
  next j
  pwm 1, stop
  pause 1000 
  print "1250Hz"
  pwm 1, (baseHz+1), 50
  pause 10000
  pwm 1, stop

(Edit: Ooops, I hit the post button too soon)
It only comes in to play and is noticable AT the 1249 to 1251 range. That's also an unlikely scenario to ramp up from 1249 to 1251 as minimum speed set to maximum speed set. Speeds will pass through that range, but only on the way to a faster speed.
If you're happy to fix it Geoff, I'm happy to test it - but for my purposes it does what it should


Edited by Malibu on 07 August 2018 at 7:57am


__________________

John
Back to Top View Malibu's Profile Search for other posts by Malibu
 
Malibu
Regular Member
Regular Member


Joined: 07 July 2018
Location: Australia
Online Status: Offline
Posts: 87
Posted: 07 August 2018 at 8:00am | IP Logged Quote Malibu

Here's the waveform with BaseHz set to 1249




__________________

John
Back to Top View Malibu's Profile Search for other posts by Malibu
 


<< Prev Page of 8 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1250 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.12