Need to count higher than 255


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2007
    Posts
    10

    Question Need to count higher than 255

    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
    Last edited by Steve Matson; - 2nd February 2008 at 05:48.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Steve Matson View Post
    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...

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Steve Matson View Post
    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
    Hi 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
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    May 2007
    Posts
    10


    Did you find this post helpful? Yes | No

    Default Thanks

    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

Similar Threads

  1. Doubling the pusle count
    By malc-c in forum mel PIC BASIC Pro
    Replies: 43
    Last Post: - 17th May 2012, 13:17
  2. COUNT is not counting again
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 19th June 2009, 04:52
  3. Can't get COUNT to count
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd March 2009, 23:14
  4. Count pulses between VARIABLE TIME
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th October 2007, 12:44
  5. Count command
    By hawk72501 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th September 2005, 19:04

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts