PICAXE 12f683 ADC problem

Malcontent

New Member
I am using a 12F683 to log a charging capacitor and I am seeing glitches as shown in the attached picture.The code is in Basic as below.main: readadc10 1 ,ADCInput_4 Voltage_1 = ADCInput_4 * 50 Voltage_2 = ADCInput_4 * 3 High1 = Voltage_1 / 10000 Volt1 =High1 * 10000 Low1 = Voltage_1 + Voltage_2 - Volt1 Outputvolts = High1 * 10000 Outputvolts = Outputvolts + Low1 'sertxd(#W1,",",13,10) sertxd(#High1,".",#Low1," ",13,10) goto mainWhat is causing these changes in readings?Any help would be appreciated.Malcontent
 

Attachments

Svejk

Senior Member
Here is the example code formated:

Code:
main: 
  readadc10 1,ADCInput_4 
  Voltage_1 = ADCInput_4 * 50
  Voltage_2 = ADCInput_4 * 3 
  High1 = Voltage_1 / 10000 
  Volt1 =High1 * 10000 
  Low1 = Voltage_1 + Voltage_2 - Volt1 
  Outputvolts = High1 * 10000 
  Outputvolts = Outputvolts + Low1 
  sertxd(#W1,",",13,10) 
  sertxd(#High1,".",#Low1," ",13,10) 
goto main
There is more than this example (variables definitions?) but it seems like some overflowing. I'd sugest to plot only the readadc10 value without any conversions to voltage.

PS: Welcome to Picaxe Forum.
 

MartinM57

Moderator
Always best to lay out your code so that it is readable (and to put all the code - there are presumably some SYMBOL definitions missing from here):

Code:
main:
readadc10 1 ,ADCInput_4
Voltage_1 = ADCInput_4 * 50	
Voltage_2 = ADCInput_4 * 3
High1 = Voltage_1 / 10000
Volt1 =High1 * 10000
Low1 =  Voltage_1 + Voltage_2 - Volt1
Outputvolts = High1 * 10000 
Outputvolts = Outputvolts + Low1
'sertxd(#W1,",",13,10)
sertxd(#High1,".",#Low1," ",13,10)
goto main
...then the problem is more obvious - the PICAXE (best to say which one, not the base PIC part number) only does integer arithmetic and your /10000 and *10000 are having a big error effect.

Spend some time with your code in the Simulator to appreciate what is happening

PS Welcome to the forum!
 

KeithRB

Senior Member
What is the capacitance and the charging resistance? The glitches are caused by the pin changing impedance during an ADC reading. You may need an op-amp configured as a high-impedance buffer.
 

hippy

Ex-Staff (retired)
I am using a 12F683 to log a charging capacitor and I am seeing glitches as shown in the attached picture.
It would be good to explain what the picture is of; actual voltages seen on the capacitor or ADC input, or what the PICAXE calculation produces.

I'd be tempted to go with KeithRB's analysis but the graphed behaviour doesn't reflect what I'd expect to see; if the raw cap voltage were being pulled down by an ADC read I'd expect the cap voltage to then climb from where it was pulled down to, not jump up to where it would have been having not been pulled down. It could happen that way if the voltage is buffered so the cap behaves as expected, the buffered output only is being pulled down, but then the varying length of pull-down period is very odd for either case.

A circuit of what you are using will help people get a clearer understanding of what you are doing.
 

Armp

Senior Member
.then the problem is more obvious - the PICAXE (best to say which one, not the base PIC part number) only does integer arithmetic and your /10000 and *10000 are having a big error effect.

Spend some time with your code in the Simulator to appreciate what is happening
Not absolutely sure what the OP is trying to do, but maybe something like this will be closer? (Haven't tried it)

Code:
main:

readadc10 1 ,ADCInput_4
Voltage_1 = ADCInput_4 * 49 /10	  ' Vcap 0 - 5V maps into 0-5012 

High1 = Voltage_1/ 1000    ' Get Approx  Volts
Low1 =  Voltage_1 // 1000   ' Get Approx mV

sertxd(#High1,".",#Low1," ",13,10)  

goto main
 
Last edited:
Top