The 24V Protected Switch Shield with BTT6030-2ERA and BTT6020-1ERA is a power switch evaluation board compatible with Arduino microcontroller boards and with Infineon’s XMC™ microcontroller kits using the Arduino form factor. The shield is equipped with three protected high-side power MOSFETs out of the PROFET™+ 24V family (2x BTT6030-2ERA, 1x BTT6020-1ERA ) offering five 24 V channels in total. Infineon’s PROFET™+ 24V protected high-side switches (BTT6xxx) drive resistive, capacitive as well as inductive loads (e.g. truck bulbs, car bulbs, valves, motors, relays, capacitors, LEDs…). The power switches are controlled via the INx (input) pins. The PROFET™+ 24V devices also provide a sense current at the IS pin, which can be enabled via the DEN (Diagnosis ENable) pin. For the two-channel devices, the sensed channel is selected via the DSEL (Diagnosis SELect) pin. For each device, the sense signal (IS) is connected to its own ADC channel of the microcontroller.
Dissecting the ShieldIN0_0: Input to switch channel 0 on PROFETTM+ 24V device no. 0
IN1_0: Input to switch channel 1 on PROFETTM+ 24V device no. 0
IN0_1: Input to switch channel 0 on PROFETTM+ 24V device no. 1
IN1_1: Input to switch channel 1 on PROFETTM+ 24V device no. 1
IN0_2: Input to switch channel on PROFETTM+ 24V device no. 2
DEN_0: Turns diagnosis for PROFETTM+ 24V device no. 0 on or off
DEN_1: Turns diagnosis for PROFETTM+ 24V device no. 1 on or off
DEN_2: Turns diagnosis for PROFETTM+ 24V device no. 2 on or off
DSEL_0: Selects if the diagnosis of channel 0 or 1 is muxed to the IS Pin
DSEL_1: Selects if the diagnosis of channel 0 or 1 is muxed to the IS Pin
IS_0: Current sense of PROFETTM+ 24V device no. 0
IS_1: Current sense of PROFETTM+ 24V device no. 1
IS_2: Current sense of PROFETTM+ 24V device no. 2
SoftwareAfter connecting the Arduino, which the shield is plugged into, to your computer, launch the Arduino IDE and install the high side switch ino library. Do this by clicking on Sketch and then hovering over Include Library and then clicking on Manage Libraries... In the search bar: type high side switch ino and then you'll find the option to install the library.
Now that the library is properly installed you have the option to explore various pre-written code examples. To do so: simply click on File and then hover over examples and high-side-switch-ino and choose whichever example code snippet you wish.
This library essentially saves you the hassle of having to manually address each pin in your code and controlling your shield in terms of analog output signals for the channel control, digital output for enabling diagnostic features/channels, and analog inputs for using Infineon's current sense diagnostic features. However, if that is what you desire check out the last section of this protip.
Setup codeWe start by including our library and then using the hss namespace
#include <hss-shield-btt60xx-ino.hpp>
using namespace hss;
Consequently, we instantiate a shield object by whichever name we desire (in the case of the code snippet we currently have: it's HSS). Additionally, we also instantiate an error variable, to which the value of a definition called OK is set (you'll know why below).
Btt60xxShieldIno HSS = Btt60xxShieldIno();
Error_t err = OK;
Jumping into our setup function: all we have to do is initialize our HSS object, which we just instantiated using the init() function. This function returns an error code, which we will compare with the value we originally assigned to our error variable (OK definition). To ensure that everything is going right you can check the serial monitor on which the controller tells us if initialization was successful. If you follow all that your code should by now look like this:
#include <hss-shield-btt60xx-ino.hpp>
using namespace hss;
Btt60xxShieldIno HSS = Btt60xxShieldIno();
Error_t err = OK;
void setup()
{
/** Serial initialization */
Serial.begin(9600);
Serial.println("Serial initialized");
/** Initialization of the High-Side-Switch-Board */
err = HSS.init();
if(OK!=err)
{
Serial.println("Initialization failed!");
}
else
Serial.println("Initialization successful!");
}
Errorcodes that could possibly be returned are:
OK
:
No error
INTF_ERROR
: Interface error
CONF_ERROR
: Configuration error
READ_ERROR
: Read error
WRITE_ERROR
: Write error
NULLPTR_ERROR
: Null pointer error
INVALID_CH_ERROR
: Invalid channel error
UNSUPPORTED_OP_ERROR
: Invalid channel error
INIT_ERROR
: Not initialized
Now that the setup is fully done, we have the option to actually control the switch channels and check the diagnostics of our channels. For our high side switch channel control, we have two main functions, which are the switchesHxOn(bool h0_0 = false, bool h1_0 = false, bool h0_1 = false, bool h1_1 = false, bool h2 = false)
andswitchesHxOff(bool h0_0 = false, bool h1_0 = false, bool h0_1 = false, bool h1_1 = false, bool h2 = false).
Those two functions take in 5 values (either 0s or 1s / true or false) that indicate their target channels of operation. You could also switch on/off a single channel at a time by using either the switchHxOff() or the switchHxOn() functions, where both take in the target switch number where:
Switch
0
- Profet 0 (BTT6030 - channel 0)
Switch 1
- Profet 0 (BTT6030 - channel 1)
Switch 2
- Profet 1 (BTT6030 - channel 0)
Switch 3
- Profet 1 (BTT6030 - channel 1)
Switch 4
- Profet 2 (Single channel)
The following code snippet turns all the shield channels on for three seconds and then turns them off again for three consecutive seconds.
void loop(){
HSS.switchesHxOn(1,1,1,1,1);
delay(3000);
HSS.switchesHxOff(1,1,1,1,1);
delay(3000);
}
Diagnostics:
The MVP function of our library for diagnosis is the readDiagx(uint8_t x) function. This function returns a DiagStatus_t type value. It takes in a number from 0 to 4 which represents the switch number where:Switch
0
- Profet 0 (BTT6030 - channel 0)
Switch 1
- Profet 0 (BTT6030 - channel 1)
Switch 2
- Profet 1 (BTT6030 - channel 0)
Switch 3
- Profet 1 (BTT6030 - channel 1)
Switch 4
- Profet 2 (Single channel)
The returned diagnosis status could be:
DIAG_READ_ERROR:
Read Error
NOT_ENABLED:
Diagnosis not enabled
NORMAL
Switch works correctly
FAULT
:
Switch is in fault condition (Is_fault at IS pin), which can mean “Short to GND”, “Overtemperature” or “Overload”
FAULT_OL_IC:
Switch is either in Open Load (whit enable channel) or inverse current is flowing
SHORT_TO_GND_OR_OT:
Short to the ground or Overtemperature detected
SHORT_TO_VSS:
Short to the supply voltage
OPEN_LOAD:
Open load detected
Another diagnostics feature is Infineon's current sense feature, which allows us to find out the value of the current flowing through our load.
The function in charge of reading the current is readIsx(uint8_t x)
. Where just like the other diagnostics function it also takes in a switch number x. The readIsx(uint8_t x)
function returns the value of the current in the form of a float in the unit of Amperes.
The following loop function code snippet demonstrates the use of these diagnostics features:
void loop(){
DiagStatus_t switchStatus;
float readAmps = 0.0;
HSS.switchHxOn(0);
delay(1000);
readAmps = HSS.readIsx(0);
Serial.print("Current flowing through the switch: ");
Serial.print(readAmps);
Serial.println(" A");
for(int i = 0; i<10; i++){
switchStatus = HSS.readDiagx(0);
}
if(switchStatus == FAULT_OL_IC)
{
Serial.println("Open load with enabled switch or inverse current detected!");
}
if(switchStatus == FAULT)
{
Serial.println("Overtemperature, overload or shot to ground detected!");
}
if(switchStatus == NORMAL)
{
Serial.println("Normal operation!");
}
HSS.switchHxOff(0);
delay(1000);
}
In addition to the setup code we had above, this code turns on switch number 0, prints out its diagnostics, and turns the switch off again. (The serial output of the board is presented in the screenshot below).
The current sense feature provided with the PROFET device comes with an internal exponential filter. The exponential filter serves to smoothen the signal and reduce the effect of noise.
"The raw data sequence is often represented by x_{t} beginning at time t=0, and the output of the exponential smoothing algorithm is commonly written as s_{t}, which may be regarded as the best estimate of what the next value of x will be. When the sequence of observations begins at time t=0, the simplest form of exponential smoothing is given by the formulas:
To use this exponential filter simply put the readDiagx()
function in a loop each time you use them (just like indicated in the code above).
PROFET devices support Infineon's current sense feature, which essentially makes them produce a current proportional to the current flowing through the load. This gives you the capacity to monitor your circuit's behavior and to always ensure that everything is working in the plan. The pin that provides the current sense feedback I S pin, wherein our respective shield, we have 3 IS pins for our three PROFET devices.
Since two of our PROFET devices have two output channels, a multiplexer is used to separate each channel's IS pin output, (where only one of those outputs could be connected to the IS pin at a time) this is implemented via a multiplexer; that takes in the DSEL signal.
Each of those three IS pins is connected to a resistor which provides a voltage input to the analog input pins of the Arduino (A0, A1, A2).
If you were to write your own code to use the current sense feature you'll have to activate the diagnosis feature of each PROFET device by sending a logic HIGH signal to each respective DEN pin. If you're using the ARDUINO IDE you would do this manually by copying the following code snippet in your setup loop. (Of course,before copying this snippet into your code, you'd also have to set up all the pin functionalities manually in your code. You could find a code snippet below where you could find all the pins defined and a setup loop with all the individual pins are set up.)
//------------ENABLING DIAGNOSTICS ON ALL THE PROFET DEVICES ON THE SHIELD------------
digitalOuput(DEN_0,HIGH);
digitalOuput(DEN_1,HIGH);
digitalOuput(DEN_2,HIGH);
This code snippet enables the diagnostics feature on all the three PROFETs on our shield. Furthermore for the two BTT6030-2ERA PROFETS, as mentioned above we would have to select which output channel's diagnostics would be shown via the IS pin by either sending a logic LOW or HIGH signal to each DSEL pin (DSEL_0 and DSEL_1).
A resistor is connected to each of the PROFET's IS pins, which in turn produces a change in voltage, which could be sensed by the Arduino's analog input pins mentioned above. Arduino boards contain a multichannel, 10-bit analog to digital converter. This means that it will map input voltages between 0 and the operating voltage (usually 5V or 3.3V) into integer values between 0 and 1023, which would be the returned value from an analogRead function performed on the IS pins.
Examples of the diagnostic output of the PROFETS are shown in the table below, where K_ILIS is the ratio of the current flowing in the output load to the Sense current at the IS Pin which is typically 2240 for the BTT6030-2ERA PROFET and 2950 for the BTT6020-1ERA.
//-------------PIN DEFINITIONS------------------------------
const int DSEL_0 = 2;
const int IN1_0 = 3;
const int IN0_1 = 4;
const int DEN_1 = 5;
const int DSEL_1 = 6;
const int IN1_1 = 7;
const int IN0_2 = 8;
const int DEN_2 = 9;
const int IS_0 = A0;
const int IS_1 = A1;
const int IS_2 = A2;
const int IN0_0 = A3;
const int DEN_0 = A4;
//-------------END OF PIN DEFINITIONS------------------------
void setup() {
//------------- PIN MODE SETUP-------------------------------
pinMode(IN0_0,OUTPUT);
pinMode(IN1_0,OUTPUT);
pinMode(IN0_1,OUTPUT);
pinMode(IN1_1,OUTPUT);
pinMode(IN0_2,OUTPUT);
pinMode(IS_0,INPUT);
pinMode(IS_1,INPUT);
pinMode(IS_2,INPUT);
pinMode(DSEL_0,OUTPUT);
pinMode(DSEL_1,OUTPUT);
pinMode(DEN_2,OUTPUT);
pinMode(DEN_1,OUTPUT);
pinMode(DEN_0,OUTPUT);
//-----------------END OF PIN MODE SETUP--------------------
}
void loop(){
}
To
control your output channels you'll have to send a pulse width modulated signal to each individual output channel pin. For example, if you would want to drive all the output channels at full power you would have the following code snippet in your void loop:
//----------DRIVING ALL CHANNELS AT FULL POWER---------------------------
analogWrite(IN0_0,255);
analogWrite(IN1_0,255);
analogWrite(IN0_1,255);
analogWrite(IN1_1,255);
analogWrite(IN0_2,255);
For more information refer to the datasheets of the BTT6030-2ERA and BTT6020-1ERA
Comments
Please log in or sign up to comment.