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
I was looking through the sensor.c file and found this function:
//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
int voltage_phidget(int value)
{
return ((value - 500) * 0.06);//returns in volts
}
and change it to
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.pdfThird question (kind of stupid): Am i using this function correctly?
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.
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).