picaxe 08M ADC

matt2466

Member
Hi everyone its been awhile...

I'm experiencing this problem with the ADC function in the 08M. I have created a Data Acquisition circuit to sample ECG signals and I wanted to use the readadc10 command to convert the ECG's analog signal into a digital form and have it plot out by a plotting program.

I've used the oscilloscope to ensure that the Data Acquisition circuit is indeed able to sample the ECG's analog signal (1Vpp after amplification). However, the digitized output from the 08M does not seem to allow my program to plot out a similar waveform but instead I get "spectrum-like" signals. The plotting program and picaxe code i'm using is tested to be working on another Data Acquisition design.

I've included my code for sampling the ECG signal.

ECG_Mode:
readadc10 2, w0
sertxd (w0)
goto ECG_Mode


Appreciate any feedback you guys may have.
 

gbrusseau

Senior Member
When using the debug command or sertxd command to output 10 bit numbers, the electrical
connection to the computer via the serial download cable may slightly affect the
ADC values. In this case it is recommened that the ‘enhanced’ interface circuit is
used on a serial connection (cable AXE026, not required with USB cable AXE027
as this uses 5V logic anyway). The Schottky diode within this circuit reduces this
affect.
 

Michael 2727

Senior Member
Note what what was said above -

And
An ADC (Picaxe) Sample is voltage dependent on the supply that is used to power the
picaxe.
E.g. -
If the Picaxe supply is 5V the readadc input range (Full Scale) is 0V to 5V.
If the Picaxe supply is 4.2V the readadc input range (Full Scale) is 0V to 4.2V.
If the Picaxe supply is 3.5V the readadc input range (Full Scale) is 0V to 3.5V.
You can always use a voltage lower than the supply but you will never get a
full scale reading/output value. (0 to 255) Edit: or (0 to 1023) if a W variable is used.
Never use an input voltage above the supply voltage used
(I think the MAX is around 0.3V above or below Supply on any pin)

Which comes back to your original quote
the ECG's analog signal (1Vpp after amplification).
If you only have a 1Vpp input signal and using a 5V Supply, the MAX value you could expect
would be 0 to 51. You may want to amplify the 1Vpp to 4.7Vpp for better resolution.
But don't overload the Picaxe Input, you could use a 4.7V Zener for protection etc.

P.S. I hope any device you have connected to yourself is Opto Isolated from any
supply above a 9V PP3 battery etc.
 
Last edited:

gbrusseau

Senior Member
Michael 2727, Since matt2466 is using READADC10 at 10 bit resolution, zero to one volt on the ADC10 pin would give W0 = 0 to 204; right?
 

matt2466

Member
Thanks for the reply guys.

I'm using a 5V DC supply to power the 08M. So in order for me to get the maximum range of 0 to 1023, I need the input signal to be analog 5Vpp?

As mentioned, I was able to get a nice plot with a digitized 1Vpp signal on another hardware. However with this new data acquisition circuitry which also produces a 1Vpp signal, the plot I get is totally off.

It got me thinking if whether it could be a faulty 08M or whether there is a synchronization problem between the data acquisition part and the 08M since the amplifiers have their own internal clocks.
 

boriz

Senior Member
1V Peak to Peak. AC?

So assuming the signal ground is connected to Picaxe ground, the Picaxe input only sees the top 0.5v of the signal and the rest is –ve.

You need to level-shift the AC signal to the middle of the Picaxe ADC voltage range, about 2.5v.

A simple frig would be to use two 100R resistors as a divider. Bottom end at 0V, top end at Picaxe Vcc. Then use the junction as the signal ground for your AC signal. Careful NOT to connect the signal ground to the Picaxe 0V.
 

MFB

Senior Member
In order not to load the 5V supply and the signal source, the potential divider at the ADC input could use resistor values of up to 10K. This would also mean that a smaller input coupling capacitor could be used for a given low requency cut-off.
 

hippy

Ex-Staff (retired)
sertxd (w0)

Neither SERTXD nor SEROUT can send 16-bit / word variables. Only the lower 8-bits are sent. To send a 16-bit value it has to be sent in two 8-bit pieces ...

SerTxd( b1, b0 )
 

gengis

New Member
Peak to peak implies a zero reference and positive and negative from zero. 1V p/p is a 1/2 volt above and below ground. The picaxe will only see the positive portion of the signal.

You may also have to deal with "aliasing." Whenever you digitize a waveform you are sampling it at specific intervals. If the signal is changing rapidly, your sample point can come anywhere along the slope of the signal.

Unless your sample rate is much higher than the rate of change, you will only see what the signal was at discrete intervals in time, and you won't be capturing a "wave form."

The frequency of the ECG is low - but so is the picaxe's sample rate.

This becomes especially problematic if there's noise or a ground loop imposed on the signal of interest. There's a lot of information on the web about aliasing and ADCs.
 

boriz

Senior Member
...assuming the signal ground is connected to Picaxe ground, the Picaxe input only sees the top 0.5v of the signal and the rest is –ve.

You need to level-shift the AC signal to the middle of the Picaxe ADC voltage range, about 2.5v..
! !
 
Top