![]() ![]() |
Jul 23 2007, 06:27 PM
Post
#1
|
||||
|
Joined: 20-July 07 Posts: 16 |
Hello Everyone,
Using a voltage divider circuit one can "convert" a variable resistance into a variable voltage. A voltage divider is just two resistors in series connected between a voltage supply and ground. If R1 is connected to +5V and R2 is connected to GND then the voltage at the point between the two resistors (AI0) is: Vout = Vcc * R2 / (R1+R2) For U12 users this means: Vout = 5 * R2 / (R1+R2) Here is the circuit on a breadboard: In this setup, R1 is 50K ohms and my photoresistor is 50K ohms in darkness: V = Vcc * R2 / (R1+R2) = 5 * 50000 / (50000 + 50000) = 2.5 Volts Under the lamp my photoresistor can go as low as 1K ohms: Vout = Vcc * R2 / (R1+R2) = 5 * 1000 / (50000 + 1000) = 0.098 Volts If R2 is the photoresistor, the voltage will decrease with increasing light intensity. If you need an increase in voltage with decrease in light intensity then switch the positions of R1 and R2. Finally, call upon AI0 to tell you the voltage of the circuit: CODE >> [voltage overVoltage errorcode LabJack_idnum] = EAnalogIn( -1, 0, 0, 0 )
voltage = 3.6279 overVoltage = 0 errorcode = 0 LabJack_idnum = 0 -------------------- Drew Barfield
Physics and Computer Science Major University of North Carolina Wilmington |
|||
|
|
Jul 24 2007, 08:18 AM
Post
#2
|
|
|
Joined: 9-June 03 Posts: 7519 |
Great tutorial topics. I am sure these will be useful to many people, so thanks.
Note that the U12 input impedance is somewhat low, and this comes into play when using a voltage divider. The analog input impedance can be described as about 100 kohms, so if your source has a 50 kohm resistor in series there is going to be substantial error. See Section 2.1 of the U12 User's Guide. That Section gives a modified formula that can be used to account for the error, but since there are usually other sources of substantial error anyway (e.g. resistor accuracy), you might just want to do a calibration of the whole system on the particular U12 AI channel. The U3 & UE9 have much higher input impedance. See Section 2.6.3.6 of the U3 User's Guide for voltage divider information with the U3. |
|
|
Jul 24 2007, 12:28 PM
Post
#3
|
|
|
Joined: 20-July 07 Posts: 16 |
LabJack,
Thank You. I was required to use the 50K photoresistor because it is one of the components in my physics "directed independent study" (DIS). If I had the choice I would go with a 1K or 5K photoresistor and a like-valued counterpart for R1. -------------------- Drew Barfield
Physics and Computer Science Major University of North Carolina Wilmington |
|
|
May 25 2011, 10:33 AM
Post
#4
|
|
|
Joined: 27-April 09 Posts: 23 |
Could you recommend (or tell me how to figure it out) a voltage divider resistor to MOST ACCURATELY measure a variable resistor 0-500 Oms? I've tried two 6.8k resistors and I'm getting about 7 readings. I'd like to get maybe 20. I'm building a servo machine to move solar panels. Here is a picture of my variable resistor (soviet military) http://twitpic.com/52exh8, measurements I'm getting are:
Votage: 0 Votage: 0 Votage: 0 Votage: 0 Votage: 0.0048828125 Votage: 0.0048828125 Votage: 0.0048828125 Votage: 0.009765625 Votage: 0.0048828125 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.009765625 Votage: 0.0146484375 Votage: 0.0146484375 Votage: 0.01953125 Votage: 0.01953125 Votage: 0.01953125 Votage: 0.01953125 Votage: 0.01953125 Votage: 0.01953125 Votage: 0.01953125 Votage: 0.0244140625 Votage: 0.01953125 Votage: 0.0244140625 Votage: 0.01953125 Votage: 0.01953125 Votage: 0.01953125 Thank you for your support and a great product (U12)!!! |
|
|
May 25 2011, 12:34 PM
Post
#5
|
|
|
Joined: 9-June 03 Posts: 7519 |
Are you interested in measuring the actual resistance between the wiper (leg 3) and either leg 1 or leg 2? Or do you want the ratio between the legs (e.g. knob is at 25%)?
What are you using for excitation? +5V? |
|
|
May 25 2011, 12:50 PM
Post
#6
|
|
|
Joined: 27-April 09 Posts: 23 |
Are you interested in measuring the actual resistance between the wiper (leg 3) and either leg 1 or leg 2? Or do you want the ratio between the legs (e.g. knob is at 25%)? What are you using for excitation? +5V? I'm using leg 3 (the wiper) and leg 1. With 5Vdc I get a better reading. There are 4 legs, I took a photo: http://twitpic.com/52ggbd I need to get as much readings as possible. 20 would be ideal. So far I get about 11 different readings from this resistor. Is there maybe a way to connecto to legs 1,2,3,4 and get more measurements per one 120 degree angle turn? Thank you for your help! |
|
|
May 25 2011, 12:55 PM
Post
#7
|
|
|
Joined: 27-April 09 Posts: 23 |
Are you interested in measuring the actual resistance between the wiper (leg 3) and either leg 1 or leg 2? Or do you want the ratio between the legs (e.g. knob is at 25%)? What are you using for excitation? +5V? Don't know if it helps, but this is a video of my experiment -- http://www.youtube.com/watch?v=ir_iOpcPgHA (in Russian) -- but it shows the servo I'm building. It will be controlled by U12. |
|
|
May 25 2011, 01:08 PM
Post
#8
|
|
|
Joined: 27-April 09 Posts: 23 |
Are you interested in measuring the actual resistance between the wiper (leg 3) and either leg 1 or leg 2? Or do you want the ratio between the legs (e.g. knob is at 25%)? What are you using for excitation? +5V? Don't know if it helps, but this is a video of my experiment -- http://www.youtube.com/watch?v=ir_iOpcPgHA (in Russian) -- but it shows the servo I'm building. It will be controlled by U12. Ratio would be nice. That way I know the exact angle I guess. I was just going to measure voltage drop and calibrate the motor/reducer so that when it moves I know the angle it's actually at. Thus, the servo. |
|
|
May 25 2011, 01:20 PM
Post
#9
|
|
|
Joined: 9-June 03 Posts: 7519 |
QUOTE I'm using leg 3 (the wiper) and leg 1. With 5Vdc I get a better reading. Better than what? If you want the ratio you don't need a fixed resistor. Connect +5V to leg 1 and connect leg 2 to GND. Connect the wiper (leg 3) to AI0. Also jumper +5V to AI1 so you can measure that. Now take a reading from AI0 and AI1. The ratio AI0/AI1 is the ratio of your pot. As you adjust the pot fully, you should see the voltage on the wiper vary from 0 to +5V. |
|
|
May 25 2011, 01:21 PM
Post
#10
|
|
|
Joined: 9-June 03 Posts: 7519 |
If you want more accuracy you will need to consider the U12 input impedance as mentioned in post #2 above. If you do some sort of calibration, though, this will be taken care of.
|
|
|
May 25 2011, 10:35 PM
Post
#11
|
|
|
Joined: 27-April 09 Posts: 23 |
Wow! 605 readings :) this is way too much now... Thank you!
|
|
|
![]() ![]() |
|