Blog List:
Garbage Collector #1 Introduction
Garbage Collector #2 Clamp testing
Garbage Collector #3 Seeking help from Infineon's Technical Supports
Garbage Collector #4 Some basic interactions with the shields
Garbage Collector #5 Base testing
Garbage Collector #6 Wireless Controller
Garbage Collector #7 Clamp and Base
Garbage Collector #8 Clamp Improvement
Garbage Collector #9 Doubling the maximum current
Garbage Collector #10 Summary
Previously I have successfully tested the DC Motor Shield using the example code in Arduino IDE. However, one of the tech support from Infineon told me that currently there is no FreeRTOS support for XMC in Arduino IDE, so, I have decided to move my working environment from Arduino IDE to DAVE.
At first, I have faced some difficulties in controlling the DC Motor Shield in DAVE. Thankfully, one of the tech support, Mr. Dominik jd_tech_support_ifx sent me the source code from his colleague and I was able to figure out how should I control the DC Motor Shield in DAVE.
I'm not sure how to upload files in here, but you can find the files in the ext_lib folder in the following GitHub link:
tle94112el.c: https://github.com/wanfp97/freertos_motor/blob/master/ext_lib/tle94112el.c
tle94112el.h: https://github.com/wanfp97/freertos_motor/blob/master/ext_lib/tle94112el.h
tle94112el_regs.h: https://github.com/wanfp97/freertos_motor/blob/master/ext_lib/tle94112el_regs.h
also, in order for these codes to work, a few lines of codes must be added as well:
static void tle94112el_enable(void); static void tle94112el_disable(void); static int32_t tle94112el_spi_transfer(uint8_t *tx_data, uint8_t *rx_data); static const TLE94112EL_t TLE94112EL_0 = { .enable = tle94112el_enable, .disable = tle94112el_disable, .spi_transfer = tle94112el_spi_transfer };
static void tle94112el_enable(void) { DIGITAL_IO_SetOutputHigh(&TLE94112_ENABLE); } static void tle94112el_disable(void) { DIGITAL_IO_SetOutputLow(&TLE94112_ENABLE); } static int32_t tle94112el_spi_transfer(uint8_t *tx_data, uint8_t *rx_data) { XMC_SPI_CH_SetBitOrderLsbFirst(SPI_MASTER_0.channel); DIGITAL_IO_SetOutputLow(&TLE94112_CS); SPI_MASTER_Transfer(&SPI_MASTER_0, tx_data, rx_data, 2); while(SPI_MASTER_0.runtime->rx_busy); DIGITAL_IO_SetOutputHigh(&TLE94112_CS); return 0; }
using these source codes, I'm was able to control DC Motor Shiled using the function TLE94112EL_SetHBrigeOutput(const TLE94112EL_t *const handler, TLE94112EL_HBRIDGE_t hbridge, TLE94112EL_HBRIDGE_OUTPUT_t output); to set one TLE94112EL_HB output at a time.
However, in my case, I would like to control a few TLE94112EL_HB outputs at once to control the movement of the base of the Garbage Collector. Eventually, I have added base.h and base.c by referring to the codes MR. Dominik sent me:
base.h: https://github.com/wanfp97/freertos_motor/blob/master/ext_lib/base.h
base.c: https://github.com/wanfp97/freertos_motor/blob/master/ext_lib/base.c
so that I can use the TLE94112EL_SetHBRegdata(const TLE94112EL_t *const handler, uint8_t TLE94112EL_HB_ACT_X_CTRL, uint8_t regdata); to set 4 TLE94112EL_HB outputs at once since each TLE94112EL_HB_ACT_1_CTRL, TLE94112EL_HB_ACT_2_CTRL, and TLE94112EL_HB_ACT_3_CTRL can control 4 TLE94112EL_HB outputs.The XMC4700 will now only need to send 2 SPI data to the TLE94112EL (configure 8 TLE94112EL_HB outputs) (configure 4 at once) instead of 8 SPI data (configure 8 TLE94112EL_HB outputs one by one) in order to control 4 DC motors.
Below is the content of base.c that I have added.
#include "base.h" int32_t TLE94112EL_SetHBRegdata(const TLE94112EL_t *const handler, uint8_t TLE94112EL_HB_ACT_X_CTRL, uint8_t regdata) { if ((TLE94112EL_HB_ACT_X_CTRL >= 0x04)|(TLE94112EL_HB_ACT_X_CTRL <= 0x00)) { return -1; } uint8_t tx_data[2]; uint8_t rx_data[2]; uint8_t addr; switch(TLE94112EL_HB_ACT_X_CTRL){ case 1: addr = TLE94112EL_HB_ACT_1_CTRL; break; case 2: addr = TLE94112EL_HB_ACT_2_CTRL; break; case 3: addr = TLE94112EL_HB_ACT_3_CTRL; break; } //write tx_data[0] = addr | 0x80; tx_data[1] = regdata; handler->spi_transfer(tx_data, rx_data); return rx_data[0]; }
The GitHub link below is a simple DAVE project that I have created to test controlling DC Motors:
GitHub link: https://github.com/wanfp97/freertos_motor
After some cutting and drilling, I have constructed the base of the Garbage Collector using biscuit tin and attached 4 DC motors to it:
Below is the video of base movement testing:
Design flow check point:
The next thing I will do is to change the controller to a wireless controller. Till then, see ya.
Top Comments