The 12V Protected Switch Shield with BTS50010-1TAD from Infineon is a flexible evaluation board that can be controlled by microcontroller boards using the Arduino form factor such as Infineon’s XMC™ microcontroller kits. The shield with Infineon’s high-side switch Power PROFET™ BTS50010-1TAD allows two different working modes:
› The shield can be controlled by a programmable microcontroller, e.g. Arduino Uno, XMC1100 Boot Kit or XMC4700 Relax Kits from Infineon.
› For stand-alone mode, BTS50010-1TAD can be commanded ON/OFF by connecting pin BTS5x In (P0.3) to 5 V (P2.10) or 12 V (VBat). The IS signal of BTS50010 is monitored by the on-board circuitry, indicating the operation mode of BTS50010 on LED3 (green for normal mode) and LED4 (red for FAULT mode, such as overtemperature or short circuit to GND).
Dissecting the shieldTP COMP 1:
Input to check state of comperator 1, can be measured at tespoint TP_COMP1.
IN - BTS500xx
: Input of BTS500xx chip to switch on / off.
LED2
: Input to shield LED no. 2.
LED1
: Input to shield LED no. 1.
S2
: Handling of user input. External Key can be connected, low active.
IS
: Measuring of current IS.
TP 5V
: Measuring availability of 5V.
VBAT
: Measuring of VBAT via voltage divider.
After 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, and analog inputs for using Infineon's current sense diagnostic features.
Setup codeWe start by including our library and then using the hss namespace
#include <hss-shield-bts5001x-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).
Bts5001xShieldIno HSS = Bts5001xShieldIno(&BTS50015);
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-bts5001x-ino.hpp>
using namespace hss;
Bts5001xShieldIno HSS = Bts5001xShieldIno(&BTS50015);
Error_t err = OK;
void setup()
{
Serial.begin(9600);
Serial.println("Serial initialized");
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 and check the diagnostics. For our high side switch control, we have two functions, which are the switchHxOn()
and switchHxOff()
. As their names suggest, these two functions respectively turn the switch on and off.
The following code snippet turns on the switch for three seconds and then turns it off again for three consecutive seconds.
void loop(){
HSS.switchHxOn();
delay(3000);
HSS.switchHxOff();
delay(3000);
}
DiagnosticsThe MVP function of our library for diagnosis is the readDiagx()
function. This function returns a DiagStatus_t type value. The returned diagnosis status could be:
DIAG_READ_ERROR:
Read Error
NOT_ENABLED:
Diagnosis not enabled
NORMAL
Switch works correctly
FAULT
S:
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()
. The readIsx()
function returns the value of the current in the form of a float in the unit of Amperes.
To add more to the bargain, the readVss()
function reads the voltage over at the vBAT pin (check the diagram above) and returns it in the unit of volts in the form of a float.
The following code snippet is taken from the BTS5001x-hss-advanced code example snippet from the library. The custom function getSwitchParams() has three built in custom functions that each serve to provide diagnostic information using the functions mentioned in this section :
void getSwitchParams()
{
Serial.println("Reading the current, battery voltage and diagnosis status of switch ...");
/** Read current value */
readCurrent();
/** Get diagnosis result */
readDiagnosis();
/** Read battery voltage */
readBatteryVoltage();
}
void readCurrent()
{
float readAmps = 0.0;
for(int i = 0; i<10; i++){ // Measure more than once to make use of the internal exponential filter
readAmps = HSS.readIsx();
}
Serial.print("Current flowing through the switch: ");
Serial.print(readAmps);
Serial.println(" A");
return;
}
void readDiagnosis()
{
DiagStatus_t switchStatus;
for(int i = 0; i<10; i++){
switchStatus = HSS.readDiagx(); // Read the diagnosis function more than once to make sure the IS value is correct (internal exponential filter)
}
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!");
}
return;
}
/**
* @brief Reads the current battery voltage
*/
void readBatteryVoltage()
{
float batteryVoltage = 0.0;
for(int i = 0; i<10; i++){
batteryVoltage = HSS.readVss();
}
Serial.print("Current battery voltage : ");
Serial.print(batteryVoltage);
Serial.println(" V");
return;
Internal Exponential FilterThe current sense and battery voltage sensors provided with this PROFET device come 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()
and the readVss()
functions in a loop each time you use them (just like indicated in the code above).
The status of the built-in button on the shield could be easily accessed using the analogReadButton()
function, which simply returns a bool value that is equivalent to true if the button is being pressed and false if it is not.
The following code snippet demonstrates the use of the analogReadButton() function where the Arduino board serially prints "pressed" if the button is being pressed and prints "not pressed" if it is not:
void loop(){
if (HSS.analogReadButton()){
Serial.println("pressed");
}
else {
Serial.println("not pressed");
}
delay(500);
}
This shield is also usable on its own (without any external microcontroller like an Arduino or an XMC device). All you have to do is connect an appropriate load and an external switch (just like the figure below). Last but not least, connect the shield to a power supply that should not exceed 18V for nominal operation and turn on the power.
In standalone mode, LED3 and LED4 give out visual diagnostics, where LED3 (green LED) will light in case of normal operation and LED4 (red LED) will light in case of a fault condition.
For more information please check the User Manual of the shield.
Comments
Please log in or sign up to comment.