Readadc values changed by state of outputs 08M

Dr_John

Member
Background
I'm trying to read a gyro chip and integrate the values to give "angle turned" fo a robot.
This is done on a dedicated 08M chip, and I wish to signal the angle to the main Picaxe chip.
I output the angle as 3 output levels on 3 output ports which are currently driving LEDs.
The sensor chip is run from a 9v battery and a 7805 regulator

Problem
The zero-rotation voltage reading from the gyro changes depending on the number of outputs,
and which outputs are active.

Current solution
I use pulseout on a single output, which works reasonably well (90 degrees drift in about 1-2 minutes)

Questions
a) will it work better if I use the internal Vref of an 08M2?
b) if I use DACLEVEL to output the reading will the adc suffer the same problems?
Thanks
John Fisher
(Pulse out Code attached)
 

Attachments

Goeytex

Senior Member
The problem is almost certainly related to supply / grounding issue(s).

Using internal VREF or DACLEVEL will probably not help and may only compound the problem.

1. What size resistors are limiting current from the Picaxe to the LEDS?
2. What size bypass capacitor(s) are you using for the Picaxe and other chips?
3. Is this on a breadboard or a soldered up PCB ?
4. Is the wring neat or does it look like a bowl of spaghetti ?
5. Did you place a bulk/storage capacitor on the board?
6. Do you have a scope ?

As Armp requested, please post an accurate schematic diagram and a clear closeup photo of your project so that folks can check the circuit for potential problems.
 

Dr_John

Member
The circuit

The problem is almost certainly related to supply / grounding issue(s).

Using internal VREF or DACLEVEL will probably not help and may only compound the problem.

1. What size resistors are limiting current from the Picaxe to the LEDS?
pretty sure 330 ohms

2. What size bypass capacitor(s) are you using for the Picaxe and other chips?
1000uF (on another board which is supplying the 5volts)
no local HF capacitors

3. Is this on a breadboard or a soldered up PCB ?
soldered PCB

4. Is the wring neat or does it look like a bowl of spaghetti ?
pretty neat - but a ribbon cable from the 5v supply 15cms long

5. Did you place a bulk/storage capacitor on the board? gyro_cct.GIF
see 2

6. Do you have a scope ?
yes 10mhz telequipment 1968 vintage.

I have posted the circuit.

======================
to repeat: the PIC chip readadc command gives different values (using debug) which depend of which combination of output LEDs are lit.

when testing this,
6 combinations of LED output were used, with the values recorded in different W registers,
before a final debug to output them all
----------------------------------

I'm looking to see if there is already a KNOWN interaction between the ADC parts of a PICAXE chip and the output levels (when driving LEDs). Much as there is a known interaction between the readadc and the use of V24 download leads.

John F
 

Goeytex

Senior Member
Hi John,

First thing .... There needs to be a 100nf bypass capacitor directly across the Picaxe supply pins or a close to the pins as possible. This is not really optional when expecting stable ADC readings.

Unstable readings are almost always related to supply variations . Supply variations can be caused by lots of things. Logical deduction points to the current drawn by the LEDs causing the Picaxe Supply voltage to droop enough to offset the ADC reading, with the offset amount being related to the number of LEDs that are on.

The Power supply cable being 15cm might suggest the need for a bulk capacitor on the 5V rail somewhere near the Picaxe. 100 to 200uf (25v) should do fine.

Might I suggest you connect a good quality DVM on the 5v supply near the Picaxe and measure the voltage with various combinations of LEDs on. Then do the same thing on the ADC pin. My guess is that the voltage is changing on one or the other. (Looking for millivolt differences).

I'm looking to see if there is already a KNOWN interaction between the ADC parts of a PICAXE chip and the output levels (when driving LEDs).
Not that I am aware of. However precautions must still be taken, such as the bypass cap, et al)
 

Dr_John

Member
Thanks Goeytex
Yes I suppose I should do a bit more hard work myself, ensuring that Power voltage at the PIC is stable. - I have a DVm with 10mv accuracy.
I did check the Gyro output and it is Rock Solid. (it has a further regulator to 3.3v).
I will measure a) the Gyro output, and b) the PIC power supply voltage with all combinations of LEDs

Thanks Guys - It helped just getting a second/third opinion.

I will let you know how I get on.

Cheers
John F
 

g6ejd

Senior Member
Have you disconnected the LED to see if the problem persists?
Use your scope to see if the supply is varying under load.
Fit a large bypass C across the local board.

I did not check your code, but is this a real effect or are you seeing variations in your variable values, I wounding if hy are all independent or not.
 

Armp

Senior Member
Problem
The zero-rotation voltage reading from the gyro changes depending on the number of outputs,
and which outputs are active.
6 combinations of LED output were used, with the values recorded in different W registers,
By how much does the voltage change? Please give the readings for each combination

Where does 'analgue out' go?
 

Goeytex

Senior Member
While bypass / filter caps are still appropriate, another approach for more stable ADC readings is to replace the 08M with an 08M2.

Then with the 08M2 the ADC can be configured to use an internal voltage reference that is not affected by small changes in the Picaxe supply voltage. See the ADCCONFIG and FVRSETUP commands in Picaxe Manual 2.
 
Last edited:

PADJ

Member
Much as there is a known interaction between the readadc and the use of V24 download leads.
As a newbie can someone tell me what are V24 download leads and the interaction?
 

eclectic

Moderator
From post #1
" 9v battery and a 7805 regulator "

A PP3?
In what condition?

Can it cope with the current demands?
I genuinely don't know the answer.

e

Addit.

How old is the 08M?

What firmware version?

The very early 08M series were modified re. ADC
 

Goeytex

Senior Member
Eclectic raises a good point. A 9V battery and a 7805 regulator is not a very good combination. Without a somewhat large capacitor on the regulator output, the transient response will be pretty dismal You would be better served by using a Low Dropout Regulator (LDO) that is not so power hungry. The LP2950 is popular where very tight regulation is needed.
 

Dr_John

Member
08M2 to the rescue!
===============

I now have a working system. I'll now report the salient facts for all those who are interested:
a) I measured the +5volts to the PIC chip under various conditions of load.
- No LEDs on : 4.97 volts
- 1 LED (didn't matter which) INCREASED by 1 mv
- all 3 FEDs Increased by 2mv
b) The readadc10 value from the gyro under the 3 conditios above
- 462
- 462 (sometimes 463)
- 463

I then used the 08M2 option of referencing the internal VREF to run the adc. I used the 4.096 volt option.
result:
- 558 regardless of the number of LEDs on.

this resulted in a steady gyro angle reading, regardless of the LED state.

HOWEVER, in place of the crude 3-bit external DAC that I had constructed, I'm now using the DACOUT ability of the 08M2.
This allows me to send 32 different ponts of the compass to the main PIC chip.
This result can be read very quickly by the main chip, (rather than waiting for the next pulse - as in the pulsout soltion above)

Thanks to GOEYTEX for helpful suggestions (ADCCONFIG and FVRSETUP)

So I am now well pleased.

Dr J

Extra info:
The final solution use a lithium-ion camera battery (1000mAh 8.4V) and a re-used 7805 regulator.
No bypass capacitors.
the current consumptions are as follows:
7508: 5mA
Gyro circuit board : 25mA
Pic chip : < 1mA
LEDs (when all on): 30mA (I no longer use the LEDs)


===========================
PADJ: "As a newbie can someone tell me what are V24 download leads and the interaction? "
V24 download cables are the older style download method that uses the computer's inbuilt serial connection.
(usually a 9-pin D-Type connector)
(as opposed to the USB download lead commonly used today).
The V24 signal from the computer is + or - about 12 volts. This is prevented from going negative at the PIC
input by its protection diodes. This in turn upsets the ADC reading circuitry.
A solution is to use the "enhanced download circuit" which uses a schottky diode to protect the pic chip externaly.
 

John West

Senior Member
Your final solution should have bypass capacitors. Just because the circuit works now in your workshop doesn't mean it will work anywhere else in any other circumstances, and there are a lot of other circumstances in this world. This appears to be the most prevalent problem for PICAXE hobbyists, and I'm not sure why. The docs are quite clear about it.
 

Dr_John

Member
Agreed:
This version without bypass capacitors does demonstrate that use of ADCCONFIG and FVRSETUP provides a sufficiently stable
ADC voltage reference for use with an electronic Gyro which requires sub-millivolt repeatability,
even without bypass capacitors, and even with 10mA LEDs being driven by output ports.

Well done 08M2

A final, final version would have capacitors.
 
Top