Writing code for battery operated projects


Results 1 to 16 of 16

Threaded View

  1. #11
    Join Date
    Jan 2005
    Location
    Puerto Rico
    Posts
    133


    Did you find this post helpful? Yes | No

    Smile Volt Read

    KK:
    gosub GetVolt
    SerOut LCDScreen, N2400, [LCDCmd, LCDLine1,"T= c"," V=",#LCDVHigh,".",#LCDVLow]
    goto KK

    GetVolt:
    'For global reference to system voltage, use the Voltage variable, which is based on a
    'scale of 1 to 1000, with 775 = 7.75 volts. Remember that the resistors on the board
    'divide the actual battery voltage in half so the ADC can "digest" it without damage.
    'ADCIN voltages are limited to 5. Voltage are compared with the onboard
    'precision voltage reference which delivers a perfect 5V.


    '**Voltage**
    LCDVLow=0
    LCDVHigh=0
    Voltage=0
    ADCIN VoltChannel, Voltage 'Take just 1 voltage sample. 7.6V = 194
    Voltage = Voltage * 4 '194 * 4 = 776
    LCDVHigh = Voltage / 100 '776 / 100 rounds to 7
    LCDVLow = (Voltage // 100) / 10 '776 // 100 = 76, 76 / 10 = 7
    'Final Display = 7.7

    return
    Last edited by jetpr; - 13th June 2005 at 18:12.

Similar Threads

  1. Writing good/proper code
    By Bill Legge in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 22nd July 2009, 00:55
  2. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  3. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  4. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  5. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26

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