Hi mackrackit,
If the leading zeros are a problem you just use DEC 3 in your LCDOUT command and you should be OK on full 0 – 65 range. The only change will be with the result of y/21 (0 -6).
Regards,
nick
Hi mackrackit,
If the leading zeros are a problem you just use DEC 3 in your LCDOUT command and you should be OK on full 0 – 65 range. The only change will be with the result of y/21 (0 -6).
Regards,
nick
currently im doing a rice dispenser device that accepts a weight or price value.. my problem was at the price input value.. as the device runs it will ask for a price/kilo of the rice.. assuming i input a value of 25.50, but the actual value stored is 2550. this 2550 is the reference for determining the weight to be dispensed. after 2550 stored, the program ask for another input to be compared in the 2550. i used the codes that mackrackit posted.
'variable PRICE is the reference input
'TOTALAMOUNT is the variable to be compared
PRICED = PRICE/10
AMT = TOTALAMOUNT/10
DECIKILO = (100*AMT/PRICED)//100
WHOLEKILO = (100*AMT/PRICED)/100
LCDOUT $FE,$C0,#WHOLEKILO,".",#DECIKILO," Kg"
using this the program I can determine the weight but it only accepts 4 digit number.. making it to a 5 digit input will go beyond a 65535 limit.
If you have PBP 2.50 and use a 18F
chip, you can compile with PBPL
that will give you 32 bit math.
This will give you the ability to use
numbers with a range of
-2147483648 to
+2147483647
That should solve the problem.
Dave
Always wear safety glasses while programming.
the codes that i created in 16f877 can be used when i changed to 18f, what 18f pic is almost the same as 16f877? and it must be pbp 2.50? coz im currently using 2.47 only.. thnx
Last edited by taisen83; - 5th January 2009 at 03:39.
If you want to use the LONG variable that gives you 32 bit math you will have to upgrade to 2.50.
When moving your code from a 16F to an 18F there will be some modifications needed. example, the 16F877 does not have comparators, so you may hace to turn them off on the 18F chip depending on the pins used.
As far as pin outs go, and as far as I know, all of the 40 pin PICs use the same pins for power, programming, OSC and MCLR.
The 18Fs will have several extra features, that may or may not be useful, such as USB pins and may even have an internal OSC.
An 18F4320 might be a good one to start with. It has an internal OSC, but does not have USB.
Dave
Always wear safety glasses while programming.
18f452 can also be a substitute right? coz i've seen in forums about transferring codes from 16f877 to 18f452..
Bookmarks