We’re a couple of never-ever programmers trying to teach ourselves LabView (in the next month…) Can someone help us out with some sample code for a trim potentiometer?
We added an analogue Open into Begin.vi (and gave it a unique DevRefNum based on some sample code for a limit switch), then tried to read values from the Get Voltage vi in the teleop.vi (inside the main loop)…
We added a probe to the output of the Get Voltage vi, and it just fluctuates around zero (looks like noise) no matter what the potentiometer does. (The pot is in analogue 1, and we identified it as such in the code.)
Thus, if someone has some sample code they would be willing to share, that would be fantastic.
How is the potentiometer connected to the cRIO (ie where is each wire going)? Have you measured the pot’s signal with a simple voltmeter to ascertain for certain that it is actually providing a signal?
If it looks like you are getting noise, you probably are - I’m betting that your code is just fine.
Wire one end of the pot to +5V, the other end to ground, and the middle to the signal input. These should be labeled on the shell for the analog breakout.
The 5v voltage regulator does have a certain degree of noise.
On the 2009 Analog Breakout, I measured about ±15mv of variation.
Granted, the regulator was changed to a linear regulator for 2010, so the noise should be less. However, there’s a lot of switcher power supplies on the robot (I count 5, excluding any motor controllers). There’s probably a lot of noise on the main supply because of this.
I would be really helpful if you could post a screenshot of the relevant part of your code and a picture showing how you connected the potentiometer to the cRio
it seems like your connection is wrong and you are measuring an input that is not connected to anything.
Above should be the your first step in troubleshooting this problem! So often we overlook the basics and jump to the advanced steps.
Verify the pot actually works.
Verify it is connected correctly.
See if the code reads as expected.
To address step #2 above, make sure the pot is connected to the analog bumper as follows:
One end of the pot is connected to the black wire of a PWM cable. The other end of that black wire needs to be connected to the Gnd. pin on the analog input you selected.
The other end of the pot needs to be connected th the red wire of the same PWM cable. The other end needs to be connected to the +5v pin of the analog input.
Now the wiper of the pot needs to be connected to the white wire of the PWM cable. The other end of the white wire needs to be connected to the Signal pin of the selected analog input.
With these steps verified, you can now use a “probe” to see if the code is working properly.
One more thing – make sure the Analog Breakout has 12 volt power. Its green light should be lit. Without that, it won’t be able to supply 5 volts to the potentiometer.