Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Trouble with pwm outputs (http://www.chiefdelphi.com/forums/showthread.php?t=23828)

D.Viddy 17-01-2004 06:38

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?

deltacoder1020 17-01-2004 10:56

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)


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

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