The easy way would be using an 18Fxxx with PBP 2.50 or greater. That way you have LONGs.
Other wise you are stuck with dividing down and messing with HIGH BYTE/LOW BYTE stuff. Just not worth is these days.
The easy way would be using an 18Fxxx with PBP 2.50 or greater. That way you have LONGs.
Other wise you are stuck with dividing down and messing with HIGH BYTE/LOW BYTE stuff. Just not worth is these days.
Dave
Always wear safety glasses while programming.
I'm trying to rid the world of 16F chips, but try this
http://www.picbasic.co.uk/forum/show...ght=n-bit_math
Charles Linquist
What is x20?
what is f0?
what is x?
A little more detail and it is possible that a different solution exists.
The last time I did something similar, I had a pulses per mile count. After that the mile count would increase by 1. To handle numbers as big as 99999999 you can do it in code like I did
Pseudo code begins
Now, displaying this is easy.Code:miles[4] var byte ' lsb to msb on input pulse, pulses=pulses+1 if pulses >= Pulsespermile pulses = 0 ' start counting again till we reach pulses per mile miles[0] = miles[0]+1 if miles[0] > 99 then miles[0] =0 miles[1] = miles[1]+1 if miles[1] > 99 then miles[1] = 0 miles[2] = miles[2]+1 if miles[2] > 99 then miles[2] = 0 miles[3] = miles[3]+1 if miles[3] > 99 then miles[3] = 0 ' roll over to all zero endif endif endif endif endif
Code:Num = miles[0] dig 1 ' first digit to display digitpos = 0 gosub displaynum ' show the number Num = miles[0] dig 0 ' 2nd digit to display digitpos = 1 gosub displaynum ' show the number Num = miles[1] dig 1 ' 3rd digit to display digitpos = 2 gosub displaynum ' show the number Num = miles[1] dig 0 ' 4th digit to display digitpos = 3 gosub displaynum ' show the number and so on
In some cases,(like high-volume applications), the 16F series makes sense. But too often I see people that work hours (or tens of hours) longer to get something to work because they started out with an inadequate chip on a one-off project.
Charles Linquist
According to here PIC16F88 the lowest cost device is $2.20 - if you go here PIC18 Product Family and do a sort on ascending price, you will find about 45 PIC18's that cost less than a PIC16F88. That said, I use several competitive 32-bit devices that are about half that price.
Not sure, but maybe you can just change 1-line.
Depends on what f0 and x are.Code:'---[INT - interrupt handler]--------------------------------------------------- ToggleLED1: cnt = cnt +1 cntb = cnt * 20 ; could be * 1000 meter = DIV32 f0 If meter = x Then meter = 0 km = km + 1 cnt = 0 Endif @ INT_RETURN
DT
If you are looking for costs ... forget all this old 16F... or 18F...-devices.
Take new cheap dsPic33 or ...J... or ...K... -devices.
The new devices are very cheap, the old stuff is expensive !!!!
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Not an economic solution but great fun is the 'floating point co-processor' from Micromega. Costs about $20. the free IDE make developing the code a doddle.
Regards Bill Legge
Bookmarks