PDA

View Full Version : Need to count higher than 255



Steve Matson
- 2nd February 2008, 05:45
I am in a situation where I am controlling a stepper motor with a Pic and I need to count off up to 1900 stepps. Also I need to take the counted number of stepps and compare to another number to see which is higher or lower and subtract the difference. I guess I need to learn how to do natural math with Pics. For example: 1373 - 812 or whatever. I heard there are 'co-processors' but I dont know much about them. Does anybody have any ideas.
Thanks in advance,
Steve Matson

skimask
- 2nd February 2008, 05:51
I am in a situation where I am controlling a stepper motor with a Pic and I need to count off up to 1900 stepps. Also I need to take the counted number of stepps and compare to another number to see which is higher or lower and subtract the difference. I guess I need to learn how to do natural math with Pics. For example: 1373 - 812 or whatever. I heard there are 'co-processors' but I dont know much about them. Does anybody have any ideas.
Thanks in advance,
Steve Matson

Get more fingers and toes....Or....
Read in the PBP manual about Bits, Bytes, Words, and the variables that can be used with them...
Next on Jerry Springer...

Archangel
- 2nd February 2008, 07:23
I am in a situation where I am controlling a stepper motor with a Pic and I need to count off up to 1900 stepps. Also I need to take the counted number of stepps and compare to another number to see which is higher or lower and subtract the difference. I guess I need to learn how to do natural math with Pics. For example: 1373 - 812 or whatever. I heard there are 'co-processors' but I dont know much about them. Does anybody have any ideas.
Thanks in advance,
Steve MatsonHi Steve,
8 bits to a byte, 16 bits or 2 bytes to a word. Byte holds 0 - 255, word holds 0 - 65535
Count binary, each time you add a bit to the left the value doubles which is to say 010 is twice the value of 001, so if 11111111 = 255 then 1 00000000 is 256 and 1 00000001 is 257 etc, if you are using windows, fire up the calculator, switch it to scientific mode and enter any number smaller than 65535 and then click the button marked " BIN " and you will see the binary representation which is how the number is positioned in the WORD.
JS

Steve Matson
- 2nd February 2008, 08:05
Thanks, That makes sense. I suppose there is some kind of way to add and subtract those hex numbers and count down as well as up. Is this 16 bit math the same as you would find in an 8085up ?
Thanks
Steve Matson