|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
potentiometer programming help
Hey,
We are programming a potentiometer and are having difficulty. We are having difficulty getting our code to work. It was written in Easy C. Can anyone help?? |
|
#2
|
||||
|
||||
|
Re: potentiometer programming help
What specific problems are you encountering? Are you not getting readings or can't you compile your code? You may also want to post the portion of your code that is giving you diffculty. The more specific you are, the more help will you get.
|
|
#3
|
|||
|
|||
|
Re: potentiometer programming help
This is the code i made
#include "Main.h" void OperatorControl ( void ) { int joy_y_port1; int joy_x_port2; unsigned char left_output; unsigned char right_output; int limit = 1; int limit2 = 1; unsigned int steering; int pressure; while ( 1 ) { PrintToScreen ( "steering value before getting steering reading=%d\n" , (long)¬ steering ) ; joy_y_port1 = GetOIAInput ( 1 , 2 ) ; // get joystick data left_output = (( joy_y_port1 -127 ) +127) ; // drive motor SetRelay ( 8 , 1 , -1 ) ; // send power to the compressor pressure = GetDigitalInput ( 9 ) ; // get air pressure reading while ( pressure >= 120 ) { SetRelay ( 8 , 0 , -1 ) ; break ; // return to driving } steering = GetAnalogInput ( 1 ) ; // read pot joy_x_port2 = GetOIAInput ( 2 , 2 ) ; // get joystick data if ( joy_x_port2 > 245 || joy_x_port2 < 10 ) // if pushed hard left or right { right_output = (( joy_x_port2 - 127 )/2 +127) ; // use joystick over r¬ ide } if ( steering >663 ) // correcting towards the left { SetPWM ( 3 , 139 ) ; PrintToScreen ( "this steering value should be above 512=%d\n" , (long)¬ steering ) ; } if ( steering <= 308 ) // correcting towards the right { SetPWM ( 3 , 115 ) ; PrintToScreen ( "this steering value should be below 512 =%d\n" , (long¬ )steering ) ; } SetPWM ( 1 , left_output ) ; SetPWM ( 2 , left_output ) ; SetPWM ( 3 , right_output ) ; OIToRelay ( 1 , 1 , 2 , 1 ) ; } } I get readings from the device but it doesn't work the way i want it to. The purpose it to keep a solo wheel pointed directly outward and when the wheel is turned to the right with the joystick i want the pot sensor to recenter the wheel when we let go of the joystick and vice versa for the right. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help wiring potentiometer-to-Analog port | kylehager | Electrical | 4 | 17-01-2008 17:28 |
| PLEASE HELP!! Need help programming arm?? | amirjpl | Programming | 12 | 15-03-2007 15:11 |
| Potentiometer help | Unholy | Programming | 4 | 07-02-2006 17:48 |
| Potentiometer Help! | thoughtful | Programming | 4 | 18-02-2005 08:21 |
| Potentiometer Question, we need help! | dez250 | Electrical | 13 | 25-08-2004 14:50 |