![]() |
Analog Input Trouble
My co-programmer and I are having some trouble with the RC. We've tried both a potentiometer and a gyro connected to the first analog input. I tried to get the raw value using:
Code:
printf("Raw value: %d\n", Get_Analog_Value(rc_ana_in01));Using newest compiler/IDE, firmware's updated and we're using newest default code. |
Re: Analog Input Trouble
Quote:
unsigned int temp_analog_value; temp_analog_value = Get_Analog_Value(rc_ana_in01); printf("Raw value: %u\n", temp_analog_value); -Kevin |
Re: Analog Input Trouble
I'll definitely try that, however once I get to robotics I won't have access to these forums, so in case it doesn't work out, does anyone have any other tips or things for me to check?
Thanks, Matt. |
Re: Analog Input Trouble
Matt,
Remember that you are displaying in decimal. -1 = 0xFF which is full scale (>+5V input).... Are you sure it's not working? |
Re: Analog Input Trouble
You might test on an alternate controller like the EDU or last year's RC.
I ran a quick test on the EDU with this year's 2.4 compiler and didn't have a problem. I tested with the Get_Analog call in-line and to a temp variable, and with the old printf and new 2.4 stdio.h printf. Same result though every time. 1023 with nothing on analog 1, 0 with the pins shorted. |
Re: Analog Input Trouble
No matter what we do it remains at minus 1, so I don't think it's us not noticing. I'm about to go "borrow" the 2004 RC and see how it likes this, once I make sure we still have its master program. I'm hoping the code snippet above will solve my problems.
By the way, the accelerometer in the kit, could I use that with some decent math to imitate a gyro? Our budget is far too tight to get an Analog Digital gyro, or any other for that matter. |
Re: Analog Input Trouble
Quote:
|
Re: Analog Input Trouble
Quote:
To expand upon Mike's reply above, Get_Analog_Value() returns an unsigned int. Your printf() is expecting to manipulate an int because you used %d instead of %u. I fixed it in my code above, but forgot to mention it as another problem. -Kevin |
Re: Analog Input Trouble
Quote:
I forgot to ask which version of the printf() function you're using? IFI's original or the version included with the 2.4 compiler? -Kevin |
Re: Analog Input Trouble
You may also want to check that it's plugged in right, that it's the right port, etc. etc. Also check to see if an analog input defaults to high or low. (Since no ones mentioned it, I think.)
|
Re: Analog Input Trouble
Thanks for all teh help, it's working now. It was the printf statement.
Thanks guys, mods can close the thread if they want. |
| All times are GMT -5. The time now is 17:52. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi