16F876A Pulsin issues


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    just not getting the decimal places now, :-(

    Latest attempt
    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    volt = volt * 2
    Vin = (5*volt/1023)
    Vind = (volt // 1000) / 10 'millivolts?
    
    lcdout $FE, $C0+8, dec Vin,".",dec2 Vind,"V"
    Time to pack it in for the night, work tomorrow, fairly good progress, just the decimal points to figure out.

    Kind Regards
    Rob

  2. #2
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Am I on the right track?

    the "//" operator will store the remainder in the chosen Var, thus:

    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    volt = volt * 2                 'Correct the ADCin for the Voltage divider?
    FVolt = (5*volt/1023)
    MVolt = (5*volt // 1023)  'millivolts?
    
    lcdout $FE, $C0+8, dec FVolt,".",dec4 MVolt,"V"
    Sorry for getting overly complex with this but trying to understand how it works, I have been able to simulate what I need to do in excel, just not sure if the above will work in PBP:

    D1 = Vref @ 5.00
    D5 = Adc Corrected @ 1021
    D6 = 10 bit ADC @ 1024

    D14 = Whole number (Formula =TRUNC(D9,0), result = 4
    D15 = Remainder (Formula =(MOD((D5*D1)/D6,1)*1000)), result = 990

    I could then LCDout D14, ".", D15 in theory if the formula in PBP equaled the excel result.

    not sure though, still a bit confused

    Cheers
    Rob
    Last edited by Bobbo_ZA; - 31st March 2010 at 09:39.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Bobbo_ZA View Post
    just not getting the decimal places now, :-(

    Latest attempt
    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    volt = volt * 2
    Vin = (5*volt/1023)
    Vind = (volt // 1000) / 10 'millivolts?
    
    lcdout $FE, $C0+8, dec Vin,".",dec2 Vind,"V"
    Time to pack it in for the night, work tomorrow, fairly good progress, just the decimal points to figure out.

    Kind Regards
    Rob
    Ok Rob,

    What about :

    Code:
    ADCIN 4, volt                  ' Read AN4 into temp variable
    
    volt = volt * 2 * 5
    
    Volt = 100*volt               ' See manual for DIV32 !!!
    Vind = DIV32 1024           ' Here we have result in 1/100 Volts ...
    
    Vin = Vind/100                  ' Here we get the integer part ...
    Vind = Vind // 100             ' Here we get the decimal part ...
    
    lcdout $FE, $C0+8, dec Vin,".",dec2 Vind,"V"
    that's all !
    Last edited by Acetronics2; - 31st March 2010 at 09:37.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Cant believe it can be that simple, i was trying to over complicate things, :-)

    Will try it again tonight, :-)

    Achievements So far:
    1. Hitachi LCD interfaced to 16F876A
    2. Read input from RC Receiver
    3. Drive a Servo from the PIC
    4. Display pulsin values on the LCD
    5. Measure Flight Pack voltage - with load on demand

    Still to do:
    1. Menu system for each function
    2. separate components into sub functions
    3. Move off Breadboard and build into an enclosure of some sort.

    List of proposed features:
    1. Rc Flight pack battery tester
    2. Servo Tester - with Sweep and Centering
    3. Current monitor - planing to add either SI210709-300T (50A) or ACS750
    4. Receiver Pulse monitor for other PIC projects
    5. Thermometer - Although I think I'm all out of AD inputs
    6. Sure Im going to come across some more features to add to it, :-) any ideas?

  5. #5
    Join Date
    Mar 2010
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Hi Ace, All,

    its working, :-) cant believe it was that simple, :-)

    going to start working on the next phase of the implementation this weekend.

    Hope everyone has a good weekend, :-)

    Cheers
    Rob

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