Jay:
If bandwidth/nyquist is a problem in your system, how about this
modification to address it:
Use a clock that is N times the frequency of your desired frequency (e.g.,
16 times). If you want to lock into one motor rev/original clock, lock into
1 motor rev/16 clocks. You can then measure the phase error (in encoder
counts) 16 times per cycle (each clock, check the encoder, and compare it to
N/16, where N is the encoder counts/revolution). Or, stated another way,
lock into N/K encoder counts between clock edges, where N is encoder
counts/rev and K is the oversample factor of the clock. You can't go crazy
with K, since an encoder count has inherent uncertainty of true position
(unless you use encoder crossings as the time base of your system, wich you
cannot, since your crystal must be the time base), and as K gets close to N
you loose accuracy in your measurement. However, this may be a nifty way to
achieve higher sample rate for controller, albeit with accuracy of
measurement sacrificed.
Jim
"Jay" <
[email protected]> wrote in message news:61NDb.23$cj.11@fe01...
> Hi Fred,
>
> Thanks for the detailed response.
>
> In article <
[email protected]>, fmarshallx@
> >
> > ***Yes, that was the idea. But, I think you need to get away from this
> > approach anyway.
>
> I agree, the variable Ts / variable gains is an interesting problem but
> perhaps for another time? :).
>
> > .................................
> > >
> > > This also means, if my understanding is correct, my digital PID loop
> > > should not apply or provide control changes at a rater faster than the
> > > motor can respond to.
> >
> > ***Oh, I don't see why not if you have the compute power - if what you
mean
> > is the drive voltage to the motor. Actually, the issue is that it might
not
> > have an *adequate* rate!
>
> I am slightly confused here(more below). My system has enough
> computational resources to issue an update rates probably on the order
> of a kHz or so.
>
> I also have enough drive voltage and drive current, so that isn't what I
> was getting at.
>
> > > My feeling is if I continue with my existing control-loop approach
> > > (using the tachometer output) I would have to provide some kind of
> > > hysteresis or slew-rate limiting so even if my motor is spinning at
say
> > > 50Hz (meaning I get new errors at a rate ~50 Hz), and I know my 0 dB
> > > frequency is say 10 Hz, I would not issue updates any faster than 10
Hz.
> > >
> > > Is my reasoning correct?
> >
> > ***I don't think so. You probably want to generate them even faster
than
> > that! Our concern was that one indication per revolution might be
> > undersampling. Jerry's rule of thumb of a factor of 5 times
oversampling is
> > a good thing to focus on. That is, 5 times the Nyquist rate or 10 times
the
> > bandwidth of the data. If the shaft rate is 50Hz then this would mean
a
> > single sample per revolution would be OK if the motor could not
appreciably
> > change speed with a superimposed drive voltage at 5Hz - more or less.
This
> > translates into a motor step response that's much slower than 0.2
seconds.
> > That's a little hard to imagine.
>
> > Turning the numbers around:
> > If you sample at intervals around 1/50=0.020 seconds then the <bandwidth
has
> > to be less than 1/(10*0.020) or 5Hz.
> > Hysteresis or slew-rate limiting generally make things worse.
>
> What you are saying is that if my motor bandwidth is around 5Hz, 50Hz
> would be an acceptable sampling rate for errors.
>
> My point of confusion is if my motor bandwidth is only 5Hz, and I
> receive error information at the rate of 50Hz, process the error and
> produce a new output at a rate of 50Hz with some slight time delay from
> when I get the error does this not mean that I could end up with a limit
> cycle since I am driving the motor at a rate faster than it can keep up
> with?
>
> An illustration of the condition *I think I want to avoid* is shown on
> this page:
>
> http://www.engin.umich.edu/group/ctm/freq/freq.html
>
> search for "higher than the bandwidth frequency".
>
> If I'm missing something or have something flipped in my head, I'll
> gladly welcome any corrections!
>
> > .....snip the details.....
> > Take advantage of the full tachometer output! The phase lock control
chips
> > that I'm familiar with do the rough velocity control that you describe -
so
> > that part sounds OK. You adjust the frequency coming out of the motor
tach
> > until it's close.
>
> > Then, when it's close, the controller switches to a different mode of
> > operation - so you really have two control loops to analyze: the rough
> > control and the fine control. I guess as long as the rough control gets
you
> > into the fine range, it's OK if the rough control has a limit cycle (it
may
> > oscillate around the desired velocity if left by itself).
>
> Right, my idea is to bring the motor up to the desired speed or very
> close to it so phase lock occurs quickly.
>
> > For the fine control, what if you do a typical phase detection between
the
> > clock and the tach? That would be a more normal thing to do rather than
to
> > use counters. Surely the FPGA is plenty fast enough to do that. Then
you
> > phase lock the two in a normal sort of phase-locked loop approach. I
should
> > think that all of this would be in the FPGA. Something like the single
> > ended falling edge detector in:
> > http://www.cs.binghamton.edu/~csekhar/AN8017.PDF
>
> Actually this is *exactly* the kind of setup I have now. I have a
> Phase/Frequency detector in the FPGA, as I mentioned in my original
> post.
>
> Normally the edge-type phase detectors just provide the Up/Down signals
> and the duration that the Up/Down signals are on signifies the amount of
> error between the reference and clock(until both of them are in the on
> state).
>
> My "addition" to the edge type detector was to take the Up/Down signals
> and XOR them. The XORed output is used as an Enable to a counter clocked
> around 1.5MHz or so.
>
> The result is the counter holds the error between the reference and the
> motor tach output in terms of counter ticks which could be converted to
> a numerical time or a numerical phase error rather easily. My goal in
> using the counter was to have the control-loop chew on the error which
> is now numerical instead of being a square-wave of varying duty cycle.
>
> > Of course, in your case, the motor and its drive is the VCO and the
> > reference clock is the reference into the PLL, etc. And, I believe, the
> > integrator in the PID is the integrator in the VCO, right? I haven't
seen a
> > block diagram of what you're doing.....
>
> My original approach to this solution was just to treat the motor as a
> VCO and use the PFD to produce an error signal(or error count) used by
> the control-loop and just to approach the whole problem as a PLL design.
>
> But this sort of brings us back all the way around to my original
> variable Ts problem. See the error information from the Edge
> Phase/Frequency detector is only valid when the motor spins around once
> and the reference clock comes by.
>
> Even if I don't use a counter to numerically keep track of the time
> difference between the reference clock and the motor tach, I would still
> need some meaningful way to use the Up/Down signals...
>
> > I'm not the expert in how to implement this but here's a wild guess:
> > Build the single ended falling edge detector as above. Use the output
to
> > count up and down. While the phase is too positive, count up. While
the
> > phase is too negative, count down. The result is an integration of the
> > errors which should integrate to zero when it's locked. The count
drives a
> > DAC that creates the motor control voltage. I imagine the whole thing
looks
> > something like this. So, whether the counter is in the FPGA or in the
uC,
> > is up to you but I imagine that the responsiveness will be better if
it's in
> > the FPGA. Then the PID in the uC *can* be implemented with a fixed Ts
> > because you might sample the counter output regularly from the uC -
which
> > puts the sampling control in a better place. This all assumes that you
use
> > the full capability of the tachometer and have 1000 or 2000 pulses per
> > revolution of the motor shaft. It looks like it means that your
reference
> > clock will increase in frequency by a factor of 1000. Well, anyway,
this is
> > really a "cartoon" of what might work.... and there must be some fixed
> > output from the DAC somehow - maybe from the rough loop.
>
> What you're suggesting is sort of what I threw together in an hour (just
> to demonstrate to myself the PFD and all the logic in the FPGA was
> working).
>
> My one hour setup:
>
> First bring the output* to a value so the motor speed is very close to
> the reference clock.
>
> Then, each time the PFD circuit produced a new error (which meant one
> reference clock came by and the motor had spun one revolution), I had
> the uC read the error counter in the FPGA(which also provides
> leading/lagging information).
>
> If the motor was leading the reference signal, I decreased the output*
> by one binary count. If the motor was behind the reference clock I
> advanced the output* by one binary count.
>
> * The output in my case is the output from a 16-bit PWM controller
> housed in the FPGA. The PWM output drives an H-bridge whos output goes
> to the DC (brushed)motor.
>
> What I found is that the motor tach would hover around the reference
> clock but would never stop or lock. In my case I had set the reference
> clock to 20 Hz and I noticed +/- 100 deg variation in the motor output
> with respect to the reference.
>
> I figured that this approach was too simplistic and I wasn't taking into
> account the phase/frequency response of the motor, so I started on the
> PID approach.
>
> I don't see how what you are suggesting (+/- the output based on
> leading/lagging) could really be extended to using the quadrature
> outputs(as I think you are suggesting) unless I do something like what I
> suggested in my previous post where I use the quadrature counts as a
> positional error(established by the motor 1 pulse-per-revolution and the
> reference clock).
>
> I say that because if I use the quadrature output simply as a
> "tachometer", I would also have to multiply my reference signal
> frequency by a factor of 2000, which I don't have the facilities to do
> easily. In my case the reference clock is provided by an external
> circuit and I don't have the room for a normal PLL to perform frequency
> multiplication.
>
> Technically it is possible for me to build some kind of DDS in the FPGA
> but having THAT phase lock to the reference signal, etc, etc seems like
> a lot of trouble.
>
> I appreciate your help(and everyone elses) so far, it has been very
> valuable. As usual I welcome comments, criticisms and suggestions =).
>
> Thanks!
> -- Jay.
>