Go to Post Some may call it an obsession and they may be right, but I call it a huge learning experience. - 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
  #16   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...
.................................................. .........
  #17   Spotlight this post!  
Unread 17-01-2004, 10:56
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Trouble with pwm outputs

depending on the size, you might just multiply it by 1000 to give you an integer (if the number is -32.767 < x < 32.767) or some other power of 10 (i.e. if you have values -320.767 - 320.767, mult. by 100)
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)
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
Tether for new EduBot Controller gburlison Programming 9 18-12-2003 17:53
pwm 13-15 wayne 05 Programming 2 04-10-2003 12:08
PWM and burning out motors patrickrd Technical Discussion 7 19-06-2003 15:30
Hints For Rookie Programmers Noah Programming 30 20-02-2003 20:07
relay and pwm outputs nick_champ_2 Electrical 1 31-01-2003 13:08


All times are GMT -5. The time now is 19:56.

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