Servo and ReadADC10 problems

gdenehy

Member
I have a servo connected to my picaxe.
I am using readadc10 to check the value of a thermistor.
I have 2 of these boxes separately, but with the same power supplies.
The power for the servo is a different plugpack than the picaxe.

When the servo moves, the values on the ADC change.
This happens to both picaxes even if the servo being moved is not conencted to that picaxe.

I have the usual capacitors on the 7805 and picaxe.

The servos are quite large. There are no capacitors on the servos.
It is possible that the plugpack driving the servos is not really big enough for them.

Also, my AXE033 LCD dims when the servo moves.

Suggestions? Or is it as simple as giving the servo more power. If so, why would this affect the picaxe??
 

BeanieBots

Moderator
If the AXE033 is also dimming, your 5v supply for the PICAXE would appear to be collapsing. The value returned by ReadADC10 is a fucntion of the supply rail voltage so any change will be noticed in the reading.

Are you absolutely sure that the supplies are seperate?

If they are, then check your 0v routings. The servo current must not flow down the same 0v wires as those used by the AXE033/PICAXE.

A 7805 is close to it's limit for running even a single servo, however, even if it completely collapsed, if the supplies are truely seperate, the ADC reading would not be effected and the AXE033 would not dim.

What happens if you turn off the servo supply?
 
Last edited:

gdenehy

Member
*** If they are, then check your 0v routings. The servo current must not flow down the same 0v wires as those used by the AXE033/PICAXE. ***

What do you mean by this? All the 0V lines are connected together as per the manual...
Dont they need to be???
 

BeanieBots

Moderator
Yes, they must be connected together but the servo current must not flow down the same WIRE as the wire used to supply the PICAXE.

There is a big difference between a circuit diagram and a layout diagram.
To help to get your head around it, consider EVERY wire connection as a resistor. When the servo pulls a large current (about 1A typ.), consider what happens to the voltage seen at the PICAXE pins due to the resistor volt-drops.
You must wire it (same circuit diagram) such that the PICAXE sees NO volt-drops on its pins.
 

BeanieBots

Moderator
The term is known "star point".
A google search might reveal a good explanation.

Consider for example a 0v wire which comes from the battery, goes to the PICAXE 0v pin, then goes to the servo.
The servo pulls current from its own power supply.
The servo power supply 0v is connected to the PICAXE power supply 0v at the battery terminal.
When current flows in the servo, there will be a volt-drop down the 0v cable to the servo. The PICAXE 0v pin is half way down that cable so its 0v pin is no longer at 0v.

However, if the PICAXE pin was wired direct to the PICAXE battery 0v AND the servo 0v power supply was connected to the same point AND the servo 0v connection was also connected to the same point, the servo current would NOT cause the PICAXE 0v pin to go up in voltage.

A similar approach needs to be taken with the +Ve supply wires as well.
 

QuIcK

Senior Member
Err, if this is the case, its called a ground loop.
essentially, the voltage across the ground wire varies in different positions. this sounds like its being caused by the servo dumping "dirty" electricity to ground.

use a star-network for ground. i.e. connect your servo's ground and +5v lines directly to your 7805, using different wires than the ones going to your picaxe.

also, as the LCD is diming, might be worth using a 1A regulator. Perhaps also some decoupling/smoothing capacitors over the servo, to give it a bit more instant electricity.

beaten to it:rolleyes:
 

gdenehy

Member
Will look it up.
Why do I need a 1A regulator for the picaxe? Or do you mean for the servo?
I am just using a regulated plugpack directly for the servo, no regulator on it
 

BeanieBots

Moderator
You MUST use a regulator for the PICAXE if it is driven from a plug-pack.
You risk damage to the PICAXE and/or AXE033 without one.

A servo will pull around 1A at startup or if stalled.
If your circuit is wired correctly, even if the servo supply completley dies, your PICAXE and AXE033 shouldn't even notice.
 

gdenehy

Member
Looked up star ground and it looks like I have done this???
I have attached the board drawings.

The Master Box has a 12v supply coming in and a regulated 4.5v (which I am using as the ervo's 6V)

The outs of the Master box connect to the Ins of the Slave box.
I have 2 slave boxes connected to the master box.
 

Attachments

Andrew Cowan

Senior Member
What current is the powerpack rated for?

I had this problem when using a 300mA 9V powerpack and twin regulators.

Switching to a 1.5A 9V powerpack fixed the problem.

A
 

gdenehy

Member
The 12V supply is 1.8amp
I am not certain what the 4.5v supply for the servos is... Probably not big enough, but it drives the servos so it shouldnt affect the picaxe?
 

gdenehy

Member
Would it make more sense to have a 5V regulator in front of each picaxe rather than 1 regulator feeding multiple picaxes?
A stable ADC is very important for this application.
 

BeanieBots

Moderator
Depends on a lot of things.
You would need to refer to the details in the datasheet of your chosen regulator and have a good understanding of the current paths in your circuit.

Things like load and line regulation will be important factors.
Also, temperature coefs of Vout for the regulator.

Don't forget, a regulator is NOT a precision voltage source but most are adequate for 10-bit resolution references.
Good decoupling at both the regulator and PICAXE are essential. You don't want to take an ADC reading at the same time an internal switching spike causes a dip in the power rail. Equally, check to see how much the regulator output will change by when (for example) an LED is turned on.

Also, make sure you use the enhanced download circuit if you are relying on consistant readings with/without the programming cable attached.

Above all, reliable consistant analogue measurements depend heavily on circuit layout as much as circuit design.

Post your circuit and we can probably give better (more detailed) advice.
 

jglenn

Senior Member
What they are talking about is the wiring between the board you showed, the power supplies, and the servos.

It is critical to separate dirty grounds from clean grounds, that is, do not "daisy chain" them. Dirty grounds are the returns from motor driver circuits, clean ground is the one going to the board, if it just has the chip.

Run one ground from the servo and it's driver if there is one directly to the ground pin of the power supply cap. Run another separate wire from the picaxe board to the ground pin of the power supply cap. If you have separate power supplies for the servo's and board, still route the returns this way, but tie the supply grounds with another wire. Keep these all as short as possible.

And run the V+ lines adjacent to the grounds, or in twisted pairs, in the same manner. This will reduce "loop area" which increases EMI problems. :D
 

gdenehy

Member
I just connected the servo ground directly to the ground of the servo power supply, but now when I use the squiter (called Sqrt+ and - on the circuit), the servo moves! Whats going on????
Surely on the servo the black wire is GND, the Red is +6V and White is the control signal???
FIXED after changing another groundloop.
 
Last edited:

BeanieBots

Moderator
Would EMI be a problem just on the wires powering the picaxe???
Yes.
The issue works both ways.
A single wire carrying high noisy currents radiates EMI.
A nearby single wire carrying little or no current, picks up that EMI and becomes noisy.

By making both a twisted a pair, you reduce both the emission AND the likelyhood of picking it up.
 

gdenehy

Member
I seem to have most of the problems sorted now, but my ADC values are still drifting around slightly. They need to be pretty accurate.
How can I make the power supply for the picaxe VERY stable so that the ADC is fine?

Although the ADC input is a thermistor and voltage divider, coming from the same power rails as the picaxe, so wouldnt it balance out?
 
Last edited:

hippy

Ex-Staff (retired)
There will always be some point where an ADC voltage is exactly on a boundary of one reading and another and the smallest of voltage changes can switch it between the two. Single lsb errors should be expected.

Even when everything derives from the same power supply and should remain constant it is possible that any interference may affect one thing and not the other.

Even in a 'perfect circuit' there may be discrepancies; an ADC reading the PICAXE supply would be expected to give a consistent reading but as the electrical paths ( resistance, capacitance, etc ) differ between internal chip and externally supplied source you may get incorrect readings.
 

Dippy

Moderator
When ADCing always:-
1. Check the ADC with a very stable input. Your simple res/thermistor pot.div may wobble slightly, esp if in breadboard or if near something electrically noisy.
2. Good supply to PICAXE - obvious really eh, but many forget.Unsuitable capacitors on the regulator can produce oscillations/noise. Causes unstable ADC results.
3. Good decoupling at PICAXE power pins. The ADC reference must be dead smooth. A ceramic 47nF right next to +/gnd pins recommended.

I've messed up with all the above in the past. If everything dead cean, dead smooth and dead stable you should be able to get better than 3 in a thousand ADC consistency for most of the range.
 

BeanieBots

Moderator
Also, what is the TOTAL resistance that your thermistor/resistor potential divider offers up to the ADC input?
It must be < 20k for reliable readings.

You can calculate it as follows:
RT=Thermister resistance (whatever it's maximum is over your temperature range)
RP=The resistance of the resistor that makes up the POT.
RZ=Resistance seen by ADC input.

RZ=RT*RP/(RT+RP)

If it's > 20k, then fitting a 100nF capacitor between ADC input and ground will help but reducing RP would be better. However, that would also reduce the overall sensitivity. The only other alternatives are to use a different thermister and/or buffer with an op-amp.
 

QuIcK

Senior Member
is that 240v AC on a veroboard?:eek: I wouldnt trust veroboard for that, personally.
But Ive always been a bit rubbish at colouring inside the lines. Same applies to my soldering technique:rolleyes:
 

BeanieBots

Moderator
Oh err mum!

OK to have it on strip-board but I'd like to see adjacent tracks removed and multiple whole cuts after the final connection to feel safe with it.
 

hippy

Ex-Staff (retired)
is that 240v AC on a veroboard?:eek:
I've put mains on veroboard ( PCB mount transformer ) and the tracks are quite thick but everything has a rating, so suitability depends on current.

Key to safety is not to just cut tracks but to entirely remove all copper anywhere it isn't used and make sure there is a large boundary between the live, neutral and earh and other electronics or wiring.

Best if it can be a separate board, in its own case, better still, don't do it.

Connecting mains to the board has to also be done safely. Veroboard holes are quite small, wires pushed through them may snap off under adverse conditions or through wear. Best to use ferules or proper mains rated interconnects.

Mounting the board also requires it's kept the right distance from any conductive casing.

I cover top and bottom with thick insulating tape and make sure there is insulating plastic underneath.

An essential item is a mains indicator on the board which shows when it's live. I use small neon bulbs. It's easy to forget there is mains or that it's powered on and that can be fatal.
 
Top