Current Control

Has anyone tried using Current Mode on the jaguars?
I tried it today in LabVIEW, but it did nothing. (I modified the voltage example to open the Jags in current mode, and replaced the “max voltage” stuff with controls for PID)
It’s probably just an incorrect arbitration ID, but I was curious if anybody had already looked into it.

It seems to work with BDC-COMM, although I wonder if the integration was left out, or if the scaling is off. (Given constant load, constant setpoint, and constant nonzero P coefficient, there is a constant error.)
Also, the oscillation point is a little strange; oscilation becomes more apparent at lower speeds, but virtually disappears at higher speeds. I have trouble telling whether jerkiness of the motor is due to slow speed or to the oscillations of the motor. Can the Ziegler–Nichols method be used, or is there a different method? I suppose the inertia of the drivetrain or manipulator will help decrease the frequency of oscillation if I tune on a robot, not a test setup. Perhaps I should also attach a heatsink to the motor so it does not burn up. (At the moment I’m using a Fisher Price with a planetary gearbox)

I got it working in C++ when we were testing CAN out. What I found is you need to setup PID for it to work and your target current must be MUCH higher than what you actually want (I had to say 40 to get out a reasonable speed when under voltage control). Experiment in BDC-COMM and then transfer over constants that work to your robot code

Did it actually hold constant current as you varied the load?

Is there a set ratio between setpoint and effective current? I know the current set is actually a fixed point 8.8 number, so if you have a signed word as your amperage, you need to multiply it by 256 (hexadecimal 100). I saw this done in LabVIEW, but it might be something to check.

I don’t really remember. In my two days with the robot we didn’t have time to set up anything fancy like that. This was just my experimenting after I got the CAN bus loaded

Anyone?

2468 used current mode with good success this year. Be sure to enable control and tune the PID parameters. It took me a few minutes, but our current was rock solid once tuned.

Well, I tested it again today on the BDC-COMM. I think last time I had only tested the Proportional term, and my observations were based off of that.
The integration works with no problem, and is even scaled correctly. However, I can’t seem to get the Proportional term anywhere near high enough to get the motor up to the correct current, because it keeps oscillating.
Okay, so if my 12v motor draws about 2 amps full speed (with no load), then I should want my proportional constant to be 6, so that when I make the setpoint 2A, then the controller will provide full voltage (12v). That is, that would be the case if it were always referenced off of zero, and not the current error.

But check this out:
If I have my setpoint at 40A, and my proportional coefficient coefficient at 1, then it outputs 3.5 volts. (It also says my motor is drawing 2.25A at this low speed) Apparently, 1*(40-2.25) = 3.5 (Or rather, 3.5÷12 full power)
Does that mean that somewhere in here something’s scaled incorrectly? However, if I include a little integration (about 0.004) , it quickly jumps up to max speed.
Likewise, when the Proportional coefficient is at 2, setpoint at 40A, the controller outputs 7v (2.5A).
With a coefficient of 3, it outputs 10.7v, oscillating between 1.9 and 2.4A.
And with a coefficient of 3.25, it outputs full voltage, the motor drawing 1.7A.

So, judging by the fact that these outputs are constant (no change, no oscillation), I would infer the Jaguars draw their error not from the setpointprocess variable, but from setpoint - 0. (The Integral parameter probably uses setpointprocess variable)

Thus, with a small Proportional coefficient, the process variable will never even get close to the setpoint, as was observed here.

However, if I make my setpoint 4 Amps, and my Proportional coefficient 10, my motor is very clearly oscillating. (The amperage reads anywhere between 4 and zero)
Perhaps, you might say, the Proportional component is “maxing out” somewhere, thus preventing the oscillation. This is possible, but isn’t it strange for the proportional term to “max out” at such a low value, yet scale up with the proportional term and the setpoint?
I can’t make sense of this. Is current mode simply not intended to work with small motors? I don’t have any CIMs lying around my house.

Marshall -

Please make sure you have the latest firmware loaded. There was a small error in the calculations that was patched. I don’t think it would create your issue, but you might as well check.

I’m unsure of what the units in the PID are. I tuned it as I tune any other PID loop: blindly.

  1. Crank P until it oscillates, cut it in half (or more).
  2. Crank I until it hits the set point “quick enough”.
  3. Mess with D and I until either
    a) It looks good, or
    b) I find something better to do.

It isn’t a great method, but it has worked for me in the past. I’d suggest trying to remove the science from it and go at it from a “fiddle with the knobs” perspective.

Hopefully someone with more science will delete this post and put the real method up.

Yes, I have firmware version 91.

I fiddled with the sliders, but didn’t really get anywhere.
Your method of tuning is actually perfectly acceptable and common, and it’s just an approximation of Ziegler-Nichols.

However, the oscillation point seems to change on me as I change the setpoint, and that’s rather puzzling. (When I have the setpoint at 1A, every P value seems to either cause oscillation, or no output at all.)

I was driving a CIM, with a set point in the 4-10 amp range. I never tried driving it at just an amp. You might be hitting resolution limits - maximum current is somewhere in the 60+Amp range, I don’t recall what one count translates to.

Marshall -

Something in my head just jostled loose regarding this statement.

The PID loop uses the current sensor as an input and gives duty cycle as an output. Therefore, the style of analysis you were attempting does not work in this situation. Your example becomes:

% on time = scaling_factor * 1 * (40-2.5)

instead of

Amps = 1 * (40A-2.5A)

Did I mis-state something?.
The output I was recording was the voltage across the motor’s leads, as reported by the Jaguar. (I have a Fluke 175 I could use instead if the Jaguars just report a calculated value for voltage)

What do you suppose the scaling factor could be? There is no configuration that relates to this, except perhaps “number of brushes”.

Something to note:

If using a Black Jaguar, the current measurement accuracy below 8A is typically +/-2A. When trying to drive at lower currents, you might be reading 0A when it is actually 2A. Above 8A the current accuracy improves to +/- 1A. (This info is in the Black Jaguar Datasheet)

The current sense circuit in Black Jaguar is quite accurate in the higher current range. Unfortunately you get the +/- 1A and +/- 2A thing going on in the lower ranges. This is on our list of things that need improvement.

Gray Jaguar is rated at +/- 1A typically. Like Black Jag, it should improve at higher currents.

-David

Thank you!
For some reason I hadn’t seen it there before.
I see it also says “measurement resolution: 10 bits”. Does this refer to the ADC on the ARM? Is the +/- 1A resolution the accuracy of the sensor itself?

Yes, 10 bit ADC.

The +/- 1A is a combination of the sensor’s accuracy and what we measured on multiple Jaguars in the lab.

-David