|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help! Analog Inputs!!
Were using a potentiometer and I have no idea how to read the potentiometer value!
PLease help |
|
#2
|
||||
|
||||
|
Re: Help! Analog Inputs!!
Simply plug your POT into a analog port
Then use Get_Analog_Value(rc_ana_in0*) Where * is the number port you placed the POT. It will return a value between 0 and 1024, depending on how far it has been turned. |
|
#3
|
|||
|
|||
|
Re: Help! Analog Inputs!!
So i just printf("Pot %d\r", Get_Analog_Value(rc_ana_in0*)); to display it?
|
|
#4
|
||||
|
||||
|
Re: Help! Analog Inputs!!
Yes that should do it.
|
|
#5
|
||||
|
||||
|
Re: Help! Analog Inputs!!
Quote:
Code:
printf("Pot %d\r", Get_Analog_Value(rc_ana_in01));
|
|
#6
|
|||
|
|||
|
Re: Help! Analog Inputs!!
It doesn't really matter in this case, but when using an unsigned value, like analog inputs, you should use %u and not %d (the ADC conversion gives you a 10-bit value, 0-1023, so it should never come up as negative, but it's good to know in case you need a full 16-bit unsigned int).
Just make sure that the pot is properly connected (red + black leads to the outer leads on the pot, white to the wiper/middle lead) and you should have no problems. Our arm potentiometer got disconnected during testing and its value started creeping by 1 every few seconds, it was really weird. O_o |
|
#7
|
||||
|
||||
|
Re: Help! Analog Inputs!!
Also, make sure you've included ifiutilities.h in whatever file you're using Get_Analog_Value() or else it won't work. o_o
|
|
#8
|
|||||
|
|||||
|
Re: Help! Analog Inputs!!
Yep, Get_Analog_Value('the analog input number').
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Analog Inputs | bush | Programming | 5 | 13-03-2006 17:49 |
| Analog Inputs prob. | Bharat Nain | Programming | 2 | 07-02-2004 20:48 |
| Failing analog inputs? | Phasmatis568 | Control System | 5 | 22-01-2004 13:28 |
| Analog vs Digital inputs? | f22flyboy | Programming | 8 | 08-11-2002 22:18 |
| Analog Inputs | 316_programer | Technical Discussion | 2 | 05-02-2002 05:53 |