Sorry to bug you again, but we are trying to use a potentiometer to set the speed of a motor, but for visualizing what is happening, we are temporarily using a servo in it’s place. We wired a 10 turn pot to the analog module on the crio with the signal wire going to the sweeper pin on the pot.
When we move the pot it sets the servo to one of two positions, either fully rotated one way, or fully rotated the other, and it happens after a fraction of a turn from one endpoint on the pot. So if we are fully CCW on the pot the servo is in one position, if we move the pot about 1/16 of a rotation the servo moves to the opposite end. We tried two different pots to make sure it wasn’t the pot, and they are both 10k ohms. I don’t think I need to wire a resistor in series or anything like that, do I?
I tried using both the GetValue and the GetVoltage functions and have the same issue. Here is the code:
AnalogChannel *MainPot; float PotValue; int Temp; MainPot= new AnalogChannel(1); PotValue=Temp=0; Temp=MainPot->GetValue(); PotValue=Temp; PotValue=PotValue/1000; Servo6->Set(PotValue);
I divided GetValue by 1000 because it is a value of 0-1000 (and the Set Servo is -1 to 1) if I understand it right. I used a temporary variable temp to make sure there was no conflict in changing variable types. When I used GetVoltage I divided by 5 because the voltage is 0-5. Is there something obvious I am missing?