Odd 9V Power Drain

Discussion specific to the DIP and TQFP packaged ZX devices like the ZX-40, ZX-44, ZX-32 and ZX-328 series. The differences between these devices is primarily the packaging and pinout so most issues will apply to all devices.
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Odd 9V Power Drain

Post by liam.zbasic »

I am baffled why my ZX-40A project is draining its 9V battery. The rate of drain is 0.01 volts every 2 seconds. The output from the 5V voltage regulator is stable at 5V. When I switch off the project, the 9V battery recharges itself to nearly 9V.

I have changed out 3 brand new duracell batteries, so it not the power source. I removed the filter-capacitors adjacent to the voltage regulator (10uF and 0.1uF), but no change. I removed 10uF filter-capacitors from the IR range sensors, but no change.

Appreciate your suggestions.

Liam
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

Well, first of all, linear regulators are not very efficient. I'd guess that you are running at 5/9 efficiency or less. Linear regulators discard the excess power (4v *whatever amperage) as heat.

Did you measure your actual amperage drawn from the battery? WHat stuff do you have that draws power other than the CPU itself? LEDs? Sensors?

-Tony
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

My ZX-40 project is a simple autonomous ground bot that tracks an object and holds a fixed distance. The ZX-40 inputs are two Sharp IR range sensors and outputs are 1) a simple LED, and 2) PWM signals to a motor controller. The 9V battery drain still occurs when I disconnect the outputs to motor controller and the 7.2V power source to the motors.

I'm beginning to think the 9V voltage drop is normal.

I will check the amperage drawn from the battery per your suggestion.
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

I understand now. The LM2940T with a 6V power source is a better solution (more efficient) than the venerable LM5805 with a 9V battery. Thanks.
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

liam.zbasic wrote:I understand now. The LM2940T with a 6V power source is a better solution (more efficient) than the venerable LM5805 with a 9V battery. Thanks.
Be careful with only a 6V source. I believe that the 2940 is a "low drop out" type but 6v is getting quite close to the dropout voltage. WHen you have batteries that are 1/2 discharged, what voltage will they deliver? Probably less than 6V. Maybe less than the dropout voltage. In order to get full use of your batteries while still minimizing inefficiency, you may need to go up to 7.5V. It all depends on the "discharged" voltage" of your batteries. You need the "discharged" value be above your dropout voltage.

A switching regulator is much more efficient. There are 7805-equivalent switching regulators. I believe Recom makes them, and there are probably others too. There are lots of possibilities if you don't mind a non-7805 pin configuration.

-Tony
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Odd 9V Power Drain

Post by GTBecker »

Not cheap, but a good solution, very reliable and well-supported, in my
experience:

http://dimensionengineering.com/DE-SW050.htm

Tom
Tom
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

(V Battery and regulator

Post by twesthoff »

In order to really help with this, we need to know how much current is being drawn from the 9V battery. (v batteries are not good choices unless the current is low.
See: http://data.energizer.com/PDFs/522.pdf

The switching type regulators are much more efficient and work well with battery applications. I have used this series of regulator modules with good results:
PT78ST105
http://focus.ti.com/docs/prod/folders/p ... st105.html

They are more expensive though, but allow you to use a higher voltage battery without wasting as much power as linear regulators do.
Tom W.
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

Here's a video of my project (link below). It's a simple Groundbot that tracks an object an maintains a fixed distance (9"). It uses the ZX-40A mcu. Control is achieved with a simple P-controller using distance feedback from two Sharp IR range sensors (GP2D12). The calibration is based on an Arctangent fit, not a typical 5th order polynomial to save floating point calcs. The ZX-40A sends two PWM signals to the motor driver (Pololu VNH2SP30), which in turn controls two motors (Tamiya 72101).

http://www.youtube.com/watch?v=v9Lyydrp-jo

As you can see, the Groundbot is quite responsive, and sometimes overshoots the 9-inch target. Next step is to add Derivative control to dampen the overshoot.

Since the video, I attempted to clean the IR range sensor noise with a 4th order butterworth filter. It seems to help with jitter. Even a running average helps. The butterworth filter should help derive a clean velocity term for the PD-controller (Proportion & Derivative control).
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

It works very nicely. I am not sure that derivative control is your answer. I am no PID expert, but there is pretty well damped oscillation of the position. To reduce oscillation, you may need to reduce the P factor.

Have you read sources on how to tune PID loops? One I read, as I recall, says just start with P (the I and D factors are zero). Increase P until it starts to oscillate, then back off until the oscillation is gone.

What you have then is a decent control already, but you will have some offset from the desired set point when it stops. Then you start to add I until it reaches the desired setpoint.

It looks as if you have an interest in FAST response. In that case, D may be necessary, but D is typically pretty noisy and can cause more problems than it helps. Maybe some oscillation is inevitable, but I think you can do better.

Also, do you use a dead zone? How precise do you need your positioning? Use a dead zone as wide as reasonably possible so that you are not constantly trying to drive the motors to make tiny adjustments.

-Tony
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

Post by liam.zbasic »

The Ground-Bot deadzone is set at 0.25 inches. My goal is to achieve the fastest response possible while minimizing the overshoot oscillations. For others, see video below:

http://www.youtube.com/watch?v=v9Lyydrp-jo

I could mitigate the oscillations by increasing the deadzone or reducing the P-control gain. My goal however is to keep the deadzone at 0.25" or smaller and achieve the fastest reponse possible to turn the Ground-Bot 90degrees and have it balance on its two wheels. So I need to include D-control (i.e., feedback velocity). I added a 4th order butterworth filter with a 24Hz cutoff to clean the position signal and use that to calculate velocity. Stay tuned.

The Ground-Bot uses the GP2D12 (4" to 30" range) for horizontal control. For balancing on two wheels, I plan to use a single GP2D120 (1.5" to 12" range) for the best resolution among the Sharp IR range sensors. Given translational position & rate using methods with horizontal control, I can calculate angular rate. As you pointed out, noise will be the main challenge.

Thanks for your interest and comments.
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

Well, it is easy enough to calculate the derivative, and easy enough to incorporate the D term in the PID control given that you already have PI control. Not so easy is tuning, but it is pretty easy to see the results of your tuning.

It may be that with your filtering of the sensor readings, the D term will not have excessive noise. I will be interested is seeing how much the D term helps!

-Tony
stevech
Posts: 715
Joined: 22 February 2006, 20:56 PM

Post by stevech »

liam.zbasic wrote:Here's a video of my project (link below). It's a simple Groundbot that tracks an object an maintains a fixed distance (9"). It uses the ZX-40A mcu. Control is achieved with a simple P-controller using distance feedback from two Sharp IR range sensors (GP2D12). The calibration is based on an Arctangent fit, not a typical 5th order polynomial to save floating point calcs. The ZX-40A sends two PWM signals to the motor driver (Pololu VNH2SP30), which in turn controls two motors (Tamiya 72101).

http://www.youtube.com/watch?v=v9Lyydrp-jo

As you can see, the Groundbot is quite responsive, and sometimes overshoots the 9-inch target. Next step is to add Derivative control to dampen the overshoot.

Since the video, I attempted to clean the IR range sensor noise with a 4th order butterworth filter. It seems to help with jitter. Even a running average helps. The butterworth filter should help derive a clean velocity term for the PD-controller (Proportion & Derivative control).
Wow. Impressive. Way harder to code that it looks.
liam.zbasic
Posts: 163
Joined: 24 March 2008, 23:33 PM
Location: Southern California (Blue)

IR Sensor Noise!

Post by liam.zbasic »

The Sharp IR Range sensor (GP2D12) distance signal is very noisy. I added a 4th order butterworth filter to improve the reading. The P-control is now very smooth. However, when I calculate velocity from filtered distance for PD-control, velocity is still jittery.

Before increasing the butterworth filter order, I revisited the breadboard and experimented with different capacitors. I originally followed the zbasic suggested circuitry. Then I added 10uF filters at the IR sensor power source per Sharp's datasheet. I replaced them with 100uF versions, and that improved the IR sensor reading. Then I used a single 1,000uF capacitor, and that works extremely well. Question... is there a danger to the ZX chip with such a capacitor? Any danger with higher capacitance?

Thanks.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: IR Sensor Noise!

Post by dkinzer »

liam.zbasic wrote:Question... is there a danger to the ZX chip with such a capacitor? Any danger with higher capacitance?
A large capacitance value on the supply rail poses no danger to the ZX chip. Generally speaking, the more, the better.

There could be an issue with your regulator circuit though. The regulator manufacturers typically suggest a diode across the regulator (anode to output, cathode to input) to protect the regulator in cases when the capacitance on the output side is greater than that on the input side.

An example of this type of connection is shown on the second page of the schematic of the ZX-1281 Development board.
http://www.zbasic.net/doc/ZX-1281_DevBoard/
- Don Kinzer
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Re: IR Sensor Noise!

Post by spamiam »

liam.zbasic wrote:However, when I calculate velocity from filtered distance for PD-control, velocity is still jittery. .
Well, that is the noise in the "D" term I was talking about. While it is possible to filter this value, then you lost the responsiveness of this value to changes.
Then I added 10uF filters at the IR sensor power source per Sharp's datasheet. I replaced them with 100uF versions, and that improved the IR sensor reading. Then I used a single 1,000uF capacitor, and that works extremely well. Question... is there a danger to the ZX chip with such a capacitor? Any danger with higher capacitance?
No trouble at all, as Don said. The need for such dramatic filtering makes me wonder where the noise is coming from? Is it the motors? Maybe an inductor on the sensor and ZX power could help a little too. Maybe you can do something about the noise at the source. To some degree, lower ESR values on the capacitors can improve their ability to maintain voltage. Electrolytics tend to have higher ESR. Often people use a combo of lower capacitance , low ESR caps, in parallel with higher capacitance electrolytics.

Are you finding the "D" term to be of any use?

Are you using any "I" term? If so, are you familiar with Integral wind-up? If it is happening, it will contribute to oscillation. I usually prevent wind-up by limiting the value of the "I" term. I usually try to calculate the maximum "I" value that by itself will cause maximum control output in the high and low directions, and clip the "I" term to that value. Of course there are more complex schemes that use adaptive control on the 'I' term to get better control of the windup. I.E. clip "I" to a value such that you do not saturate the control output. If clipping occurs, then you are running relatively more "P" and less "I" than in a non-saturated condition. This is usually OK because if you are trying to saturate the control output, then "I" isn't really helping at all. "I" is mostly useful for the situation where you are pretty close to the desired setpoint, and need a little fine tuning to compensate for any offset.

When I describe PID control to people, I often use the example of adjusting your shower temperature. People actually DO use PID control for this application, they just don't realize it. But when someone flushes the toilet, then you sure learn to use the "D" term pretty quick!!!

-Tony
Post Reply