The H-Bridge Kit 2GO is a ready-to-use baord to drive DC motors. It is populated with a H-Bridge IFX9201 combined with a XMC 1100 Microcontroller based on ARM® Cortex®-M0 CPU and a 5V LDO. It is designed to control DC motors or other inductive loads up to 6 A and up to 36 V of supply.
Attention: The 5V regulator is a linear voltage regulator and can get very hot depending on the input voltage! VBAT can range from 5 V to a maximum of 36 V without damaging the board. However, since the power dissipation of the 5 V regulator strongly increases with the input voltage it is recommended to keep VBAT below 15 V or to provide additional cooling by attaching a heat sink to the backside of the board.
IFX9201The main player of the game here is the IFX9201 IC. As the name of this protip suggests it is essentially a half-bridge circuit on steroids! (You'll know why in a second). But first, let's take a simpler look at the basic functionalities of the half-bridge circuit.
The half-bridge circuit has two output pins as shown in the diagram above, and 4 MOSFETs. The Mosfets are operated within specific combinations to achieve a certain polarity between both output pins ( the pins connected to the motor in the diagram above). To control the power delivered at the output of the half-bridge circuit pulse width modulation is utilized. Crash Course: PULSE WIDTH MODULATION
Pulse width modulation is switching power ON and OFF with a high frequency with the aim of controlling the power delivered to the devices. The ratio of ON and OFF time is called duty-cycle and this indicates the amount of power delivered to the device (in our case motors). To keep everything simple: it is just a way of quantifying the power that we are giving to the motors, where at 100% duty-cycle the motor is getting full power (we could use this when we want the motor to move at maximum speed), if we want to decelerate then we would reduce the duty-cycle and if we want to accelerate we would increase it.
So the IFX9201 allows us to not only control the direction of the output signal but also have the option to downsize it.
Moreover, the IFX9201 comes prepacked with some protective features so let's briefly go through them:
- Chopper current limitation
- Short circuit shut down with latch behavior
- Overtemperature shut down with latch behavior
- VS Undervoltage shutdown
- Open load detection in ON and OFF state
Now that the basic functionality of the IC is given let's have a deeper dive into how to use it.
Pins
As you can see from the pin definitions above there is a pin for determining the direction and another for the PWM input. What makes this IC special is its SPI communication interface which allows it to output diagnostics data.
There are two control modes for using the IFX9201:
- PWM Mode
- SPI Mode
PWM Mode: Controlling the output of the half-bridge by sending pulse width modulated signals to the PWM pin of the IFX9201. This allows us to manually configure the intended duty cycle by modifying the signal being sent to the PWM pin.
SPI Mode: Sacrifice the ability to control the duty cycle for having access to the diagnostics data of the IFX9201. The IFX9201 has three registers whose contents could be shared over SPI, these registers are the control, diagnostics, and revision register. As the name suggests: the control register contains data related to the current functionality of the IC. The control register is the only register that could be written to by a controller. ( More info about the data on these register/truth tables for diagnosing the info could be found in the datasheet of the IFX9201 under subsections 4.12.2.1, 4.12.2.2, and 4.12.2.3.)
Since in this protip we're dealing with the H-Bridge2GO Kit we do not need to get any more into the intricate details of the wiring and connections since everything is already "out of the box" wired and connected in the PCB. So without further ado let's get into actually using the board.
SoftwareTo use the H-bridgekit2go with the Arduino IDE: we'll have to perform some quick installations. First of all to use this board and any other Infineon XMC microcontroller we would have to install SEGGER J-Link. Please follow this link SEGGER J-Link and install the J-Link Software and Documentation Pack for your respective operating system (OS). Additionally, we also have to set up our board in the Arduino IDE itself; we'll do this by navigating to the preferences in the Arduino IDE
and copying the following URL in the box asking for additional board manager URLShttps://github.com/Infineon/Assets/releases/download/current/package_infineon_index.json
Lastly, we'll have to install the boards under Tools > Board > Boards Manager. To do this search for XMC and install the latest version available in the boards manager.
Now that the boards are installed and ready. Its time to choose our H-Bridge2Go kit
The main player of the game here is the IFX9201 library, which is automatically installed with the XMC microcontroller library. To use it we will have to include it in our code by writing:
#include "IFX9201.h"
Additionally, you'll have to instantiate an IFX9201 object by writing (of course you don't have to name your object IFX9201_HBridge, but in this thread, we'll just name it that way for simplicity purposes).
IFX9201 IFX9201_HBridge = IFX9201( );
the last step separating us from controlling our h-bridge instance is to enable it. To do this we have to either write:
- for the PWM mode:
IFX9201_HBridge.begin( DIR, PWM, DIS );
- for the SPI mode:
IFX9201_HBridge.begin( SPI, CSN, DIR, PWM, DIS );
DIR, PWM, and DIS are input pins of the IFX9201. When using the IFX9201 on its own we'd have to specify the pins of our microcontroller that are connected to the DIR, PWM, and DIS pins of the IFX9201. When using the H-Bridge Kit2GO we don't have to deal with any of this since the pins of the onboard IFX9201 are connected to our onboard XMC1100 which are already defined within the library.
To set the frequency for the IFX9201 we use the setPWMFrequency( ) method, which takes in a maximum of 20KHz (20000).
Active Control
The IFX9201 library provides three main functionalities for actively controlling the bridge: forwards( ), backwards( ) and stop( ); where forwards( ) and backwards( ) control the polarity of the output pins, and stop simply disconnects both output pins. Both forwards( ) and backwards( ) take in the intended duty cycle as input (0-100). ( NOTE: you cannot enter a duty cycle in SPI mode, the output can only be set to 100% duty cycle or 0).
SPI Mode Register access
To read the data stored on the diagnostics register you would need to use the getDiaReg( ) method to apply this to our instance above we would write
IFX9201_HBridge.getDIAReg( );
To read the data stored on the revision register you would need to use the getREVReg( ) method; to apply this to our instance above we would write
IFX9201_HBridge.getREVReg( );
To read the data stored on the control register you would need to use the getCTRLReg( ) method; to apply this to our instance above we would write
IFX9201_HBridge.getCTRLReg( );
To write to the control register you would need to use the setCTRLReg( ) method; to apply this to our instance above we would write
IFX9201_HBridge.setCTRLReg( uint8_t );
To reset the contents of the diagnostics register you would need to use the resetDIAReg( ) method; to apply this to our instance above we would write
IFX9201_HBridge.resetDIAReg( );
( More info about the data on these register/truth tables for diagnosing the info could be found in the datasheet of the IFX9201 under subsections 4.12.2.1, 4.12.2.2, and 4.12.2.3.)
Comments