Go to Post Science and Technology is like the tide in the ocean, it raises all ships together, whether they're an engineering ship or a manual labor ship. - Doc Wu [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 19-01-2006, 20:53
Der Rowan's Avatar
Der Rowan Der Rowan is offline
Registered User
AKA: Capn Rowan
FRC #1531 (Lake Effect)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Oswego, NY
Posts: 6
Der Rowan is an unknown quantity at this point
Send a message via AIM to Der Rowan
Analog to Digital Conversion Help

Well I can get the motors running and pneumatics firing, but I'd really like to be able to do the more complicated stuff and that means interfacing with some sensors that provide analog output. So I have a few questions.

1. After I hook up my PWMs to the sensor (take your pick) and plug it into the RC's analog input, how do I make the code know which port I'm looking at?

and

2. How do I test / troubleshoot / even see the output from the sensor?
Is there some easy way to use a "print to a .txt file" or something? (something I'd try on a PC)

Better yet, what is the BEST way to get all the information? I'm seeing outputs in some of these posts mentioning the same kind of scaling that you see when you output to one of the motors. So should I find some way to get the info back to the dashboard (which I still need to set up). Even with that, we need to integrate (for many of the sensors) and seeing the value at any one time wont tell us too much.

Hope I'm not being too redundant or posting in the wrong place. If any of my questions indicate that I'm just fundamentally wrong, point that out too, please.

Thanks
__________________
Where's my Burger's vector?
  #2   Spotlight this post!  
Unread 19-01-2006, 21:11
iBheat's Avatar
iBheat iBheat is offline
Registered User
FRC #0418 (Lasa Robotics)
Team Role: Programmer
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Austin, TX
Posts: 24
iBheat is on a distinguished road
Re: Analog to Digital Conversion Help

Take a look at Kevin's ADC code which can be found at http://kevin.org/frc! He has excellent readme files that explain what each method does and how to use them!
  #3   Spotlight this post!  
Unread 19-01-2006, 21:59
duane's Avatar
duane duane is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Vacaville
Posts: 98
duane is an unknown quantity at this point
Send a message via AIM to duane
Re: Analog to Digital Conversion Help

Quote:
Originally Posted by Der Rowan
Better yet, what is the BEST way to get all the information? I'm seeing outputs in some of these posts mentioning the same kind of scaling that you see when you output to one of the motors. So should I find some way to get the info back to the dashboard (which I still need to set up). Even with that, we need to integrate (for many of the sensors) and seeing the value at any one time wont tell us too much.
So, are you using printf()? printf() will let you write output to the programming port on the RC. After you download the code to your RC then the COM program will start up. Then you will see any output that you have added printf's for.

Maybe I'm missing what you are asking.
  #4   Spotlight this post!  
Unread 20-01-2006, 07:29
Der Rowan's Avatar
Der Rowan Der Rowan is offline
Registered User
AKA: Capn Rowan
FRC #1531 (Lake Effect)
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Oswego, NY
Posts: 6
Der Rowan is an unknown quantity at this point
Send a message via AIM to Der Rowan
Re: Analog to Digital Conversion Help

I'm just looking for a good way to trouble shoot.

Even if I get the sensor and the RC to talk how do I see what they are saying to each other? The way I understand it, The RC is going to capture a value every so often at regular intervals which can then be used within the code to integrate (given that you know the interval...) or whatever. But I dont know how to see what that value is. Is there a way? It would be very helpful to explain whats going on to a highschooler.
__________________
Where's my Burger's vector?
  #5   Spotlight this post!  
Unread 23-01-2006, 00:17
duane's Avatar
duane duane is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Vacaville
Posts: 98
duane is an unknown quantity at this point
Send a message via AIM to duane
Re: Analog to Digital Conversion Help

Quote:
Originally Posted by Der Rowan
I'm just looking for a good way to trouble shoot.

Even if I get the sensor and the RC to talk how do I see what they are saying to each other? The way I understand it, The RC is going to capture a value every so often at regular intervals which can then be used within the code to integrate (given that you know the interval...) or whatever. But I dont know how to see what that value is. Is there a way? It would be very helpful to explain whats going on to a highschooler.
That explains things a little better.

There's nothing special about what's going on. You are in complete control.

First, I would second, what another poster said. Check out the ADC code from Kevin Watson (I saw wish I had to time to do what he does! :-)

Analog inputs are pretty simple. Unlike digital inputs which are just on and off, analog inputs can have any value between 0-5 volts. In order to read those values, the analog reading has to be coverted to an digital value. The FRC has a 10-bit analog-to-digital converter built in. When you call Get_Analog_Value() the RC returns a 10-bit number (in an integer). That means the value will range from 0 to 1024 (2^10).

Imagine dividing a line that is 5 units long into 1024 pieces. Each value represents that length of the line. 0 is 0, 1024 is 5, 512 is 2.5, etc. In practice, you care less about what the actual value is than how the value is different from the previous or expected value your code may be looking for.

The value you want to look at when you are debugging is the result from Get_Analog_Value(). That is the reading from the ADC converter.

You will see many examples that show shifting the result to the right 2 bits:
int result = Get_Analog_Value( rc_ana_in01 ) >> 2;

This reduces the resolution from 1024 (2^10) to 256 (2^8) by removing the two least significant bits. This is often done if the reading is going to be used with other devices that only support 8-bit values. For internal lookup tables and other math, you can use the entire 10-bit value.

Hope that helps,
...Duane
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
Analog-to-Digital Converter Code Kevin Watson Programming 29 17-02-2008 13:07
Analog and digital input question Robby Control System 7 30-04-2005 20:07
Accelerometer: Analog or Digital? psquared Programming 2 10-02-2005 16:38
Analog / Digital IO Connectors Aidan F. Browne Control System 4 06-02-2005 22:26
heres the code. y this not working omega Programming 16 31-03-2004 15:18


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

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