Go to Post The possibilities for zip ties are endless. - Elgin Clock [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 20-01-2005, 00:49
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
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));
but it just prints -1. Any suggestions ?

Using newest compiler/IDE, firmware's updated and we're using newest default code.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #2   Spotlight this post!  
Unread 20-01-2005, 01:54
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Analog Input Trouble

Quote:
Originally Posted by Matt Krass
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));
but it just prints -1. Any suggestions ?

Using newest compiler/IDE, firmware's updated and we're using newest default code.
The compiler doesn't seem to handle this very well. I've taken to just using a temporary variable for the return value of a function, then pass the value of the temporary variable into printf. Try this:

unsigned int temp_analog_value;

temp_analog_value = Get_Analog_Value(rc_ana_in01);
printf("Raw value: %u\n", temp_analog_value);

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #3   Spotlight this post!  
Unread 20-01-2005, 12:07
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
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.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #4   Spotlight this post!  
Unread 20-01-2005, 12:23
Unsung FIRST Hero
Mike Betts Mike Betts is offline
Electrical Engineer
no team
Team Role: Engineer
 
Join Date: Dec 2001
Rookie Year: 1995
Location: Homosassa, FL
Posts: 1,442
Mike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond reputeMike Betts has a reputation beyond repute
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?
__________________
Mike Betts

Alumnus, Team 3518, Panthrobots, 2011
Alumnus, Team 177, Bobcat Robotics, 1995 - 2010
LRI, Connecticut Regional, 2007-2010
LRI, WPI Regional, 2009 - 2010
RI, South Florida Regional, 2012 - 2013

As easy as 355/113...
  #5   Spotlight this post!  
Unread 20-01-2005, 12:33
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,830
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
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.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
  #6   Spotlight this post!  
Unread 20-01-2005, 12:35
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
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.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #7   Spotlight this post!  
Unread 20-01-2005, 12:42
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,830
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Analog Input Trouble

Quote:
Originally Posted by Matt Krass
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.
Not really for a gyro. It's probably better used for distance or as a tilt sensor. It does make a great gravity detector.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 20-01-2005 at 13:12.
  #8   Spotlight this post!  
Unread 20-01-2005, 13:13
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Analog Input Trouble

Quote:
Originally Posted by Matt Krass
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.
Matt,

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
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #9   Spotlight this post!  
Unread 20-01-2005, 13:25
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Analog Input Trouble

Quote:
Originally Posted by Matt Krass
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.
Matt,

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
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org
  #10   Spotlight this post!  
Unread 20-01-2005, 16:11
Astronouth7303's Avatar
Astronouth7303 Astronouth7303 is offline
Why did I come back?
AKA: Jamie Bliss
FRC #4967 (That ONE Team)
Team Role: Mentor
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Grand Rapids, MI
Posts: 2,071
Astronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud ofAstronouth7303 has much to be proud of
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.)
  #11   Spotlight this post!  
Unread 20-01-2005, 21:09
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
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.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Example gyro code released. Kevin Watson Programming 60 17-03-2005 18:32
Arm Design Input -- Four Bar Linkages Sachiel7 Technical Discussion 4 18-01-2005 01:29
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Why not analog sensors?? gnormhurst Programming 16 07-03-2004 16:14
DC Motor current to an Analog Input junkyarddawg Motors 43 04-04-2002 15:53


All times are GMT -5. The time now is 03:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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