Go to Post Never underestimate people's ability to underestimate. - Ginger Power [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 17-02-2006, 22:56
Idaman323 Idaman323 is offline
In Theory, Our Robot Would Own.
FRC #1706
Team Role: Driver
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Wentzville, MO
Posts: 116
Idaman323 is an unknown quantity at this point
Pot Printf Variable

Hey guys, just got a quick question. I have a command to tell me the range of our potentiometer. Its a printf command. I have gotten the adc code all up in the code already. It goes something like:

printf("Pot value: %d\r\n", variableNameUsedForPot);

Except, Im not sure what the actual variable name is. Can someone maybe tell me real quick I cant find it in the code. Thanks!
__________________
TEAM 1706
2007 Judges Award, St. Louis (For our amazing ability to have bad luck)
2005 Rookie Inspiration Award, St. Louis
  #2   Spotlight this post!  
Unread 17-02-2006, 23:00
Bob Koehl Bob Koehl is offline
Engineer
no team (The MEZ)
Team Role: Mentor
 
Join Date: Nov 2001
Rookie Year: 2000
Location: Detroit, MI
Posts: 7
Bob Koehl is a jewel in the roughBob Koehl is a jewel in the roughBob Koehl is a jewel in the rough
Re: Pot Printf Variable

See this example from the IFI programming guide (2004-programming-reference-guide-12-apr-2004.pdf) page 16:
/* Example of using the Analog Inputs to map an analog input to a PWM output. */
unsigned int sensor1;
unsigned char sensor1_8bits;
sensor1 = Get_Analog_Value( rc_ana_in01 ); /* Assign the analog reading to a variable. */
sensor1_8bits = (unsigned char)(sensor1 >> 2); /* Only take the 8 most significant bits, */
pwm01 = sensor1_8bits; /* because PWM OUTPUTS can only be 8 bits. *

printf("Pot value: %d\r\n", variableNameUsedForPot);
would be
printf("Pot value: %d\r,(int)sensor1);

Hope this helps.
__________________
Bob Koehl
Michigan Engineering Zone Mentor
VP/Secretary DADARA
  #3   Spotlight this post!  
Unread 17-02-2006, 23:55
Idaman323 Idaman323 is offline
In Theory, Our Robot Would Own.
FRC #1706
Team Role: Driver
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Wentzville, MO
Posts: 116
Idaman323 is an unknown quantity at this point
Re: Pot Printf Variable

So pretty much I can do

unsigned int sensor1;

sensor1 = Get_Analog_Value( rc_ana_in01 ); /* Assign the analog reading to a variable. */

then in proccess_data_from_master_up we put the

printf("Pot value: %d\r,(int)sensor1);


would that work, and would the top part go into adc.h or adc.c?
__________________
TEAM 1706
2007 Judges Award, St. Louis (For our amazing ability to have bad luck)
2005 Rookie Inspiration Award, St. Louis
  #4   Spotlight this post!  
Unread 18-02-2006, 07:17
Ryan M. Ryan M. is offline
Programming User
FRC #1317 (Digital Fusion)
Team Role: Programmer
 
Join Date: Jan 2004
Rookie Year: 2004
Location: Ohio
Posts: 1,508
Ryan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud ofRyan M. has much to be proud of
Re: Pot Printf Variable

Quote:
Originally Posted by Idaman323
would that work, and would the top part go into adc.h or adc.c?
You should place the sensor declaration whereever you are going to be using it. If it needs to be in multiple places, put an extern declaration in a header file which you then include in the extra files. IE:

externDeclartion.h (or whatever you want to call it)
Code:
extern unsigned int sensor1;
someFile.c
Code:
#include "externDeclaration.h"
...
--EDIT--
And yeah, you have the idea.
__________________

  #5   Spotlight this post!  
Unread 18-02-2006, 10:48
kevlarman kevlarman is offline
"why cant i install Linux?" guy
AKA: Roman Tetelman
None #0100
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Belmont, CA
Posts: 11
kevlarman is an unknown quantity at this point
Re: Pot Printf Variable

if you have kevin watson's adc code set up then you should use Get_ADC_Result(1) instead of Get_Analog_Value( rc_ana_in01 )
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
printf could not find definition Alex829 Programming 7 27-06-2005 10:04
Printf Oddity : Programming Challange DarkAlex Programming 7 21-03-2005 08:12
printf statements do not display in autonomous mode PVC Pirates Programming 3 22-02-2005 15:41
Anyone with a replacement Printf? Larry Barello Programming 5 19-03-2004 02:20


All times are GMT -5. The time now is 01:34.

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