Author Topic: Questions pertaining to reading analog voltages using the axon microcontroller  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.

Offline Its_FridayTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
I'm using the axon microcontroller to read voltages of a circuit. I made a voltage divider that takes an input voltage and divides it by 2000 +- 1% so that the output voltage lies between 0 and 5 volts. I'm going to calibrate the output so it gives me a better estimate.

My first question is: How accurately can the axon microcontroller read volts? I'm looking for 0.01+- volt accuracy.

I was looking through the sensor.c file and found this function:
Code: [Select]
//Voltage Sensor
int voltage_phidget(int value)
{
return ((value - 500) * 0.06);//returns in volts
}

Second question: Does this function return a double, float, or int?

Third question (kind of stupid): Am i using this function correctly?

Code: [Select]
int voltage; //(should i use int? or maybe double? float?)
voltage=voltage_phidget(a2dConvert8bit(1)); //should i use voltage_phidget(a2dConvert10bit(1)) instead?
if (voltage > 2.45) {do stuff}

Fourth Question(unrelated to programming): I'm finding the voltage of a circuit that is anywhere from 0 to 10,000 VDC. To get an accurate reading, should i hook up the negative lead of the circuit to the ground pin of the axon microcontroller so that they share a common ground?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
First, I'd be leary about getting 10kV near a processor circuit.

1- The ADC resolution depends on its reference voltage and the number of bits in the conversion.

If the ADC is 12 bit and Vref is 5V then the resolution is 5V / (2^12) = 0.0012 Volts per bit. But since the voltage you wish to read is divided by 2000 then the ADC res is 2000 *  0.0012 = 1.2 Volts per bit.

2- The function returns an int by its definition (the int in front of the function name is the return type). Doesn't make sense to me, I would think to should be a float. Hope some one else knows this.

3- ?

4- Yes, the source voltage you are measuring with the ADC must be referenced to the ADC's ground (Axon's ground).

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Quote
My first question is: How accurately can the axon microcontroller read volts? I'm looking for 0.01+- volt accuracy.
It really depends on your hardware, and how stable your signal is. Hook up an oscope to measure your signal, and then see how the Axon matches that signal. If your signal oscillates wildly, you'll need to add filter caps.

In theory, with a perfectly stable signal and zero noise, the Axon can measure as low as 10 bit.

5V/2^10=0.00488 V

and for 8 bit:
0.0195 V

Quote
I was looking through the sensor.c file and found this function:
Code: [Select]
//Voltage Sensor
int voltage_phidget(int value)
{
return ((value - 500) * 0.06);//returns in volts
}
Second question: Does this function return a double, float, or int?
hmmmm you just found a bug . . . it should be returning a float. I've never actually tested this code as I don't have any Phidget devices, so it might still not be correct. Let me know.

in sensors.c, look for
Code: [Select]
int voltage_phidget(int value)
{
return ((value - 500) * 0.06);//returns in volts
}
and change it to
Code: [Select]
float voltage_phidget(int16_t value)
{
return ((value - 500) * 0.06);//returns in volts
}

I took the conversion equation from this datasheet:
http://www.robotshop.us/PDF/Phidgets-Sensors.pdf


Quote
Third question (kind of stupid): Am i using this function correctly?

Code: [Select]
int voltage; //(should i use int? or maybe double? float?)
voltage=voltage_phidget(a2dConvert8bit(1)); //should i use voltage_phidget(a2dConvert10bit(1)) instead?
if (voltage > 2.45) {do stuff}
It should be a2dConvert10bit(1). Make voltage a float.

Quote
Fourth Question(unrelated to programming): I'm finding the voltage of a circuit that is anywhere from 0 to 10,000 VDC. To get an accurate reading, should i hook up the negative lead of the circuit to the ground pin of the axon microcontroller so that they share a common ground?
Normally I'd say yes, as all grounds should be common . . . but 10kV is a lot! I'm a bit worried about static or something frying the Axon if anything goes wrong. I recommend Googling around to see if other people have done the same thing, maybe there is a better way than a voltage divider (I've never worked with high voltages).