Building an Inverted Pendulum System The Ups and Downs of Defying Gravity…

February 9, 2010

Even more current analysis

Filed under: Software — Bruce Ammons @ 7:04 pm

I thought my plans for scaling the current and calculating the overall current would work well.  The exact factor of two was appealing – until I ran the motor in the other direction.  In that direction, the factor looked closer to 1.8, which totally confused me.  I was frustrated and decided to take a break for while.  In the meanwhile, I continued discussing my issues measuring current on the NI discussion forum.  Yesterday Eric from NI answered all my questions very clearly (see How is NI-9505 current sense measured? for details).  He explained that there are two resistors used to measure the current.  During the On cycle, the resistor that the current passes through depends on the direction of rotation.  During the Off cycle the current goes through both resistors, which makes the measured current twice the actual current and totally explains why the Off cycle was measuring about twice the On cycle.  The different factor for each direction of rotation is because the two resistors have slightly different values.  Once I realized this, I compared the waveforms and found out that for CW my 9505 module has an Off/On ratio of about 2.05, and for CCW the ratio is about 1.95.  Once these correction factors are applied, the On and Off cycles are almost exactly equal for both directions.  Therefore, my current measurement scheme will be:

  • Measure at the center of the Off cycle if the PWM < 30% (to avoid spike effects in small pulse widths) and leave the value as is.
  • Measure at the center of the On cycle if the PWM > 30%, and multiply it by the appropriate scaling factor (CW = 2.05, CCW = 1.95) to get it to match the Off cycle.

This will give me an accurate current measurement at any PWM and either direction.  The scaling factor for the current measurement will be 3.1 mA/count since I will have twice as many counts during the On cycle.

I believe this resolves my issues measuring current, so I can move on to the next step – reading the encoders to determine position, velocity, and acceleration.  I can also start programming a PID loop to control the current.

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress