Skip to content

NCV7240 Module

This module contains the Zerynth driver for the OnSemi NCV7240 automotive eight channel low-side/relay driver, that can be controlled with a standard SPI interface or parallel input pins.

Each output driver is protected for over load current and includes an output clamp for inductive loads. Open load or shorts to ground can be detected when the driver is in the off state.

class NCV7240

class NCV7240()

The NCV7240 class implements several methods to access the I/O expander over an SPI bus and easily control its features.

Each one of the 8 channels can be configured in one of 4 modes:

  • Standby (default) - the channel is disabled
  • On - the output driver is active (low), with over-load fault detection
  • Off - the output driver is inactive, with open-load fault detection
  • Input - the output driver on/off state is controlled by input pins (PWM capable)

Note

Faults are latched and must be cleared by switching the channel to Standby mode to attempt recovery.

Note

Off mode and open-load detection can be used as way to read channels as digital inputs.

NCV7240.init

__init__(spidrv,cs,clk=500000)

Creates an instance of NCV7240 class, using the specified SPI settings.

Arguments:

  • spidrv – the SPI driver to use (SPI0, …)
  • cs – Chip select pin to access the NCV7240 chip
  • clk – Clock speed, default 500 kHz

Note

SPI mode is fixed by the slave chip protocol (CPOL=0,CPHA=1)

NCV7240.setChannel

setChannel(channel,mode)

Set one channel to the specified mode.

Arguments:

  • channel – Index of the channel (0-7)
  • mode – One of the four possible modes: CH_STANDBY, CH_ON, CH_OFF, CH_INPUT
NCV7240.setAllChannels

setAllChannels(mode)

Set all channels to the specified mode.

Arguments: mode – One of the four possible modes: CH_STANDBY, CH_ON, CH_OFF, CH_INPUT

Note

If mode is a list or a tuple, each element specifies the corresponding channel mode.

NCV7240.getChannel

getChannel(channel)

Get the status of the specified channel.

Arguments: channel – Index of the channel (0-7).

Returns: One of the two possible states: CH_OPEN, CH_FAULT

Note

Put the channel in Standby mode to clear status.

NCV7240.getAllChannels

getAllChannels()

Get the status of all channels.

Returns: A tuple where each element specifies the corresponding channel state: CH_OPEN or CH_FAULT

Note

Put the channel in Standby mode to clear status.

NCV7240.channelInputMode

channelInputMode(channel)

Set the specified channel to input mode (output driver state is controlled directly by the corresponding input pin on the NCV7240 chip).

Arguments: channel – Index of the channel (0-7)

NCV7240.channelStandby

channelStandby(channel)

Set the specified channel to standby mode (output driver and fault detection are disabled, fault status cleared).

Arguments: channel – Index of the channel (0-7)

NCV7240.channelOn

channelOn(channel)

Switch the specified channel output driver on (polarity active-low, over-load/over-temperature fault detection is active).

Arguments: channel – Index of the channel (0-7)

NCV7240.channelOff

channelOff(channel)

Switch the specified channel output driver off (open-load fault detection current is active).

Arguments: channel – Index of the channel (0-7)

NCV7240.isChannelOpen

isChannelOpen(channel)

Returns whether the channel status indicates an open-load fault (only meaningful when the channel is off).

Arguments: channel – Index of the channel (0-7)

Note

Put the channel in Standby mode to clear fault status.

NCV7240.isChannelFault

isChannelFault(channel)

Returns whether the channel status indicates an over-current/over-temperature fault (only meaningful when the channel is on).

Arguments: channel – Index of the channel (0-7)

Note

Put the channel in Standby mode to clear fault status.