TS-BAT10

From embeddedTS Manuals
TS-BAT10
TS-BAT10.jpg
Product Page
Documents
Schematic
Battery Datasheet

Overview

The TS-BAT10 is a PC/104 peripheral that contains two 4.2v 2200mA LiPo batteries wired in parallel to provide a high power battery back up system for Technologic Systems' Single Board computers as well as most other PC/104 SBC modules. The TS-BAT10 acts as both a regulator and a battery back up system, accepting from 8VDC to 30VDC and powering the entire PC/104 stack via the 5+VDC pins on the 64-pin PC/104 connector. The batteries are charged via two dedicated LiPo chargers that will charge the batteries until they reach 4.2 volts or for a maximum of a 6 hour charge time. Each battery has an indication of "charging", "charge complete", or "fault", these three states can be read from userspace by the SBC. Each battery can also have a slow 250mA charge current, or a fast charge 500mA current depending on the current source available.

Usage with 3rd party devices

Please note this peripheral is not tested with third party SBCs or connected peripherals and is not guaranteed to operate as intended.

This peripheral does not adhere to the standard PC/104 pinout. Before third party SBCs or peripherals are connected, please review the schematics. Most notably the standard signal +12V has the BAT10's VIN connected which can be 5-30V depending directly on the connected powersupply.

Getting Started

Be sure to remove all power from the system and install a jumper on position 4 (battery backup disable) of the 2x4 pin header to disable battery power before connecting TS-BAT10 to a PC/104 stack. A jumper also needs be installed in one of the three address decode jumper positions. Exactly one address jumper must be installed, resulting in the TS-BAT10 using one of the following PC/104 address ranges:

  • 0x110-0x11F
  • 0x150-0x15F
  • 0x300-0x30F

On Technologic Systems ARM SBCs, that base address must be added to the 8 bit PC/104 base address for the particular system.

Operation

Note: The minimum input voltage for the TS-BAT10 is 8 volts DC. The internal regulators will ensure 5 volts is made available to the SBC through either the +5 Volt output, or through the PC104 hdeader. Providing the TS-BAT10 with less than 8 volts can risk unexpected and undefined behavior.

To use the TS-BAT10 for the first time, add it to a PC/104 stack, with jumpers installed as described above, and provide 8-28V DC on the power input connector. The TS-BAT10 will begin providing a regulated 5V to the SBC. The batteries will not be charging and will be disabled, and none of the status LEDs should be lit. JP4 can now be removed to allow battery backup. With JP4 installed, battery power will never be used.

Once battery backup is enabled, the TS-BAT10 will power the system any time external power is removed. The TS-BAT10 uses a boost regulator in order to boost the 4.2V DC provided by the two LiPo batteries to the necessary 5V DC for the PC/104 system. The input regulator for the external power supply requires at least 4.5V DC in order to provide power to the system. With an input voltage in the range of 4.5-5V DC the boost regulator will bring the voltage up to the proper levels.

Battery Charging Sequence

Once the TS-BAT10 is provided at least 4.5V DC, the host SBC can instruct the battery charging ICs to begin their charging cycle. Using the timers is highly recommended to provide safe charging. The timer on the charging devices is set for 6 hours; if this expires the batteries will immediately stop charging and show a fault.

In order to begin a slow charge with the timers enabled, write 0x78 to the TS-BAT10 address space. Both red "charging" (CHG) LEDs will turn on. This will draw an additional 500mA (250mA for each battery) for the duration of the charge cycle. For a fast charge with the timers enabled, write 0x18 to the TS-BAT10 address space. This will cause the TS-BAT10 to draw an additional 1A of current from the external power supply (500mA for each battery).

The standard 5V DC @ 1A power supply from embeddedTS will not be able to provide enough current to do a fast charge as well as provide power to the SBC. If the regulated 5V DC line slumps below 4.5V DC it will be unable to charge the batteries properly and will suspend charging until the proper voltage is available. It is not recommended to charge each battery individually unless there is a guarantee that the system will not go in to battery backup mode until both batteries are charged to the same level. Unequal charge levels can result in imbalanced current draw which can result in damage to the battery packs.

The charge controllers are intelligent and have automatic cutoff when the batteries are at the correct voltage, the batteries overheat, or the max charge time is exceeded. To maximize the lifetime (number of recharge cycles) of a LiPo battery, it is best to wait until the batteries report they are below 3.3V and then begin a full charge cycle. This is recommended for use cases where the system will only use the TS-BAT10 for power for a brief time while it does an orderly shutdown. Note that the battery charge controllers will not automatically begin a charge cycle; they must be commanded to do so via software.

WARNING: Do not attempt to trickle charge the batteries! The TS-BAT10, the batteries, and the SBC can all be damaged by trickle charging and overcharging the batteries. Overcharging the LiPo batteries can result in a fire or explosion hazard. It is recommended to issue a charge command a maximum of once per boot cycle when power is applied.

Power Requirements

The TS-BAT10 takes a wide range of power input, from 5 volts through 30 volts. Given this range, power requirements are best expressed in wattage. The minimum available wattage to operate the TS-BAT10 is 6 watts plus the power required to service the attached single board computer. For example, the TS-7800-V2 SBC idle power requirement is 5 watts, so the minimum power requirement when paired with the TS-BAT10 is 11 watts.

Disabling Battery Backup Power

There are five conditions under which the batteries will be disabled from powering the system:

  • Valid external voltage is applied
  • The battery voltage is below 3.1V DC
  • A jumper in position 4 is installed
  • A large current draw has occurred and the regulated 5V DC drops below 4.45V DC
  • The battery backup is disabled by software

Battery backup functionality is enabled by default when the system is first powered up unless JP4 is installed.

LiPo batteries can be severely damaged if the cell voltage drops below 2.3V DC. In order to prevent permanent damage to the cells, the battery backup functionality is automatically disabled if the cell voltage drops below 3.1V DC. LiPo batteries hold their nominal voltage (in this case, 4.2V DC) through the length of their charge. The LiPo discharge curve will drop voltage sharply once the cells can no longer provide adequate current. There is a low battery register that indicates when the cells are below 3.3V DC. When the cells are less than 3.3V DC the LiPos will only be able to provide stable voltage for minutes at most. The recommended procedure is for the system to shut down when the batteries reach 3.3V DC and no external power is available.

The TS-BAT10 will ship with a jumper in position 4 to prevent the batteries from being drained during shipment. When this jumper is installed, the battery backup functionality will never be enabled; however, the batteries can still be charged using normal procedures.

The batteries and boost regulator can provide 4A of current. If that is exceeded under battery operation and the regulated 5V DC line drops below 4.45V DC, the batteries will immediately be disabled until the backup circuit is reset or external power is restored, see the Push Button section for more information.

If the battery backup is disabled via software, the power to the PC/104 system will be cut if the external input power is cut. The software disable will reset to its enabled state when external power is re-applied. Power can also be restored to the system via the battery backup by resetting the battery backup circuit, see the Push Button section for more information.

Push Button SW1/CN1

A momentary switch is installed on the side of the TS-BAT10. This switch can be read by software from the SBC to trigger a custom event, or to re-enable battery backup functionality while there is no external power and the battery backup has previously been disabled. Pressing and holding the switch for one second will cause the battery backup to become enabled and provide 5VDC through the PC/104 stack. See the Register Map for more information.

The two pins labeled CN1, located immediately next to the push button, can be used to connect an external button. If the two pins are shorted together it has the same effect on the system as if the push button were depressed. This can be used to bring out the push button to the outside of an enclosure.

The push button, combined with the low battery state, can be used in a power management application. A userspace process can poll the register; if a low battery condition occurs, or if the push button is depressed, the system can be commanded to safely shut down.

Jumper Configuration

Jumper Function
1 Use 0x110 as base
2 Use 0x150 as base
3 Use 0x300 as base
4 Disable battery backup
CN1 Switch contacts in parallel with SW1.

Register Map

Status Register (Read only)

This register is available at (SBC PC104 base) + (TS-BAT10 PC/104 address)

Read-only Status Register
Bit 0 0 = Battery 2 charge complete
1 = Battery 2 charge did not complete
Bit 1 0 = Battery 2 charging
1 = Battery 2 not charging
Bit 2 0 = Battery 1 charge complete
1 = Battery 1 charge did not complete
Bit 3 0 = Battery 1 charging
1 = Battery 1 not charging
Bit 4 0 = Battery backup disable jumper installed
1 = Battery backup disable jumper not installed
Bit 5 0 = input voltage not OK
1 = input voltage OK
Bit 6 0 = Battery under 3.3V
1 = Battery over 3.3V
Bit 7 0 = Push switch is closed
1 = Push switch is open
Note: bits 0-1 and 2-3 are also used to indicated a fault in charging. If they are both logic 1 (HiZ state) after initiating a charge cycle, either the timer has expired or the thermal cutoff of the batteries has engaged.

Configuration Register (Write only)

Write-only Configuration Register
Bit 0 0 = Enable battery backup
1 = Disable battery backup
Bit 1 0 = Enable battery 1 charge timer
1 = Disable battery 1 charge timer
Bit 2 0 = Enable battery 2 charge timer
1 = Disable battery 2 charge timer
Bit 3 0 = Disable battery 1 charge
1 = Enable battery 1 charge
Bit 4 0 = Disable battery 2 charge
1 = Enable battery 2 charge
Bit 5 0 = Charge battery 1 at 500mA
1 = Charge battery 1 at 250mA
Bit 6 0 = Charge battery 2 at 500mA
1 = Charge battery 2 at 250mA
Bit 7 Reserved

Safe Shutdown Example

The typical operation of the TS-BAT10 is to enable charging on startup, and safely shut down the board when power is lost. When the TS-BAT10 receives 5V it will reapply power to the PC104 bus. This can be accomplished with the tsbatctl and a startup script at /etc/init.d/ups-monitor.

This script should be created at /etc/init.d/ups-monitor.

#!/bin/sh
#/etc/init.d/ups-monitor

case "$1" in
        start)
                nohup /usr/bin/tsbatctl --jumper 1 -a 2 -b 2 --daemon &
                ;;
        poweroff)
                /usr/bin/tsbatctl --jumper 1 --disable-power
                ;;
        *)
                echo "Usage: ups-monitor start|poweroff" >&2
                exit 3
        ;;
esac

exit 0

The script will be called by runlevel 0's halt script by default, so this only needs to be added to the startup script.

chmod a+x /etc/init.d/ups-monitor 
update-rc.d ups-monitor defaults

This is tsbatctl.c and should be installed to /usr/bin/tsbatctl.

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <getopt.h>
#include <string.h>
 
// The mpeek/mpoke functions are specific to the TS-47XX, TS-7250-V2
unsigned int opt_pc104 = 0x81008000;
volatile uint8_t *muxbus = 0;
uint8_t mpeek8(uint16_t addr) 
{
    if(muxbus == 0) {
        int mem = open("/dev/mem", O_RDWR|O_SYNC);
        muxbus = mmap(0,
            getpagesize(),
            PROT_READ|PROT_WRITE,
            MAP_SHARED,
            mem,
            opt_pc104);
    }
    return muxbus[addr];
}
 
void mpoke8(uint16_t addr, uint8_t value)
{ 
    if(muxbus == 0) {
        int mem = open("/dev/mem", O_RDWR|O_SYNC);
        muxbus = mmap(0,
            getpagesize(),
            PROT_READ|PROT_WRITE,
            MAP_SHARED,
            mem,
            opt_pc104);
    }
    muxbus[addr] = value;
}
 
typedef enum
{
	SW1 = 1 << 7,
	BELOW33V = 1 << 6,
	HAVE_VDC5 = 1 << 5,
	BACKUPDISABLED = 1 << 4,
	BAT1CHARGING = 1 << 3,
	BAT1CHARGED = 1 << 2,
	BAT2CHARGING = 1 << 1,
	BAT2CHARGED = 1 << 0
} StatusFlags;
 
typedef enum
{
	RESERVED = 1 << 7,
	BAT2NOFASTCHARGE = 1 << 6,
	BAT1NOFASTCHARGE = 1 << 5,
	BAT2CHARGEEN = 1 << 4,
	BAT1CHARGEEN = 1 << 3,
	BAT2TIMERDISABLE = 1 << 2,
	BAT1TIMERDISABLE = 1 << 1,
	SOFTDISABLE = 1 << 0
} ConfigurationFlags;
 
void usage(char **argv) {
	fprintf(stderr,
	  "Usage: %s -j [1-3] [OPTIONS] ...\n"
	  "TS-BAT10 userspace driver utility.\n"
	  "\n"
	  "  -s, --status               Print the current status of the TS-BAT10\n"
	  "  -j, --jumper=              Specify jumper 1-3 for the I/O address (required)\n"
	  "  -e, --disable-power        Immediately cuts power to the system.  This should\n"
	  "                             normally be called after the system has finished syncing\n"
	  "                             the disk(s) during the shutdown process to prevent corruption\n"
	  "  -a, --charge-bat1=#        Specify 0-3 for battery 1 charge setting (default 0)\n"
	  "  -b, --charge-bat2=#        Specify 0-3 for battery 2 charge setting (default 0)\n"
	  "  -n, --disable-timer-bat1   Disable the charge timer for battery 1 (default on)\n"
	  "  -n, --disable-timer-bat2   Disable the charge timer for battery 2 (default on)\n"
	  "  -t, --daemon               Daemonize and run the shutdown command when batteries are low\n"
	  "  -k, --shutdown-app=APP     When daemonizing, specify another application other\n"
      "                             than the default \"/sbin/shutdown -h now\"\n"
	  "  -h, --help                 This help\n"
	  "\n"
	  "  The 2 Batteries have 3 settings for charge options:\n"
	  "		0 - Disable charge (default)\n"
	  "		1 - Enable Slow charge (250mA)\n"
	  "		2 - Enable Fast charge (500mA)\n"
	  "  The TS-BAT10 uses a write only register so previous write values cannot be detected."
	  "  When using any settings previous values must be passed if they are to be retained."
	  "  For example, to charge both batteries:\n"
	  "  %s --jumper 1 --charge-bat1 2 --charge-bat2 2 "
	  "\n",
	  argv[0], argv[0], argv[0]
	);
}
 
int main(int argc, char **argv) {
	int opt_status = 0;
	int opt_jumper = 0;
	int opt_bat1charge = 0;
	int opt_bat2charge = 0;
	int opt_bat1timer = 0;
	int opt_bat2timer = 0;
	int opt_poweroff = 0;
	char *opt_shutdownapp = "/sbin/shutdown -h now";
	int opt_daemon = 0;
	int opt_write = 0;
 
	int c;
	int offset;
	uint8_t value = 0, status = 0;
 
	static struct option long_options[] = {
	  { "status", 0, 0, 's' },
	  { "jumper", 1, 0, 'j' },
	  { "charge-bat1", 1, 0, 'a' },
	  { "charge-bat2", 1, 0, 'b' },
	  { "disable-timer-bat1", 1, 0, 'n' },
	  { "disable-timer-bat2", 1, 0, 'o' },
	  { "pc104base", 1, 0, 'r' },
	  { "disable-power", 0, 0, 'e' },
	  { "daemon", 0, 0, 't' },
	  { "shutdown-app", 1, 0, 'k' },
	  { "help", 0, 0, 'h' },
	  { 0, 0, 0, 0 }
	};
 
	while((c = getopt_long(argc, argv, "sj:a:b:n:o:r:tek:h", long_options, NULL)) != -1) {
		switch(c) {
			case 's':
				opt_status = 1;
				break;
			case 'j':
				opt_jumper = strtoul(optarg, NULL, 0);
				break;
			case 'a':
				opt_bat1charge = strtoul(optarg, NULL, 0);
				opt_write = 1;
				break;
			case 'b':
				opt_bat2charge = strtoul(optarg, NULL, 0);
				opt_write = 1;
				break;
			case 'n':
				opt_bat1timer = strtoul(optarg, NULL, 0);
				opt_write = 1;
				break;
			case 'o':
				opt_bat2timer = strtoul(optarg, NULL, 0);
				opt_write = 1;
				break;
			case 'e':
				opt_poweroff = 1;
				opt_write = 1;
				break;
			case 'r':
				opt_pc104 = strtoul(optarg, NULL, 0);
				break;
			case 'k':
				opt_shutdownapp = strdup(optarg);
				break;
			case 't':
				opt_daemon = 1;
				break;
			case 'h':
				usage(argv);
				return 0;
			default:
				usage(argv);
				fprintf(stderr, "Unknown option \"%c\"\n", c);
				return 1;
		}
	}
 
	if(opt_bat1timer < 0 || opt_bat1timer > 1 ||
	   opt_bat2timer < 0 || opt_bat2timer > 1) {
		usage(argv);
		fprintf(stderr, "Timer value must be 0 or 1\n");
		return 1;
	}
 
	if(opt_bat1charge < 0 || opt_bat1charge > 2 ||
	   opt_bat2charge < 0 || opt_bat2charge > 2) {
		usage(argv);
		fprintf(stderr, "Charge value must be between 0-2\n");
		return 1;
	}
 
	if(opt_jumper < 1 || opt_jumper > 3) {
		usage(argv);
		fprintf(stderr, "The jumper value must be specified between 1-3\n");
		return 1;
	}
 
	if(opt_jumper == 1) offset=0x110;
	else if (opt_jumper == 2) offset=0x150;
	else if (opt_jumper == 3) offset=0x300;
 
 	status = mpeek8(offset);
	if(opt_status) {
		fprintf(stdout,
			"sw1=%d\n"
			"below33=%d\n"
			"have_5vdc=%d\n"
			"jp4=%d\n"
			"bat1charging=%d\n"
			"bat2charging=%d\n"
			"bat1charged=%d\n"
			"bat2charged=%d\n",
			status & SW1 ? 0 : 1,
			status & BELOW33V ? 0 : 1,
			status & HAVE_VDC5 ? 1 : 0,
			status & BACKUPDISABLED ? 0 : 1,
			status & BAT1CHARGING ? 0 : 1,
			status & BAT2CHARGING ? 0 : 1,
			status & BAT1CHARGED ? 0 : 1,
			status & BAT2CHARGED ? 0 : 1
		);
	}
 
	if((opt_bat1charge | opt_bat2charge) && (~status & BACKUPDISABLED)){
		fprintf(stderr, "Cannot enable charging with JP4 on.  Exiting.\n");
		return 1;
	}
 
	if(opt_write){
		if(opt_poweroff) value |= SOFTDISABLE;
		if(opt_bat1charge == 1) value |= (BAT1CHARGEEN | BAT1NOFASTCHARGE);
		if(opt_bat1charge == 2) value |= (BAT1CHARGEEN);
		if(opt_bat2charge == 1) value |= (BAT2CHARGEEN | BAT2NOFASTCHARGE);
		if(opt_bat2charge == 2) value |= (BAT2CHARGEEN);
		if(opt_bat1timer) value |= BAT1TIMERDISABLE;
		if(opt_bat2timer) value |= BAT2TIMERDISABLE;

		if((status & BELOW33V) && opt_bat1charge) {
			fprintf(stderr, "bat1 charged.  Skipping charging.\n");
			value &= (~BAT1CHARGEEN);
		}
		
		if((status & BELOW33V) && opt_bat2charge) {
			fprintf(stderr, "bat2 charged.  Skipping charging.\n");
			value &= ~(BAT2CHARGEEN);
		}

		mpoke8(offset, value);
	}
 
	if(!opt_daemon) return 0;
 
	while(1) {
		status = mpeek8(offset);
 
		if(~status & HAVE_VDC5) {
			printf("shutting down: %s\n", opt_shutdownapp);
			system(opt_shutdownapp);
			return 0;
		}
		sleep(10);
	}
}

This can be compiled with:

gcc tsbatctl.c -o tsbatctl -mcpu=arm9
cp tsbatctl /usr/bin/tsbatctl

Reboot/Sleep support

Reboot/Sleep on REV A boards

Bat10-jp1.jpg

On some boards the sleep mode or reboot mechanism will depend on the 5V going into the terminal block header on the board rather than going through the PC104 bus. Test your board first to find out if this modification is necessary. To redirect 5V to support both of these modes you can depopulate R18 and R19. This will prevent the 5V from going through the PC104 bus. The pad furthest away from the PC104 connector in the JP1 box provides the regulated 5V. Connect this to the + power connector on your System-on-Module (SoM) baseboard or single board computer.

  • The TS-7800 requires this modification for sleep and rebooting.
  • The TS-8160 requires this for sleep mode.

Reboot/Sleep on REV B and later boards

The REV B BAT10 includes a "JP1" jumper that passes 5V through the PC104 bus. On boards such as TS-7800 or TS-8160 this would be needed for Reboot or sleep mode support. If this jumper is installed, which it is by default, it will pass 5V down the PC104 bus. To fix reboot/sleep mode on many hosts, the power will need to come from the 5V output. JP1 can be removed, and CN2 provides a regulated 5V which can be connected to the PC104 host.

Errata

Incorrect silkscreen on TS-BAT10 Rev A

Synopsis Incorrect silkscreen on TS-BAT10, shows incorrect address
Severity Minor
Affected TS-BAT10 Rev A

Description:

The TS-BAT10 Rev A has a typo on the silkscreen. It lists JP3 as being address 0x310. It should read 0x300, the documentation on this is correct and should be followed instead of the board markings. REV A units shipped after 2-28-13 include a sticker with the corrected address.

TS-BAT10-Label.jpg

Incorrect resistor value for R75

Synopsis Incorrect value for R75
Severity Major
Affected TS-BAT10 Rev A (shipped before Jan 30th, 2013)

Description:

The TS-BAT10 units shipped before Jan 30th, 2013 had an improper value for R75 which would cause voltage up to 5.7V when power is connected to the TS-BAT10. Any units ordered before this date should be sent for repair through an RMA.

Product Notes

FCC Advisory

This equipment generates, uses, and can radiate radio frequency energy and if not installed and used properly (that is, in strict accordance with the manufacturer's instructions), may cause interference to radio and television reception. It has been type tested and found to comply with the limits for a Class A digital device in accordance with the specifications in Part 15 of FCC Rules, which are designed to provide reasonable protection against such interference when operated in a commercial environment. Operation of this equipment in a residential area is likely to cause interference, in which case the owner will be required to correct the interference at his own expense.

If this equipment does cause interference, which can be determined by turning the unit on and off, the user is encouraged to try the following measures to correct the interference:

Reorient the receiving antenna. Relocate the unit with respect to the receiver. Plug the unit into a different outlet so that the unit and receiver are on different branch circuits. Ensure that mounting screws and connector attachment screws are tightly secured. Ensure that good quality, shielded, and grounded cables are used for all data communications. If necessary, the user should consult the dealer or an experienced radio/television technician for additional suggestions. The following booklets prepared by the Federal Communications Commission (FCC) may also prove helpful:

How to Identify and Resolve Radio-TV Interference Problems (Stock No. 004-000-000345-4) Interface Handbook (Stock No. 004-000-004505-7) These booklets may be purchased from the Superintendent of Documents, U.S. Government Printing Office, Washington, DC 20402.

Limited Warranty

See our Terms and Conditions for more details.