PICAXE-18X, Interface with a TI TPIC6259 Power Latch

copyright, Peter H Anderson, Baltimore, MD, June, '04


Introduction.

This note illutrates how to interface with the Texas Instruments TPIC6259 8-bit addressable latch.

The TPIC series of logic from TI is interesting in that the control interface uses TTL compatible logic (logic 0 near ground and logic one near +5 VDC), but the outputs are open drain FETs which are capable of sinking up to 250 mA per output with up to 40VDC outputs which may be used to drive relays, small lamps and similar. It is readily available from a number of sources, including Digikey for about $3.00.

The specific one of eight outputs to be addressed is determined by inputs S2, S1 and S0. The desired state of the output is determined by the state appearing on input D. The data is latched into the flip flop by bringing /G momentarily low.

Note that a logic one on the 'D' input which is then latched causes the output DMOS transistor to turn on. That is, the output goes to near ground causing the relay or lamp to operate. A logic zero on 'D' causes the output transistor to turn off.

All outputs may be turned off by applying a logic zero on the CLR input.

The TPIC6259 provides separate logic and power grounds. When configuring your circuit, connect the logic ground (LGND) to the processor ground. However, run a seaparate lead from the power ground (PGND) back to the supply using a separate lead. This avoids L-di/dt transients in the processor's ground which can raise havoc with processor resets and other erratic behavior.

One might question the wisdom of using six outputs to obtain a mere eight powwer outputs. However, this can be easly increased to 16 power outputs, or even 24 outputs by using either two or three TPIC6259 devices. Leads D, S2, S1, S0 and /CLR may be shared by all of the TPIC devices. The "cost" is simply providing a separate /G terminal for each TPIC6259 device.

Thus, to operate bit 3 on TPIC 2 is a matter of setting S2, S1 and S0 to 011, D to 1 and then bringing G2 momentarily low and again high to latch the data.

In program TPIC6259_1.Bas, I am controlling only a single TPIC6259 device. Program TPIC6259_2.Bas expands this control to three TPIC devices providing 24 power outputs.

Program TPIC6259_1.Bas


' TPIC6259_1.Bas (PICAXE-18X)
'
' Illustrates an interface with the Texas Instruments TPIC6259 8-bit
' Addressable Latch with FET Outputs.
'
' Initially clears all eight oututs.
'
' Operates output Drain 0 for a period of time and then releases it.
' This is repeated for output Drain 1, 2 and 3.
'
' PICAXE-18X                          TPIC6259
'
' Output5 (term 11) ----------------- /G (term 13)
' Output4 (term 10) ----------------- CLR (term 19)
' Output3 (term 9) ------------------ D (term 18)
'
' Output2 (term 8) ------------------ S2 (term 12)
' Output1 (term 7) ------------------ S1 (term 8)
' Output0 (term 6) ------------------ S0 (term 3)
'
' Uses about 128 bytes and could probably be accommodated in a less expensive
' PICAXE-18A.
'
' copyright, Peter H Anderson, Baltimore, MD, May, '04


    Symbol LatchDataBit = B0	' 0 or 1
    Symbol LatchSelectAddress = B1 ' 0 - 7

    Symbol CurrentPORTB = B2

    Symbol D = 3        ' Data
    Symbol CLR = 4      ' Clear all TPIC6259 outputs
    Symbol G0 = 5

Main:
    High G0
    Low CLR		' clear all outputs
    High CLR

Main_1:

    LatchDataBit = 1
    LatchSelectAddress = 0
    GoSub Latch

    Pause 200

    LatchDataBit = 0
    LatchSelectAddress = 0
    GoSub Latch


    LatchDataBit = 1
    LatchSelectAddress = 1
    GoSub Latch

    Pause 200

    LatchDataBit = 0
    LatchSelectAddress = 1
    GoSub Latch

    LatchDataBit = 1
    LatchSelectAddress = 2
    GoSub Latch

    Pause 200

    LatchDataBit = 0
    LatchSelectAddress = 2
    GoSub Latch

    LatchDataBit = 1
    LatchSelectAddress = 3
    GoSub Latch

    Pause 200

    LatchDataBit = 0
    LatchSelectAddress = 3
    GoSub Latch

    Goto Main_1

Latch:
    ' set the output identified in LatchSelectAddress to state D

    High G0		                        ' be sure G is high
    Peek $06, CurrentPORTB                      ' determine current sate of outputs
    Pins = CurrentPORTB & %11111000 | LatchSelectAddress ' setup S2, S1 and S0

    Branch LatchDataBit, (Latch_0, Latch_1)      ' set D to appropriate state

Latch_0:
    Low D
    Goto Latch_2

Latch_1:
    High D
    GoTo Latch_2

Latch_2:
    Low G0	' latch the D into the addressed flip flop
    High G0
    Return


Program TPIC6259_2.Bas


' TPIC6259_2.Bas (PICAXE-18X)
'
' Illustrates an interface with three Texas Instruments TPIC6259 8-bit
' Addressable Latches.
'
' Initially clears all eight oututs on each of the three latches.
'
' Operates output Drain 4 on Device 0 for a period of time and then releases it.
' This is repeated for output Drain 5 on Device 0, Drain 6 on Device 1 and Drain 7
' on Device 2.
'
' PICAXE-18X                          TPIC6259              TPIC6259         TPIC6259
'                                     Dev 0                 Dev 1            Dev 2
'
' Output7 (term 13) ---------------------------------------------------------- /G (term 13)
' Output6 (term 12) ----------------------------------------- /G (term 13)
' Output5 (term 11) ----------------- /G (term 13)
' Output4 (term 10) ----------------- CLR (term 19) --------- CLR ------------ CLR
' Output3 (term 9) ------------------ D (term 18) ----------- D -------------- D
'
' Output2 (term 8) ------------------ S2 (term 12) ---------- S2 ------------- S2
' Output1 (term 7) ------------------ S1 (term 8) ----------- S1 ------------- S1
' Output0 (term 6) ------------------ S0 (term 3) ----------- S0 ------------- S0
'
' Uses about 174 bytes and could probably be accommodated in a less expensive
' PICAXE-18A.
'
' copyright, Peter H Anderson, Baltimore, MD, May, '04


    Symbol LatchDataBit = B0		' 0 or 1
    Symbol LatchSelectAddress = B1 	' 0 - 7
    Symbol DeviceNum = B2		' 0, 1, 2

    Symbol GateSelect = B3

    Symbol CurrentPORTB = B4

    Symbol D = 3        ' Data
    Symbol CLR = 4      ' Clear all TPIC6259 outputs
    Symbol G0 = 5
    Symbol G1 = 6
    Symbol G2 = 7

Main:
    High G0
    Low CLR		' clear all outputs
    High CLR

Main_1:

    DeviceNum = 0
    LatchSelectAddress = 4
    LatchDataBit = 1
    GoSub Latch

    Pause 200

    DeviceNum = 0
    LatchDataBit = 0
    LatchSelectAddress = 4
    GoSub Latch

    DeviceNum = 0
    LatchDataBit = 1
    LatchSelectAddress = 5
    GoSub Latch

    Pause 200

    DeviceNum = 0
    LatchDataBit = 0
    LatchSelectAddress = 5
    GoSub Latch

    DeviceNum = 1
    LatchDataBit = 1
    LatchSelectAddress = 6
    GoSub Latch

    Pause 200

    DeviceNum = 1
    LatchDataBit = 0
    LatchSelectAddress = 6
    GoSub Latch

    DeviceNum = 2

    LatchDataBit = 1
    LatchSelectAddress = 7
    GoSub Latch

    Pause 200

    DeviceNum = 2
    LatchDataBit = 0
    LatchSelectAddress = 7
    GoSub Latch

    Goto Main_1

Latch:
    ' set the output identified in LatchSelectAddress on the specified device to state D
    Peek $06, CurrentPORTB
    Pins = CurrentPORTB | %11110000  ' be sure G2, G1 and G0 at one, /CLR at 1

    Peek $06, CurrentPORTB
    Pins = CurrentPORTB & %11111000 | LatchSelectAddress ' setup S2, S1 and S0

    Branch LatchDataBit, (Latch_0, Latch_1)      ' set D to appropriate state

Latch_0:
    Low D
    Goto Latch_2

Latch_1:
    High D
    GoTo Latch_2

Latch_2:
    Lookup DeviceNum, (%11000000, %10100000, %01100000), GateSelect
    Peek $06, CurrentPORTB
    Pins = CurrentPortB & %00011111 | GateSelect	' bring appropriate gate bit low
    Pins = CurrentPortB | %11100000                   ' bring it back to high
    Return