12F675 compare voltage help.


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default Little more help

    I am stuck again.

    I multiply by 1000 to shift where the decimal will be.
    The problem is my first calculation is
    1022*1000 comes out 38960 instead of 1022000 How do I keep my whole number?


    I tried this as well
    dummy VAR WORD
    adval0=1019
    dummy = adval0*1000*3
    adval0 = div32 1023


    Gives me 111... Should be giving me 2988 or something...
    Last edited by geckogrotto; - 1st February 2007 at 17:03. Reason: Div32

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Try this...
    Code:
        adval0 = adval0*3000
        adval0 = div32 1023
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Thank you much Mister_e!

  4. #4
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Stuck again. I'm just not understanding this math

    adval0 = 2904
    result = adval0 / 15100
    remainder = adval0 // 15100
    result = 0
    remainder is 2904
    How do I get the acutal number it should be 0.192xxx?


    I'm looking at dig but not sure if thats the right thing to use because it will not always be 2 digits...

    adval 0 = 2904*10
    result = adval/151
    192
    then use dig to move the places... and do something like
    if > 9999
    if > 999
    to figure out where the . should be... Is this the best way to do it?
    Last edited by geckogrotto; - 2nd February 2007 at 00:20.

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by geckogrotto View Post
    Stuck again. I'm just not understanding this math

    adval0 = 2904
    result = adval0 / 15100
    remainder = adval0 // 15100
    result = 0
    remainder is 2904
    How do I get the acutal number it should be 0.192xxx?
    You aren't going to get .192xxx.
    PBP only deals with integer math, as stated in the PBP manual.
    You'll have to write your own routines to get anything past the decimal point.

  6. #6
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ok how do I do that. I had edited my post while you were posting.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by geckogrotto View Post
    Ok how do I do that. I had edited my post while you were posting.
    I see the edit, and you're on the right track, pretty much the only track.

Similar Threads

  1. high voltage high frequency H-Bridge
    By George in forum Off Topic
    Replies: 6
    Last Post: - 27th April 2009, 11:50
  2. Expanded Scale Voltmeter
    By Pic_User in forum Schematics
    Replies: 6
    Last Post: - 8th February 2008, 20:32
  3. make a low voltage output from a PIC pin
    By emptyset in forum General
    Replies: 1
    Last Post: - 8th February 2008, 19:20
  4. Help with final project
    By OvERKiLL in forum General
    Replies: 4
    Last Post: - 15th December 2006, 20:35
  5. Low Voltage Detection
    By Srigopal007 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 5th January 2005, 18:29

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