Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   coding a potentiometer (http://www.chiefdelphi.com/forums/showthread.php?t=34499)

incognito_NICK 12-02-2005 15:25

coding a potentiometer
 
I am trying to look at the values i get with a potentiometer through the dashboard, but my attempts are ending in failure. :(
So is there some special code that have to put in so that i can read it or is it because i have it plugged in the wrong spot.
anyone know the solution?

:confused:

Leav 12-02-2005 15:35

Re: coding a potentiometer
 
Quote:

Originally Posted by incognito_NICK
I am trying to look at the values i get with a potentiometer through the dashboard, but my attempts are ending in failure. :(
So is there some special code that have to put in so that i can read it or is it because i have it plugged in the wrong spot.
anyone know the solution?

:confused:

on your pot you should have 3 pins, i blieve that the two outer ones should be connected to the + and - pins of the analog inputs and the middle one to the signal pin. (not infront of the robot right now...)

once you do that use this code: (assuming you connected it to analog input #1)
Code:

pot1=Get_Analog_Value(rc_ana_in01);
printf("pot1=%d \r ",pot1);

i'm not sure if you can read the analog inputs with the dashboard....
-Leav

Mark McLeod 12-02-2005 15:53

Re: coding a potentiometer
 
Do you have to pot attached to the OI or attached to the RC?
You could have a wiring problem with the pot in either place, so double check the OI or RC specs for correct wiring.

The dashboard display for the OI comes setup to show the joystick port pot values as a range from 0-254.

For the RC dashboard screen you'll have to scale the pot (0-1023) to the range (0-255) and set one of the User_Byte's (1-6) to that value.

Alan Anderson 12-02-2005 23:05

Re: coding a potentiometer
 
Quote:

Originally Posted by Mark McLeod
For the RC dashboard screen you'll have to scale the pot (0-1023) to the range (0-255) and set one of the User_Byte's (1-6) to that value.

Or use two user bytes:
Code:

    User_Byte1 = value >> 8;
    User_Byte2 = value & 255;


Mike 12-02-2005 23:28

Re: coding a potentiometer
 
Just bitshift it twice (from a 10 bit to an 8 bit number)
Code:

POT = Get_Analog_Value(rc_ana_in01) >> 2;

incognito_NICK 14-02-2005 15:56

thanks, that situation has been taken care off. appreciate greatly.
:)


All times are GMT -5. The time now is 23:56.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi