Voltage vs. PercentVbus

Can someone confirm/explain the difference between driving Jaguars via kPercentVbus which is a plain -1 to +1 PWM duty cycle (ie: 0.5 means 50% ON in the forward direction), and kVoltage (ie: 5 means +5V).

I assume the latter means the Jag will output an average of +5V during its PWM cycle irrespective of battery voltage (assuming it is > some minimum above 5V) (what is that minimum delta? maybe 1V?).

For the examples above that means, if the Battery is 12V, a kPercentVbus will provide an average V of 6V whereas in the second it will be 5V. This can then be an effective way (easier than PID) to provide a known power input to the motor irrespective of the varying state of the battery. So for example driving the shooter power via kVoltage would be quite predictable after calibration. May even be more predictable than fidling with a PID.

Now onto some confusing documentaion:
From:
http://javadoc.waltonrobotics.org/edu/wpi/first/wpilibj/CANJaguar.html#kControllerRate

getOutputVoltage
public double getOutputVoltage()Get the voltage being output from the motor terminals of the Jaguar.

Returns:
The output voltage in Volts.


Also:
configMaxOutputVoltage

public void configMaxOutputVoltage(double voltage)Configure the maximum voltage that the Jaguar will ever output. This can be used to limit the maximum output voltage in all modes so that motors which cannot withstand full bus voltage can be used safely.

Parameters:
voltage - The maximum voltage output by the Jaguar.


This implies the output votage from the Jag is analogue not just ON/OFF???

If so then getOutputVoltage() will NOT return the average V of a PWM cycle.

Output voltage from Jag (or Victor) is always PWM.

The electronics in them do not permit analogue variation.
*
*

Like Ether said, the output is always a PWM. However you are correct about the differences between the modes.

Percent VBus drives the output at some percentage of the input voltage. This is the most straightforward of the the various modes.

Voltage mode AKA Voltage Compensation mode will try and output a set voltage regardless of the battery voltage. It accomplishes this by varying the output PWM based on what the measured voltage on the input voltage is. For example, if you’re telling the Jaguar to output 5 volts, and the battery is at 12V, the output duty cycle of the Jaguar will be ~42%. If the battery droops to 7 volts, the Jaguar will adjust the output duty cycle to ~71% to maintain an average of 5V.

-David

Yeah, I should have cross-referenced this thread in my post in my response for completeness for readers who hadn’t already seen it.
*
*

Just to make sure we’re all seeing things the same way:

When we say output 6 in kVoltage, there will be NO 6V measurable on the output at any point in time. I think we all agree that the output can only be in two possible states, a full ON or full OFF of the H-bridge (Full battery voltage (less MOSfet drop) or 0V). The output will look identical to a 0.5 in kPercentVbus with a battery voltage of 12V. There is no need to ADC the output, just the input Bus Voltage so that the Jag processor can compute the % duty cycle on the output.

So it is awfully missleading to read the following method description:

configMaxOutputVoltage

Quote:
public void configMaxOutputVoltage(double voltage)Configure the maximum voltage that the Jaguar will ever output. This can be used to limit the maximum output voltage in all modes so that motors which cannot withstand full bus voltage can be used safely.

Parameters:
voltage - The maximum voltage output by the Jaguar.


It depends on how you measure it and what it’s connected to and what you measure it with.

If it’s connected to a stalled motor with a high inductance and you measure it using the DC setting of a meter which responds to average voltage, you will read 6V.
*
*

The PWM cycle is (I believe) 50KHz so a DC meter will read the average and indeed show 6V. But that is not reality. If you use a scope, in “normal” operation, you will see a 50KHz squarewave (ignoring inductance distortion for clarity) with a 50% on/off duty cycle, and the the squarewave will be between 0V and 12V. In a stalled case, depending on fuses, inductances, etc, for a CIM, you will likely see whatever the CIM windings R is over a 12V battery before the fuse blows or the Jag shuts down thermally.

No, it’s 15KHz (for a Jaguar) and 150Hz (for a Victor).

so a DC meter will read the average and indeed show 6V
There’s no guarantee that any given DC meter will read average. A true RMS DC voltmeter will read 8.5 volts. Some DC voltmeters read RMS, some read algebraic average, and some read neither.

But that is not reality. If you use a scope, in “normal” operation, you will see a 50KHz squarewave (ignoring inductance distortion for clarity) with a 50% on/off duty cycle

The voltage waveform you see on a scope will depend on the motor, the motor controller, and the test conditions. With high inductance motors and high PWM frequency, the stalled-rotor current waveform will be DC with slight ripple.

While I understand your point, do you have a better name and description for the method? If you do you could attach it as a patch to a bug report in the WPILib tracker: http://firstforge.wpi.edu/sf/tracker/do/listTrackers/projects.wpilib/tracker

OK Ether, you are going to make me work here - last time I did this was 20+yrs ago. But it is all for a great cause!

So on the DC meters - yes there are many types out there, all will generally give some approximation of average voltage. As a rule though a DC meter is not the best tools for time variable signals. An oscilloscope is generally the best tool for analogue time variable signals. All electrical/electronics engineers will use them so they are a great investment to learn to use. They are the eyes into electric circuits.

I agree the inductance is huge on a CIM and cannot be ignored. I will try and model it. I couldn’t find any charts of stalled CIMs on here… But I will get the kids to play with that in the off-season it will be a great exercise!

The main Q I was after is finding out exactly what the Jag APIs do - there are ample horror stories on CD from poor people spending time figuring out their problems and a lot of those can be overcome with proper documentation - which is lacking IMHO. We should be spending time on the robot/game and not on reverse engineering the APIs and tools we use.

Specifically if anyone has the full specs on kVoltage, kPercentVbus, getOutputVoltage, configMaxOutputVoltage, and setVoltageRampRate, please post a link.

I am really mostly a mechanical guy so forgive me if this makes no sense.

The output of an unconnected jag would be a PWM square wave. Connect a motor to it, you are essentially throwing a big inductor with a little resistor in the loop? You would then have to look at it as system? Would resistance in the battery become an issue? Do have to admit the whole concept of DC & output of the jag is more of a metaphor that you are using to avoid confusing mechanical types that try to relate electricity to plumbing? After all the rate equations are the same.

… and a generator, if the motor is spinning.

Our robot was stripping the timing belt we wanted to use for the drivetrain and at midnight last night we decided to switch to chains… So excuse the lack of progress on the PWM vs analog Voltage. But I did do a quick model in SpiceIV and was surprised how little effect the inductor had (or how determined the battery was!). Today I threw a rig together and put a scope on it - and it too showed very little deviation from a true PWM, even after braking the CIM with my glove to a near stall.

I will do some pics etc and figure out how to post them (after we get the robot working!)

The good news is: use kVoltage - you can see (on the scope) the Jag modifying the PWM ratio as you apply load on the motor.

The bad news is that the documentation is quite missleading. Especially the
decription of the configMaxOutputVoltage method. (see quote in this thread.)

If you set kVoltage = 6V there is only Battery voltage or 0V to be seen anywhere - and the square wave is pretty square accross loads - see the pics and further detail I will post soon.

Dean

BTW - the kids were excited to see the High duration of the PWM stretch as you apply load to the motor. It was a great oportunity to teach them something - most of them have never played with an oscilosope and see what really is happening in the wires. Just seing the excitement in their eyes makes it all worth while!

To answer RuffleRidge’s Q above:

There is nothing really wrong with the method names - it is the description that needs to reflect reality. Its all pretty simple - The Jag can only output ON or OFF - I even looked at their cirsuit diagram and you can see that the MOSFETS in the H-Bridge are driven by a separate chip and follwing that datasheet it can ONLY drive the H-Bridge with ON/OFF signals.

Dean -

It would be great to see the traces. I think it becomes more apparent if you scope the current through the motor. Also, the output voltage is better described as “effective output voltage”.

I’d expect a stalled CIM driven by a Jag to show an almost DC current, if the conventional-wisdom 200μH inductance number is correct.

@Dean: while you’ve got the test setup, could you run locked-rotor traces for some of the other popular motors as well? Nobody seems to have motor inductance specs or data.

OK. Will try.

What I would love to do is to get a few kids excited to do a decent job in characterizing all these motors/Jags/etc. and publish it for the benefit of all.

I must say I was surprised at the SpiceIV results (also I don’t have a model for the motor so was just playing with H values), so I was really surprized how relatively little effect the motor inductance had in the real test rig. (I hope I wasn’t doing something wrong :eek: )

Dean

Here are the tests and results, with scope pictures.
(I am not sue how best to input pictures - my son suggested Imgur - but they say the pics may be deleted if not viewed in 6 months… if anyone knows of a better way to save these let me know)

Summary:
We tested the behavior of two FIRST motors under idle speed (no load) and stalled condition. The Motors are CIM and Fisher Price. All components are standard FIRST KOP. The setup is a 12V battery, cRio, Jaguar CANbus controlled driven in the kVoltage mode, and first a CIM then FP motor tested at various settings of kVoltage from 6V to 12V. The kVoltage mode behaves as predicted but does not seem to fully compensate for the bus voltage drop (battery input voltage). The inductance of the load has remarkably little effect on the waveforms observed. Some odd effects were observed and we speculate on the reasons.

Setup pic:
Imgur

First Motor - CIM - pic:
Imgur

Scope used:
Imgur

Test 1 - Idle, kVoltage=6V, I=3.23A
Jaguar Current=3.23A -as reported by getOutputCurrent() -This is almost certainly average current. see pic (ignore lines 1 and 3):
Imgur

Voltage on jag output is a 12V peak-peak 50% duty cycle PWM.
pic:
Imgur

Test 2 - Stalled, kVoltage=6, I=55A
The PWM duty cycle is now about 55% while the High V is about 10V.
Why does the Jag not make the average Vout closer to 6V? Maybe because it measures the input side Voltage which is higher given that we have about 100A flowing during the high cycle. [ToDo next time - look at input side V.]
pic:
Imgur

Test 3 - Idle, kVoltage=9, I=3
pic:
Imgur

Test 4 - Stalled, kVoltage=9, I=88A
pic:
Imgur
Jag cut out after a while (thermal cutoff), and restarted a few seconds later.
Pretty decent squarewave for 100A chopped through a large inductor!
I guess its the battery which is a bigger monster than the CIM <smiley>
Our battery measured at 0.02 Ohms internal resistance. Modeling with LTspiceIV confirmed this.

Test 5 - Idle, kVoltage=10, I=3A
pic:
Imgur

Test 6 - Stalled, kVoltage=10, I=98A
Hm… the Jag kept cutting out before I could snap a pic! Also very curiously, it crashed the cRio!! very consistently. Speculation: noise on the Vcc (power input to the cRio) either the voltage drops too far, or the voltage disturbance goes through the input filters and crashed the cRio.

Test 7 & 8 with kVoltage=12 are the same as for 10V. The Current always spikes and settles - it is the settled readings provided here, and there is not much observable diferrence in current between kVoltage of 10 and 12.

The Fisher Price motor date will be uploaded tomorrow - this is taking a long time …

Thanks for sharing this, and the time and effort you put into it.

I’m a bit disappointed there’s no scope traces of current. I was hoping to get some motor inductance data :frowning: