AN-7669: Using the MAX14916PMB# with TMCM-0960- MotionPy
Introduction
This document introduces using the MAX14916PMB# with TMCM-0960-MotionPy V2.1. The MAX14916PMB# shown in Figure 1 is a peripheral module for the MAX14916 octal 1A/Quad 2A high-side switch with diagnostics. The MAX14916PMB# has four software configurable high-side switches, which are capable of delivering up to 2.4A (min) per channel. For more information, refer to the MAX14916 data sheet and the MAX14916PMB# product page. The basic functions of the MAX14916 have been implemented in a MicroPython environment for use on a TMCM0960-MotionPy board. A brief introduction on how to use these basic functions and how to set up the example are presented to enable the rapid prototyping and development.
Requirements
- MAX14916PMB#
- TMCM-0960-MotionPy V2.1 set up as shown in Application Note AN-061: TMCM-0960-MotionPy V21 with TMCL-Modules
- USB-C Cable
- Terminal connection to the TMCM-0960-MotionPy board
Connecting the Pmod™ Board
The MAX14916 communicates with a host controller using a SPI interface, which can be accessed through the PMOD-1 and PMOD-2 connectors on the TMCM-0960-MotionPy V2.1 board. The default configuration corresponds to the PMOD-1 connector as seen in Table 1. and Figure 2, where the MAX14916PMB# is the target device and the TMCM-0960-MotionPy is the controller device. In addition to the four SPI signals (CS, SCLK, MOSI and MISO), all the MAX14916 FAULT, READY, SYNCH, and ENABLE signals can be accessed through GPIOs.
MAX14916PMB# J1 | TMCM-0960-MotionPy | Description | ||
Pin Name | Pin No. | Pin Name | Pin No. | |
SPI_CS | 1 | CS01 | 1 | Chip Select |
SPI_MOSI | 2 | SPI1_MOSI | 3 | Controller Serial Data Out, Target Serial Data In |
SPI_MISO | 3 | SPI1_MISO | 5 | Controller Serial Data In, Target Serial Data Out |
SPI_SCLK | 4 | SPI1_SCK | 7 | Serial Clock |
ENABLE | 8 | GPO1 | 4 | MAX14916 EN pin |
SYNCH | 9 | GPO2 | 6 | MAX14916 SYNCH pin |
FAULT | 7 | CS02 | 2 | MAX14916 FAULT and COMERR pin |
READY | 10 | GPO3 | 8 | MAX14916 READY pin |
GND | 5, 11 | Ground | 9, 10 | Ground |
VCOM | 6, 12 | +3.3V | 11, 12 | +3.3V digital supply |
Note 1: On the TMCM-0960-MotionPy V2.1 schematic, the Pmod connectors are labeled as PMOD0 and PMOD1, but on the PCB silkscreen they are labeled as PMOD1 and PMOD2. In the driver, the connector variables are called pmod0 and pmod1.
Note 2: On the MAX14916PMB#, the connector J1 numbering convention is 1 to 6 for the outside row and 7 to 12 for the inside row. However, on the TMCM-0960-MotionPy V2.1 the Pmod connector numbering convention is 1, 3, 5, 7, 9, and 11 on one row and 2, 4, 6, 8, 10, and 12 on the other row. Despite this, the physical signal mapping is consistent.
Structure and Functions
The MAX14916 communicates with a host controller through SPI interface. SPI initialization, register read/write, and basic configuration and monitoring have been implemented in the max14916.py script. For more information on the TMCM-0960-MotionPy and its filesystem, refer to the Application Note AN-061: TMCM-0960-MotionPy V21 with TMCL-Modules.
The basic functions read (addr) and write (addr, data) are used to read and write registers in the MAX14916. To configure a channel's status, set_HSS (channel) can be used to select a channel to be turned ON. To turn OFF any channel, use clear_HSS (channel).
The MAX14916 LED matrix (fault and status) are set to manual control by default. To change the control scheme of the LED matrix, SLED_control (enable) and FLED_control (enable) can be used to allow manual control (enable=1) or autonomous control (enable=0). While in manual mode, individual LEDs can be set using set_SLED (LED, val) and set_FLED (LED, val), where the LED corresponds to the channel number, and LEDs can be turned ON (val=1) or OFF (val=0).
To take advantage of all diagnostics available on the MAX14916, open-wire fault detection can be turned ON for individual channels while the switch is ON (enable_OW_ON_fault (channel)) and/or when the switch is OFF (enable_OW_OFF_fault (channel)). The open-wire fault detection can also be turned OFF for each channel while the switch is ON or OFF using disable_OW_ON_fault (channel) and disable_OW_OFF_fault (channel) respectively. Short-toVDD detection can be enabled and disabled in a similar way using enable_ShVDD (channel) to enable the short-to-VDD detection for a channel and disable_ShVDD (channel) to disable.
Finally, faults can be monitored by reading respective register values. The current limit fault register is read using read_CurrLim_fault(). When short-to-VDD detection is enabled, short-to-VDD faults can be read using read_ShVDD_fault(). To read open-wire faults when they are enabled for when a switch is ON, use read_OW_ON_fault(), and when they are enabled for when a switch is OFF, use read_OW_OFF_fault(). For a full list of supported functions in the MAX14916 python driver, see Table 2.
Class | Function | Arguments | Descriptions |
MAX14916 | read (addr) | addr: (hex) valid register address | Reads register contents and verifies CRC. Returns 24-bit binary string. |
write (addr, data = "00000000") | addr (hex): valid register
address data (str): binary string to write to the register |
Writes data to register and verifies CRC. Returns 24- bit binary string. | |
set_HSS (channel) | channel (int): 1,2,3,4 | Turn ON the specified output channel. | |
clear_HSS (channel) | channel (int): 1,2,3,4 | Turn OFF the specified output channel. | |
read_HSS() | -- | Read the SetOUT register. Returns 8-bit binary string. | |
SLED_control (enable) | enable (int): 0 = Autonomous LED Mode, 1 = Manual LED Mode | Set the status LED matrix to manual mode or autonomous mode. | |
set_SLED (SLED, val) | SLED (int): 1,2,3,4 val (int): 0=OFF, 1=ON |
Configure the on-board status LEDs while the status LEDs are in Manual LED Mode. | |
FLED_control (enable) | enable (int): 0 = Autonomous LED Mode, 1 = Manual LED Mode | Set the fault LED matrix to manual mode or autonomous mode. | |
set_FLED (FLED, val) | FLED (int): 1,2,3,4 val (int): 0=OFF, 1=ON |
Configure the on-board fault LEDs while the fault LEDs are in Manual LED Mode. | |
EN (val) | val (int): 0=LOW, 1=HIGH | Configure the EN signal connected to the MAX14916. | |
SYNCH (val) | val (int): 0=LOW, 1=HIGH | Configure the SYNCH signal connected to the MAX14916. | |
read_global_err() | -- | Read the global error register on the MAX14916. Returns 8-bit binary string. | |
check_fault() | -- | Check the FAULT signal status. Returns boolean true or false depending on FAULT pin status. | |
enable_OW_ON_fault (channel) | channel (int): 1,2,3,4 | Enable the open-wire detection for a channel while the switch is in the ON position. | |
disable_OW_ON_fault (channel) | channel (int): 1,2,3,4 | Disable the open-wire detection for a channel while the switch is in the ON position. | |
read_OW_ON_fault() | -- | Read the open-wire detection register, OwOnChF, while the open-wire detection fault monitoring feature is enabled for switches in the ON position. Returns 8-bit binary string. | |
enable_OW_OFF_fault (channel) | channel (int): 1,2,3,4 | Enable the open-wire detection for a channel while the switch is in the OFF position. | |
disable_OW_OFF_fault (channel) | channel (int): 1,2,3,4 | Disable the open-wire detection for a channel while the switch is in the OFF position. | |
read_OW_OFF_fault() | -- | Read the open-wire detection register, OwOffChF, while the open-wire detection fault monitoring feature is enabled for switches in the OFF position. Returns 8-bit binary string. | |
enable_ShVDD (channel) | channel (int): 1,2,3,4 | Enable the short-to-VDD detection for a channel. | |
disable_ShVDD (channel) | channel (int): 1,2,3,4 | Disable the short-to-VDD detection for a channel. | |
read_ShVDD_fault() | -- | Read the short-to-VDD detection register while the short-to-VDD detection fault monitoring feature is enabled. Returns 8-bit binary string. | |
read_interrupt() | -- | Read the interrupt register. Returns 8-bit binary string. | |
read_CurrLim_fault() | -- | Read the current limit fault register. Returns 8-bit binary string. | |
set_FLED_stretch (timeout) | timeout (str): "0s", "1s", "2s", "3s" | Set the minimum on-time for the fault LED in autonomous control mode. | |
enable_FFilter() | -- | Enable fault bit filtering and blanking. | |
disable_FFilter() | -- | Enable fault bit filtering and blanking (real-time fault detection). | |
enable_FiltrLong() | -- | Select long blanking time (8ms) for filtering fault bits. | |
disable_FiltrLong() | -- | Select short blanking time (4ms) for filtering fault bits. | |
enable_FaultLatch() | -- | Enable fault bit latching. | |
disable_FaultLatch() | -- | Disable fault bit latching. | |
enable_SYNCH_WD() | -- | Enable the SYNCH pin watchdog. | |
disable_SYNCH_WD() | -- | Disable the SYNCH pin watchdog. | |
enable_VDD_ON_Thr() | -- | Use VDD_GOOD_R (16V typ) threshold after UVLO event. | |
disable_VDD_ON_Thr() | -- | Use UVLO_VDD_R (9V typ) threshold after UVLO event. | |
set_WD_To (SPI_Watchdog_To) | SPI_Watchdog_To (str): "0ms", "200ms", "600ms", or "1.2s" | Set SPI and SYNCH watchdog timeout value. | |
set_OWOff_Cs (current_val) | current_val (str): "20uA", "100uA", "300uA", or "600uA" | Set the pull-up current source magnitude for open-wire fault detection when the switch is in OFF state. | |
set_ShtVDD_Thr (voltage_thr) | voltage_thr (str): "9v", "10v", "12v", or "14v" | Set the short-to-VDD voltage threshold. | |
Masking (bit, enable=1) | bit (int): bit position in register enable (int): bit value to write (defaults to '1') | Set individual bits in the masking register to mask specific errors. |
Running the Example
To begin, use the example script max14916pmb_example.py. As shown in Figure 2, connect the MAX14916PMB# to the TMCM-0960-MotionPy V2.1 and a 24V power adapter to the MAX14916PMB# connector J2. Connect the TMCM-0960-MotionPy v2.1 to the PC using a USBC cable and start a serial terminal connection.
If you clone the Trinamic µPython repository, all files should be placed in the correct default position. If you have an older version of the repository downloaded onto the SD Card, to ensure that the example program works correctly, place the MAX14916PMB driver files in the following locations:
Example File: SDCARD:\PyTrinamicMicro\platforms\motionpy2\examples\modules\max
Driver File: SDCARD:\PyTrinamicMicro\platforms\motionpy2\modules\max
When the driver and example files are in the correct directories, then the example script can be executed with the following command:
exec(open("PyTrinamicMicro/platforms/motionpy2/examples/modules/max/max14916pm b_example.py").read()).
The example script configures both status and fault LED matrixes to autonomous mode, and then starting at Channel 1, it turns each channel ON one-by-one every second until all channels are turned ON. Once the channels are all turned ON, the open-wire detection feature (for both channel ON and channel OFF) is turned on for channel 1 and 2. Then the program waits 4 seconds. The open-wire detection register for ON channels, OwOnChF, is read and printed to the terminal. Each channel is then turned OFF one-by-one every second starting with channel 1.
With no external components connected to the output channels of the MAX14916PMB#, the serial output appears as shown in Figure 3.
Trademarks
Pmod™ is a trademark of Digilent, Inc.