View Single Post
  #1   Spotlight this post!  
Unread 17-01-2004, 06:38
D.Viddy's Avatar
D.Viddy D.Viddy is offline
Registered User
AKA: Dylan Vester
FRC #3176 (Purple Precision)
Team Role: Programmer
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Camby, IN
Posts: 44
D.Viddy is an unknown quantity at this point
Re: Trouble with pwm outputs

Quote:
Originally Posted by Just3D
If for some reason you get the power set up once more and it still fails, try this, it will help clear up any future printf statements:

Code:
printf("%d\n", &pwm02);
Notice the ampherstand (&). This will tell printf to read the value of pwn02 rather than the memory address of pwn02 (this is why 10000 or so seemed so out of range; memory addresses range all the way up to the maximum RAM).

As for the digits between the % and the 'd', lpramo55 was right in saying the number controls the number of digits output. If you write a 3, it will display 3 digits, adding zeroes as necessary. This also works with decimal places. For example: If you wrote

Code:
float f = 34.67;
printf("%2.1f", &f);
The output would be 34.7, rather than 34.670000.
The number between the '%' and the 'f' in this case represents 2 digits, plus a decimal point, plus 1 additional digit.

Hope this helps!

NOTE: Do not use floats with the robot programming because it has no floating point processor. Instead, stick to ints and unsigned chars, using "%i", and "%d" as needed.
If I'm not mistaken, doesn't the rewritten printf function not support the %f format for floating point. If I am right. How would I display a floating point number in the terminal window?
__________________
.................................................. .........
Dylan Vester - (Programmer)
Running a P4 1.8 Ghz
Team 998, We can't win...
.................................................. .........