Convert Potentiometer value from 0-1000 to it's actual value

Technical Discussions on any InterfaceKits
Post Reply
stever1388
Fresh meat
Posts: 2
Joined: Wed Sep 19, 2018 11:37 am
Contact:

Convert Potentiometer value from 0-1000 to it's actual value

Post by stever1388 »

Hello,

I'm using a Rotary Potentiometer - WDA-D35-D4C (ID: 3583_0) attached to a PhidgetInterfaceKit 8/8/8 (ID: 1018_2B) to track movement of a gun like object pointed at a screen. I'm using the C# library to access the Interface kit in code. In code, after connecting to the Interface kit I use this.interfaceKit.sensors[0].Value to get the value of the potentiometer. This returns a value from 0 to 1000. From the interface page (https://www.phidgets.com/?tier=3&catid= ... rodid=1021) under "User Guide", it states:

"If you have an analog sensor connected that you bought from us, you can select it from the Sensor Type drop-down menu. The example will then convert the voltage into a more meaningful value based on your sensor, with units included, and display it beside the Sensor Value label. Converting voltage to a Sensor Value is not specific to this example, it is handled by the Phidget libraries, with functions you have access to when you begin developing!"

However the 3583_0 does not show up in the Phidget Control Panel list and I can't find an equation that converts the 0-1000 to an actual value. I assume I could just divide by 360 since it seems like the 0-1000 is just one rotation of the device, but it'd be nice to know that is correct. Am I missing something or should I just assume the value needs divided by 360 to get the degree?

Thanks!
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Convert Potentiometer value from 0-1000 to it's actual value

Post by mparadis »

Instead of dividing by 360, you should divide by 1000 and multiply by 360. You may also want to add an offset or orient the potentiometer so that 0° corresponds to the neutral position.
stever1388
Fresh meat
Posts: 2
Joined: Wed Sep 19, 2018 11:37 am
Contact:

Re: Convert Potentiometer value from 0-1000 to it's actual value

Post by stever1388 »

mparadis wrote:Instead of dividing by 360, you should divide by 1000 and multiply by 360. You may also want to add an offset or orient the potentiometer so that 0° corresponds to the neutral position.
Yes I realized after I posted that I worded that incorrectly (and I am dividing by 1000 and then multiplying by 360). I just wasn't sure if this was the "best" or right way to do it.
User avatar
mparadis
Site Admin
Posts: 959
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: Convert Potentiometer value from 0-1000 to it's actual value

Post by mparadis »

Yes, this is the best way. Not all sensors have SensorType entries in the API, so manual calculation is the only option.

If you put this calculation in the event handler for the VoltageInput change event, you'll only have to do it once instead of repeating it whenever a number in degrees is needed.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest