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 >>
Malibu
Regular Member
Regular Member


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

Quote:
Another update for the beta version (it is now at beta 7)

Thanks Geoff
I'm pretty crook at the moment, so give me a couple of days and I'll knock up some test code - I'll let you know how it gets on (I'm sure it will be fine!)

__________________

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: 2403
Posted: 11 August 2018 at 9:15am | IP Logged Quote Geoffg

I hope that it is not anything serious.

When said "changing the frequency from <1260Hz to above"
I should have said "changing the frequency from <1250Hz to above"

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: 79
Posted: 11 August 2018 at 2:16pm | IP Logged Quote Malibu

Nah, it's all good
Just a dose of the gastro that's been going around (I think my problem now is that I haven't eaten in 2 days!)

__________________

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: 79
Posted: 12 August 2018 at 1:17pm | IP Logged Quote Malibu

Sorry Geoff, I'm not sure what's going on with this version... I can't quite put my finger on a reason, so I'll give the facts and see where it goes from there.

A couple of days ago I had a piece of code to read a pot value, convert to PWM frequency and ramp up/ramp down to that value. If the pot value changed, so did the motors revs - and everything worked well.
I downloaded Beta 7 this morning and flashed the MM. Knocked up some code (A long story, but this is what I finished with)
option explicit

Dim StartHz, EndHz as integer
dim i, j as integer


pwm 1, stop
'Steady20Hz
'Range1000To2000
'Range100To1000
Range20To1000
'Range20To100

do:loop

sub Steady20Hz
  pwm 1, 20, 25
end sub

Sub Range1000To2000
  do
  for i = 1000 to 2000
    pwm 1,i,25
    pause .1
  next i
  pwm 1, stop
  pause 10
  loop
end sub

Sub Range100To1000
  do
  for i = 100 to 1000
    pwm 1,i,25
    pause .1
  next i
  pwm 1, stop
  pause 10
  loop
end sub

Sub Range20To1000
  do
  for i = 20 to 1000
    pwm 1,i,25
    pause .1
  next i
  pwm 1, stop
  pause 10
  loop
end sub

Sub Range20To100
  do
  for i = 20 to 100
    pwm 1,i,25
    pause .1
  next i
  pwm 1, stop
  pause 10
  loop
end sub

Running "Range20To1000", here's the waveform ... (Remember, this is using Beta 7)

If you comment in and out the various calls to the subs, you'll see there's a variation on the same theme - The worst offender is the "Range20To100".
...So, I loaded the code I had running a few days ago, and it certainly wasn't happy either. A very jumpy motor tone and seemed to be running a higher temperature on the motor. I went for a bite to eat and a think and when I came back the motor was sitting on the pad 45 degrees angle to what I left it at, which tells me that there's some serious stepping glitches happening (the momentum of the pulling up a motor makes a tiny jump)
So...... back in with Beta 6 and here's the "Range20To1000" code again.


It's hard to see, but the first picture is a 50m/s timebase and the second is 100m/s timebase yet running the same code.
Moving on, it's back in with the motor code from a couple of days ago running on Beta 6 and it's all sweet again.
As I said first up, I'm not sure what's going on!
Two things I noticed - first, a straight call of
PWM 1, 20, 25

... gives a nice waveform, and second, the 1250 glitch was certainly missing in Beta 7, but also seemed to jump Hz from 1247 to 1257. Maybe it's me or my DSO but that's what I could see.
Anyway, I'd love to offer my thoughts on what's going on, but I'm stumped on this one!

Edited by Malibu on 12 August 2018 at 1:20pm


__________________

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: 2403
Posted: 12 August 2018 at 11:29pm | IP Logged Quote Geoffg

I'm stumped also.

Looking at my oscilloscope traces it looks fine but there must be something going on that your servo is reacting to. I will try to get the time to put a logic analyser on to it - that will allow me to check one sweep in detail.

The problem is that I am running out of time. I leave in a week for Europe and will be gone until the end of September. It might be best to simply revert to the beta 6 code and leave it there.

EDIT:
Something just jumped out at me. Your loops have a delay of only 0.1ms, that is very short. Your Range20To100 has 80 steps and thus they are all completed in a little over 8ms. BUT the period of the first cycle (at 20Hz) is 50ms, so the whole thing is over before the first cycle has completed. This seems ridiculous, have I got it wrong?

Your other code ran at higher frequencies and had delays of 5ms, enough to get out several cycles before a frequency change. I never thought of testing it with such rapid changes - maybe the answer lies there.

Edited by Geoffg on 12 August 2018 at 11:59pm
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: 79
Posted: 13 August 2018 at 6:22am | IP Logged Quote Malibu

Quote:
The problem is that I am running out of time. I leave in a week for Europe and will be gone until the end of September. It might be best to simply revert to the beta 6 code and leave it there.

Not a problem Geoff
You've done heaps already and Beta 6 runs perfect as far as the motor turns go. It's only nit-picking because the trace 'says' there's a problem. I've re-flashed with the backup I made of 6, so I'm good to go with that.

Re the edit... This is 0.1ms delay, but I also dabbled with longer delays with the same results. I only went down to 0.1 to try and get the pulses closer together so I could capture the trace easier on the DSO.
It wouldn't explain why the 'working' motor code wouldn't work on Beta 7 though...

I have another kit for an MME64 (What can I say, I like these so much I bought 3 more kits!). Leave it with me and I'll put together another E64 loaded with Beta 7.
I can play around at some point and see if I can nut out what's going on (...and yeah, I'm happy to put my hand up and say it's my code! )

Don't stress, enjoy yourself in Europe and forget my badgerings!

__________________

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: 2403
Posted: 13 August 2018 at 9:12am | IP Logged Quote Geoffg

Well, I doubt that the code that you presented would work on beta 6, or any version.

Do you have a simple bit of demo code (just a few lines) that works on beta 6 but not 7?
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: 79
Posted: 13 August 2018 at 1:32pm | IP Logged Quote Malibu

G'day Geoff,
Ok, you're correct in that the 0.1ms is too quick for the 20Hz PWM.
So far, i haven't used down to 20 (minimum has always been 530; around 5 RPM) so never really concerned myself with what was happening below that figure. The 0.1mS was just to speed the frequency change up to make things happen faster. Plus, I only used 20 in Beta 7 to do a thorough test as promised

Sorry for the delay, I knocked up another E64 so I could have a B6 & B7 on hand to easily swap them around.
Ok, here's the results :

The code
option explicit
dim i as integer

do
  for i = 20 to 128000 step 500
    pwm 1,i,25
    pause 50
  next i
  pwm 1, stop
  pause 150
loop

...Changed from 0.1ms to 50ms with a step value of 500 to ramp up pretty fast. 20 is an RPM of 0.1875/min and 128000 is 1200/min

Here's the B6 waveform

The first wide pulse is 2.9mS wide and MAY be a remnant of the 20Hz PWM, but I can't be sure. Each change in errr... 'texture' (where the frequency changes and so the colour changes) corresponds to the 50mS pause value and the frequencies increase by the step value. All good there...

Here's B7 waveform running the same code

Again, the first 2 pulses are probably the 20Hz remnants and the same 'pattern' in both waveform recordings. Also shown is the gap in the 1250Hz
All I can see that MIGHT be another glitch is that I change frequencies ad-hoc and may cause the last pulse to be out of sync with the next set of frequencies.

Which bring me to the problem I've got with B7... I ran B6 around 50(ish) times without a problem, but with running B7, there's a LOT of out of step situations (motor squeal & "clunk"), maybe, 20% of the time?
I don't know why because I can't trap it on the DSO (As you say, an LA would be a better option)
I suspect it's having trouble with the ad-hoc frequency change, but it's only a guess. I'll keep fiddling as time permits and I'll try a loop-back to an interrupt pin so only on a falling edge of the frequency period will the new Hz get loaded into the PWM.
It's just odd that B6 works and B7 has developed this problem....

Seriously though, I'm happy to say that B6 fixed the issue for me - If you think it needs further debugging, I'm more than happy to test changes until your satisfied!
(Stay tuned for motor temperature readings re B6&B7)

Edit: I've done some temperature checking because I thought that the B7 motor was running hotter than the B6
B7 motor temperature was at 50 degrees, and with B6 running now for 45 minutes, it's at 36 degrees...


Edited by Malibu on 13 August 2018 at 2:40pm


__________________

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: 2403
Posted: 14 August 2018 at 12:49pm | IP Logged Quote Geoffg

I am afraid to say John that something is wrong with your setup, or your program, or whatever as the PWM output from Beta 7 is perfect with changing frequency. I connected a logic analyser and other than the missing pulse at 1250Hz there are no glitches, gaps, etc in the output.

I used the following program as the test. It pauses for a fraction over one cycle of the output and this means that the frequency increases by 1Hz for every cycle:
For i = 20 To 10000
   PWM 1, i, 50
   Pause (1000 / i) * 1.1
Next i
PWM 1, stop


The start (20Hz) is a clean pulse of the correct width:


There is the expected missing pulse at 1250Hz:


And at the PWM 1, STOP command the output is terminated cleanly:


In between it is a perfect square wave:


Remember that the frequency is increased by 1Hz after every cycle.

I also tried it with descending frequency, other frequency steps, etc... same story.

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: 79
Posted: 14 August 2018 at 2:33pm | IP Logged Quote Malibu

You have no idea how much I appreciate you're looking into this Geoff... A big Thanks for doing so!
Ok, I'm happy to admit that I have an issue somewhere (first time that's happened? Not likely!!)

I ran a modified version of your test code
do
  For i = 20 To 128000 step 5
    PWM 1, i, 50
    Pause (1000 / i) * 1.1
    Next i
  PWM 1, stop
  pause 3000
loop

... a higher final frequency, STEP 5 to push things a little harder and a continual DO:LOOP to just keep cycling. Basically the same core code though.

On Beta6, it all ran perfect 6 or 8 times in a row until I shut it down and inserted the 2nd board which has Beta7. It hadn't completed one loop and I had a step stall.
Ok, so it's a board problem I'm thinking.

Flash the current B6 board with B7, flash the current B7 board with the saved B6 hex from the other board (ie: swapped the hex from one to the other) and run the test code again.
Beta6 - No problems what so ever (old B7 board)... B7 step stalled on the 2nd loop cycle (old B6 board).

I'm completely baffled on what it could be...........
I'll keep pondering the problem - maybe I've missed something.
Thanks for the original bug-squash, that was the one one that was a real problem (Crikey, that seems so long ago now!)

EDIT: Just tried the new Beta 8 ... same thing as 7

Edited by Malibu on 14 August 2018 at 2:47pm


__________________

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: 2403
Posted: 14 August 2018 at 3:33pm | IP Logged Quote Geoffg

I'm thinking that it might be the missing pulse at 1250Hz. Beta 6 had a glitch (50us pulse) at that point and that might have been enough to keep your stepper happy.

Could you run a test from 20Hz to 1245Hz, then a second from 1255Hz to 128000Hz. If both work OK it means that the missing pulse is the issue.
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: 79
Posted: 14 August 2018 at 4:34pm | IP Logged Quote Malibu

Sigh...............
Are you sick of me yet? I would be if I were you!
Quote:
Could you run a test from 20Hz to 1245Hz

I ran this (everything is on Beta 8, because that's in the MM)
do
  For i = 20 To 1245
    PWM 1, i, 50
    Pause (1000 / i) * 1.1
    Next i
  PWM 1, stop
  pause 3000
loop

and as I expected, it didn't flinch (I didn't think it would be a problem because at 1245Hz, it's only around 10RPM. If there's a skip, there's still time for the motor to recover and continue, and any <clunk> just sounds like normal motor noise... that's the main reason why I wasn't concerned with the gap at that frequency)
Then...
do
  For i = 1255 To 128000
    PWM 1, i, 50
    Pause (1000 / i) * 1.1
    Next i
  PWM 1, stop
  pause 3000
loop

Which 90% of the DO:LOOP cycles gave a <clunk> at random frequencies, with around 20% eventuating into a step stall.
With a STEP value of 1, it's a much more docile ramp up for the motor, which means it's easier to recover if there's a small glitch along the way. The higher the STEP value, the more violent the ramp up is to the motor, so it's more likely to go into a stalled situation on a glitch. (Read into that that with a STEP val of 1, when there's a stall, the motor MAY recover and continue on its way. It seldom recovers from a stall with a higher STEP value)
Quote:
If both work OK it means that the missing pulse is the issue

For my situation, that glitch was never a problem because of what I said earlier - 10RPM is nothing in the grand scheme so I was never really too concerned with it, even when it was still a spike (I just thought it was odd)

So... in the latest development (from which I'm still kicking myself from my stoopidity!) my USB DSO has a Logic Analyser built in to it... Ah-ha!
So I hooked it up and after 17 attempts to catch what's going on, here's the trace


It's hard to get exact times etc from the cursors, but it's about 1.3mS long from falling edge to rising edge and the leading frequency is about 25KHz with the trailing one at 26.3KHz
By my maths, that's around (very roughly) 32 pulses (hmmmm... the exact number that the microstepping is set to. I disregarded that because this is a reading directly from the output pin on the E64)
There may be more than this in the recording, but it's the only one I could snare.

For me, it seems a little like the original problem, but I can't see how it could be!

__________________

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.1719 seconds.
Privacy Policy     Process times : 0, 0.02, 0, 0.16