Shop OBEX P1 Docs P2 Docs Learn Events
Battery measurement help — Parallax Forums

Battery measurement help

ArchiverArchiver Posts: 46,084
edited 2000-08-30 00:33 in General Discussion
An alternative to adding ADCs is to use a digital switch. One example isthe Maxim 333A, which has 4 DPST switches.· Then use the BS2 to logicallycontrol the switch to select a particular channel.· This is more versatilethen using a multiplexer, because you can control the logic in a non-sequentialmode, which your application requires.
Dennis



Don Bannon wrote:
[size=-1]HelloGroup--[/size][size=-1]I have a stamp2 alternatelyreading "data out" on two A to D convertors, first one, then the otherand repeat.· After each is read 20 or 30 times, I want to read a thirdADC that measures the battery supply voltage to the circuit.· Thiswill tell me when the battery should be changed.[/size][size=-1]I'mthinking of using another ADC to read this supply voltage and the codeto kick out of the main loop after 20 or 30 readings, read the voltagefrom the third ADC, then go back into the main loop to do another 20 or30 readings.[/size][size=-1]Would any ofyou be able to provide me with a sample of the code needed to do jump outafter 20 or 30, read the third ADC and go back ito the main loop?[/size][size=-1]Hasanyone had experience doing this before from a hardware standpoint?[/size][size=-1]TIAfor any help.·· --Don[/size]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-08-24 21:21
    Hello Group--
    I have a stamp2 alternately reading "data out" on two A to D convertors, first one, then the other and repeat.· After each is read 20 or 30 times, I want to read a third ADC that measures the battery supply voltage to the circuit.· This will tell me when the battery should be changed.
    I'm thinking of using another ADC to read this supply voltage and·the code to kick out of the main loop after 20 or 30 readings, read the voltage from the third ADC, then go back into the main loop to do another 20 or 30 readings.
    Would any of you be able to provide me with a sample of the code needed to do jump out after 20 or 30, read the third ADC and go back ito the main loop?
    Has anyone had experience doing this before from a hardware standpoint?
    TIA for any help.·· --Don
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-25 01:51
    Tracy Allen's Excellent web site has an application using RC time for
    measuring battery voltage

    http://www.emesystems.com/BS2misc.htm#RCtime

    I recently tried it out and it works perfectly, of course!

    Steve




    At 12:17 PM 08/24/2000 -0700, you wrote:
    > This is more versatile then using a multiplexer, because you can
    >control the logic in a non-sequential mode, which your application requires.
    >Dennis
    >
    > Don Bannon wrote: Hello Group-- This will tell me when the battery
    >should be changed.I'm thinking of using another ADC to read this supply
    >voltage and the code to kick out of the main loop after 20 or 30 readings,
    >read the voltage from the third ADC, then go back into the main loop to do
    >another 20 or 30 readings.Would any of you be able to provide me with a
    >sample of the code needed to do jump out after 20 or 30, read the third ADC
    >and go back ito the main loop?Has anyone had experience doing this before
    >from a hardware standpoint? --Don
    >
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-25 11:39
    Why not use one of the multi-channel ADCs - one chip most likely means less
    power and everything can be done within one loop. Something like:

    maxct = 20
    ct = 0
    READADC:
    read chan1
    read chan2
    ct = ct + 1
    if ct < maxct then skipnext
    read battchan
    ct = 0
    SKIPNEXT:
    goto READADC

    I hope this helps

    Vic
    _____________________________________________________

    Victor Fraenckel - The Windman vfraenc1@n...
    KC2GUI
    www.windsway.com

    Home of the WindReader Electronic Theodolite
    Read the WIND
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-29 19:46
    Dennis--· Thanks for your help on my measurement problem.· Much appreciated.· --Don

    Original Message
    From: Dennis O'Leary [noparse][[/noparse]mailto:doleary@hsc.usc.edu]
    Sent: Thursday, August 24, 2000 2:17 PM
    To: basicstamps@egroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] Battery measurement help

    An alternative to adding ADCs is to use a digital switch. One example is the Maxim 333A, which has 4 DPST switches.· Then use the BS2 to logically control the switch to select a particular channel.· This is more versatile then using a multiplexer, because you can control the logic in a non-sequential mode, which your application requires.
    Dennis
    ·
    ·

    Don Bannon wrote:
    [size=-1]Hello Group--[/size][size=-1]I have a stamp2 alternately reading "data out" on two A to D convertors, first one, then the other and repeat.· After each is read 20 or 30 times, I want to read a third ADC that measures the battery supply voltage to the circuit.· This will tell me when the battery should be changed.[/size][size=-1]I'm thinking of using another ADC to read this supply voltage and the code to kick out of the main loop after 20 or 30 readings, read the voltage from the third ADC, then go back into the main loop to do another 20 or 30 readings.[/size][size=-1]Would any of you be able to provide me with a sample of the code needed to do jump out after 20 or 30, read the third ADC and go back ito the main loop?[/size][size=-1]Has anyone had experience doing this before from a hardware standpoint?[/size][size=-1]TIA for any help.·· --Don[/size]
  • ArchiverArchiver Posts: 46,084
    edited 2000-08-30 00:33
    The structure should be something like this:

    I var byte 'variable to count

    main:
    for i= 1 to 30
    gosub readADC1
    gosub readADC2
    next
    gosub readBatt
    goto main

    readADC1:
    'put code to read here
    'do something with result
    return

    readADC2:
    'put code to read here
    'do something with result
    return

    readBatt:
    'put code to read here
    'do something with result
    return

    ACJacques


    Don Bannon wrote:
    >
    > Hello Group--
    > I have a stamp2 alternately reading "data out" on two A to D
    > convertors, first one, then the other and repeat. After each is read
    > 20 or 30 times, I want to read a third ADC that measures the battery
    > supply voltage to the circuit. This will tell me when the battery
    > should be changed.
    > I'm thinking of using another ADC to read this supply voltage and the
    > code to kick out of the main loop after 20 or 30 readings, read the
    > voltage from the third ADC, then go back into the main loop to do
    > another 20 or 30 readings.
    > Would any of you be able to provide me with a sample of the code
    > needed to do jump out after 20 or 30, read the third ADC and go back
    > ito the main loop?
    > Has anyone had experience doing this before from a hardware
    > standpoint?
    > TIA for any help. --Don
Sign In or Register to comment.