Go Down

### Topic: Phidgets 1135 - Precision Voltage Sensor (Read 5863 times)previous topic - next topic

#### DanK

##### Feb 12, 2011, 09:51 pm
Greetings,

I've interfaced a Phidgets 1135 Precision Voltage Sensor to A0, via a GVS Shield on my Arduino Uno.

http://www.phidgets.com/documentation/Phidgets/1135.pdf

I'm getting a signal, though not appropriate to my voltage, as measured with DMM.

I've tried to apply the formulas in the manual above, but to no avail (though I'm no mathematician).

#### WillR

#1
##### Feb 12, 2011, 10:17 pm
"I'm getting a signal, though not appropriate to my voltage, as measured with DMM."

Saying something like "I apply 9V (a battery) across the input terminal of the Phidgets sensor and I get 3.13 V at the output of the phidget... is that correct?" -- is a lot more helpful...

Then if you hook the output of the phidget sensor to the Arduino you should get about 641 as the sensor reading on the Arduino -- that's what the arithmetic says ---

Does that help?
Just another Hacker

#### DanK

#2
##### Feb 12, 2011, 10:29 pmLast Edit: Feb 12, 2011, 10:32 pm by DanK Reason: 1

9v battery attached to Vin+/- on 1135

Reading is 637 when connected from battery (1.85v sensor output)
Reading is 513 when disconnected from battery (1.24v)

I'm not sure what formula to apply as they all seem to give inappropriate numbers..

Hope that is a bit better..

#### WillR

#3
##### Feb 12, 2011, 10:36 pmLast Edit: Feb 12, 2011, 10:39 pm by WillR Reason: 1
That the world is unfolding as it should....

Please note how close you are to what I posted....

At 0 V (0 Difference the Phidgets produces 2.5V..

2.5V/5V == ~ 1/2

The arduino sensor ranges from 0 to 1024
0=0
5V=1024

Halfway Between (2.5V) is  surprise 512.

From the PDF

The Voltage Sensor measures the differential voltage between the input terminals and outputs the difference
proportionally. The maximum differential voltage that can be measured accurately is +/-30V. When the positive and
negative inputs are equal, the analog output value is 2.5V.
When the positive input is 30V greater than the negative
input, the analog output is 4.5V and when the positive input is 30V less than the negative input, the analog output is
0.5V.

The phidgets produces 2.5V when things are Zero (0V) volts difference between the leads   (512) on the arduino sensor....

If the Voltage on the phidget goes negative the arduino starts going towards oooo

If the voltage on the phidgets sensor is greater than Zero Volts (0V) the arduino starts to read greater than 512

Tell me! Are you surprised that you got it right on the first try?    I often am.... lol

Just another Hacker

#### WillR

#4
##### Feb 12, 2011, 10:39 pmLast Edit: Feb 12, 2011, 10:52 pm by WillR Reason: 1
OK I think I got all the spelling mistakes.

Just one other note....

The 4.5 max output from the Phidgets sensor does change things...

I used 5V to keep things easy...

You could figure out a way to apply 4.5V to the external Reference pin for the analog and then maybe it would be exact.

A voltage divider... across the 5V

Here is the arithmetic for a 9V battery -- assuming exactly 9V

9v/30v = .3   so there is 512 units from 512 to 1024
so .3 X 512 = 153.6  (you just do a ratio calculation)

Now you ADD that to the 512 -- you are starting from halfway or Zero remember....

Now the correction since we are really dealing with a 4V swing.... or 80% of 5V

.8 * 153.6 = 122.8 or 123
we get 634

If it's a fresh battery it is probably better than 9V -- so no surprise that the reading is a bit high.

Hope that's even more clear.

Just another Hacker

#### DanK

#5
##### Feb 12, 2011, 11:17 pm
Thanks for the support and encouragement, I feel I've made it but not quite sure to where...

Recap:

 -30v 0v 30v Sensor Input 0 512 1024 Arduino Reading 0v 2.5v 5v Sensor Output

Float Voltage = 0;
Voltage = (60/1024 * sensorValue) -30;

Arduino doesn't seem to like 60/1024, so I can approximate to 0.0586

Voltage = (0.0586 * sensorValue) -30;

Though I'm getting 7.33v via Arduino vs 8.72v via DMM...think I'm missing something?  Should I be using float?  I'd like it to be as accurate as possible.

#### WillR

#6
##### Feb 12, 2011, 11:19 pmLast Edit: Feb 12, 2011, 11:34 pm by WillR Reason: 1
Here are the max min and mid point... and the resulting formulas -- I think lots of people see these problems so this is a good example...

Let's redo that a bit
(Because the range is actually from .5V to 4.5V)

.5 Volts on the arduino analog input == 102 Units on the Anlaog sensor reading (.5V/5V * 1024)

So 0 volts difference between the Phidget leads is 512.....

************
So far so good?

As we go from 0V to +30 Volts we will range from 512 up to 922 as read by the arduino...

Ok 922 -512 = 410 units

30Volts / 410 =~ .073 Volts per unit....

So therefore -->  9volts / (.073Volts/unit) gives -- surprise 123 units.....
So if we got 635 units (read by the arduino) then we got 9Volts on the input right?

So your voltage is always ....

(Arduino reading - 512) * 0.073170 = Volts on input....

And this preserves the sign correctly. It also keeps a few guard digits to maintain accuracy. It does not improve precision.

So if we take the 637 reading you got does it work?

637-512= 125 units  Multiply that by 0.073170 Volts/unit and you get 9.15 Volts -- does that agree with your voltmeter...?

Hook the battery up reversed on the leads and check the results. The formula should still work.

Just another Hacker

#### WillR

#7
##### Feb 12, 2011, 11:22 pm
I think you need a new voltmeter...

But you do have the idea.

My new post should put the nail in the coffin.
Just another Hacker

#### DanK

#8
##### Feb 12, 2011, 11:49 pmLast Edit: Feb 13, 2011, 12:08 am by DanK Reason: 1
Thanks again for all the help...

Using the following equation:

Voltage = (sensorValue - 512) * 0.073170;

Yields;

9v Battery: 9.15 (8.7 on MM)
5v Voltage Regulator: 5.34 (4.99 on MM)
No Input Voltage: .22 (.05 on MM)

Why is it reading anything?  Residual from power to sensor?  Is the discrepancy because I should have Vref of 4.5v?

#### WillR

#9
##### Feb 13, 2011, 12:33 amLast Edit: Feb 13, 2011, 12:43 am by WillR Reason: 1
Dan:

You now understand the difference between reality and science. Engineers deal in reality. Science is for people who can't handle reality, -- mathematicians, physicists and the like... everything works out in "physics land"  -- speaking relatively of course.

OK when you measure "Zero" connect the two input leads on the phidgets. Then there "should" be "Zero" difference -- in the Engineering sense where everything is expressed so:

The input was 0V +- .0001 V
The power supply was built to a tolerance of +-.01 volts using precision components of 1% tolerance...
The voltmeter is accurate +- 2.5% of full scale...
...and statements like that

Go to Sparkfun (.com) -- look up some sensors and read the data sheets... For the pressure and temperature sensors sometimes your head swims... See the BMP085 at Sparkfun for example... That is what I am working on today. The BMA 180 tomorrow...  :~

Get the idea?

**** When you add or subtract the absolute error (estimate or tolerance) adds absolutely...

**** When you multiply or divide the relative error adds absolutely.

Absolute error --> The output was 10V where I can measure to an accuracy of -.1v to + .2V volt of the value measured -- is a absolute measurement and error range.

Relative error --> I measure the output to be 9.41V where the meter was on a 10V scale with an accuracy of 2% of FULL SCALE.

So 2.25V (+-2%)  /  100ma (+- 5%) gives you what resistance?

where R = E/I (Or V/I) if you like... (Volts over amps)

I leave it to the interested reader....

Error analysis is a weird and wonderful topic.... Anytime you are in the analog world, think component and measurement tolerance and the above methods...

So why do the "meters" disagree? You tell me -- but first pull out the manual and check the accuracy -- which I bet will be given as a percentage (relative) of full scale.

The pull out the arduino specs for your processor and find the A/D conversion accuracy specification. Are they relative or absolute?

When a commercial product is designed you calculate all these possible errors (somehow) then you try to get enough measurements to verify that your calculations are correct.

Just for fun look up the SPICE design program for circuitry.

Go from there...

And I'm just joking about mathematicians -- I work in a branch where the only way you can solve a problem is develop a well thought out opinion of how to get the answer... see "NP" and "NP hard" if you care... Then you develop guestimates of how to do the calculations -- then you pray that your clients don't catch on... It has been called witchcraft not mathematics by some engineers I know. I work in both areas and can reconcile this easily. (see Doublethink)

BTW: You will get your propeller beany in the mail... just attach it to your hat!

Just another Hacker

#### DanK

#10
##### Feb 13, 2011, 01:02 amLast Edit: Feb 13, 2011, 01:26 am by DanK Reason: 1
OK...I think I understand...

That's just as good as it get's more or less...due to fault tolerance...

Incidentally, here is the code:

Code: [Select]
`/* * Volt&Amps * -------------- * Implement Phidget 1122 and 1135 sensors for volts and amperage readings * * Created 2/12/2011 * copyleft 2011 Daniel Kramer <Dank@LeviathanEnterprises.com> * http://LeviathanEnterprises.com/ */// These constants won't change.  They're used to give names// to the pins used:const int analogInPin = A0;  // Analog input pin that the Voltage Sensor is attached to.const int analogInPin2 = A1;  // Analog input pin that the Voltage Sensor is attached to.int VoltValue = 0;        // value read from the potfloat Voltage = 0;        // calculated Voltage from sensorValueint AmpValue = 0;        // value read from the potfloat Amps = 0;        // calculated Voltage from sensorValuevoid setup() {  // initialize serial communications at 9600 bps:  Serial.begin(115200); }void loop() {  // read the analog in value:      VoltValue = analogRead(analogInPin);   AmpValue = analogRead(analogInPin2);     // Voltage sensor measures from -30v to 30v with the resolution on the Arduino of 0-1024  // Volt sensor only has a range of .5v -4.5v making it 10-922, instead of 0-1024  // 922-512 = 410 & 30v /410 =~.073 Volts per unit  // 60 / 1024  Voltage = (VoltValue - 512) * 0.073170;  Amps = (AmpValue - 512) * 0.058594;  // print the results to the serial monitor:  Serial.print("Volts Sensor Reading: ");  Serial.println(VoltValue);            Serial.print("Voltage Reading: ");    Serial.println(Voltage);        Serial.print("Amps Sensor Reading: ");  Serial.println(AmpValue);        Serial.print("Amps Reading: ");  Serial.println(Amps);        // wait 10 milliseconds before the next loop  // for the analog-to-digital converter to settle  // after the last reading:    delay(500);                     }`

Go Up

Please enter a valid email to subscribe