A mobility scooter can be made more useful with a radar based safety system. In this project a Sense2GoL kit will be used to demonstrate a collision avoidance system.
How Does It Work?
The Sense2GoL radar kit is used to search for the returning doppler signal of an approaching object. A separate micro-controller board is used to carefully monitor the speed of the mobility scooter and pay attention to the radar sensor signal from the Sense2GoL kit.
When an object signal is classified as approaching the scooter, braking action is applied and an audible warning given.
This project is kept simple because distance measuring capability is not possible with the Sense2GoL evaluation kit . Infineon makes more elaborate demonstration boards that could measure the distance to oncoming objects, but this project explores what can be accomplished with the Sense2GoL evaluation kit .
Measuring the Speed of the Mobilty Scooter
An Infineon Speed Sensor 2GO evaluation kit is used to rapidly prototype a speedometer based on a Hall effect sensor. The ruggedness and precision of the Infineon TLE4922 Hall effect sensor, used in the Speed Sensor 2Go kit, will work nicely in a product design process.
The Speed Sensor 2Go kit seems to be a variation of the XMC 2 Go board design. XMC 2 Go is also known as KIT_XMC_2GO_XMC1100 . If you want to get started writing custom code for Speed Sensor 2Go , the sample code project for XMC 2Go works without any modifications needed. Using the Speed Sensor 2Go kit , as an additional micro-controller board for the project, will save me the trouble of adding an Arduino board to my project and also enables all of the software development to be done in one software IDE.
The link for the XMC 2 Go
The link for XMC 2 Go documents ( including the starter project )
A Test Bed for Development
I am reactivating a hacked RC car chassis to use as a test bed for the radar safety system.
The parts bin has plenty of room for the two eval kits.
Speed Sensor 2 GO board has many spare I/O pins that are not available on the Sense 2 GoL board, so the code that takes action on the radar sensor data for the scooter is getting pushed into Speed Sensor 2 GO board. A finished commercial product will need a user interface and the spare I/O pins will be very needed.
The drag behind wheel speedometer
I tried to come up with good ways of attaching the Hall effect speed sensor to the radio control car chassis but was always disappointed with my ideas. So my plan is to use a wheel attached to back of the chassis. A pizza cutter makes a nice wheel to attach cobalt samarium magnets. The magnets are so strong that the air gap between the magnet and the Hall effect sensor can be 5 mm or slightly larger. Mounting the hall sensor should be easy with such a large air gap.
Things I have forgotten since my college physics class
The frame of reference for the moving mobility scooter and the radar are the same.
Example 1: If a jogger is running faster than the scooter is moving (in the same direction) ahead of the scooter, the jogger is measured by the radar as moving away from the scooter.
Example 2: If a jogger is running slower than the scooter is moving (in the same direction) ahead of the scooter, the jogger is measured by the radar as moving toward the scooter.
In both examples we did not need the speedometer sensor to sort out the situation concerning the jogger,to answer the question - "Is the mobility scooter catching up with the jogger?" .
But the speedometer does help to apply sensible braking and also detect the situation where the scooter is already stopped and someone or something approaches the front of the mobility scooter.
Short Term Goals
Get started with the Sense2GoL board. This video link below is a good tutorial on how to get started with the Sense2GoL board and get the example Dave software project downloaded to the board. You will need this project imported into the DAVE IDE so that it can be slightly modified to better suit the purposes of this project.
Infineon Video: Unboxing Sense2GoL
Modifying the original project
I changed the Sense2GoL Dave App called Radar_sense2Go_exe, supplied on the USB drive that came with the Sense2GoL kit, to turn on an LED only when detecting an approaching object . I used the LED on the Sense2GoL board for the first set of experiments. The detection threshold will also needed to be adjusted to provide a good warning of an object that is in the way.
I changed 3 lines of the Infineon supplied example code
Reduced the detection threshold to 50 (on line 56)
.trigger_det_level = 50, /* 100 OK, was 200, trigger detection level */
I initialized a variable so radar detection immediately starts coming out of a power on reset, (on line 160)
start = true; //!!!Start radar on power up!!!
The LED action was changed to turn the LED on for the Approaching Object condition only. (on line 129)
if (detection_state == XMC_MOTION_DETECT_APPROACHING)
So Sense2GoL will now start automatically when power is applied and the LED flashes on at distance suitable for safe stopping. Here is the link for the archive file on Dropbox for those interested in replicating the project.
Dropbox link for the Dave IDE project with Lower Threshold and Detect on Approaching
From the Dave IDE you can do File->Import which brings up a pop-up window from which you select Infineon and then Dave Project as an Import source. The next popup window helps select the file, a zipped archive file in this case.
There may be a really convenient way of creating a GitHub repository from the Dave IDE, I have not found it yet.
Long Term Goals
Use a digital output from the Sense2GoL to pass radar information to the processor on the Speed 2 Go kit and have the Speed 2 Go processor beep a horn, do intelligent braking, and other cool stuff.
The Sense2GoL kit seems very similar in construction to the XMC 2 Go kit that I am using in another project. The two kits are so similar that the demonstration project for the XMC 2 Go kit can be downloaded and run unmodified on the Sense2GoL kit.
That was fun for a quick demonstration, but I am hoping to use the peripherals on the XMC 1100 processor without much reading the manuals for the processor, so I have created a new Dave Project that does most of what the original XMC 2 Go demo project did. A Dave project is good to use because of the well debugged code libraries that are available when we select Dave software components. The Dave IDE also the helps getting the pins allocated correctly on the XMC 1100 processor.
Here is the link for the first Dave project to copy the output of the Hall effect sensor to an LED on the Speed2GoL kit. The primary utility of the Hall sensor program is to show that the mechanical setup for the speedometer is built correctly, proving that the magnet is detected as it passes under the Hall effect sensor.
/*
* main.c
* Created on: 2017 Aug 24 08:35:14
* Author: tminnich
*/
#include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)
uint8_t data[] = "Infineon Technologies";
uint8_t rec_data[10];
/**
* @brief main() - Application entry point
*
* <b>Details of function</b><br>
* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/
int main(void)
{
DAVE_STATUS_t status;
uint32_t pin_status;
#define TOM_TIMER_LIMIT 1000000
int tom_timer;
status = DAVE_Init(); /* Initialization of DAVE APPs */
if(status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
UART_Transmit(&UART_0,data,sizeof(data) - 1);
while(1U)
{
//for(tom_timer=0;tom_timer<TOM_TIMER_LIMIT;tom_timer++){
//}
//DIGITAL_IO_ToggleOutput(&DIGITAL_IO_LED_1);
pin_status = DIGITAL_IO_GetInput(&DIGITAL_IO_HALL_OUT);
if(pin_status == 1)
{
DIGITAL_IO_SetOutputLow(&DIGITAL_IO_LED_1);
}
else
{
DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_LED_1);
}
}
}
void EndofTransmit()//
{
UART_Receive(&UART_0, rec_data, sizeof(rec_data));
}
void EndofReceive()//
{
UART_Transmit(&UART_0, rec_data, sizeof(rec_data));
}
I have extended the Hall Sensor project to collect the last 8 samples of Hall sensor high to low transition. This makes a crude speedometer that times the transition of signal edge accurately to a millisecond.
DropBox link Speed2Go_SPEEDOMETER.zip Dave App archive file
* main.c
*
* Created on: 2017 Aug 24 08:35:14
* Author: tminnich
*/
#include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)
uint32_t mS_high_ticks,mS_low_ticks;
uint32_t timings[8],timings_index;
uint8_t data[] = "Infineon Technologies";
uint8_t rec_data[10];
uint32_t pin_status,prev_pin_status;
/**
* @brief main() - Application entry point
*
* <b>Details of function</b><br>
* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/
int main(void)
{
DAVE_STATUS_t status;
#define TOM_TIMER_LIMIT 1000000
status = DAVE_Init(); /* Initialization of DAVE APPs */
if(status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
UART_Transmit(&UART_0,data,sizeof(data) - 1);
while(1U)
{
// A very empty background loop at the moment
}
}
void STOPWATCH_ISR(void){
prev_pin_status = pin_status;
pin_status = DIGITAL_IO_GetInput(&DIGITAL_IO_HALL_OUT);
if(pin_status == 1)
{
DIGITAL_IO_SetOutputLow(&DIGITAL_IO_LED_1);
mS_low_ticks++;
mS_high_ticks = 0;
}
else
{
DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_LED_1);
mS_high_ticks++;
if(prev_pin_status == 1){
timings[timings_index++] = mS_low_ticks;
timings_index &= 7;
}
mS_low_ticks = 0;
}
}
void EndofTransmit()//
{
UART_Receive(&UART_0, rec_data, sizeof(rec_data));
}
void EndofReceive()//
{
UART_Transmit(&UART_0, rec_data, sizeof(rec_data));
}
It is fairly easy to add timers and various hardware components like A/Ds and I2C components. The DAVE help file system provides usage examples that speed the software development process. The help is brief and to the point, yet the help is very complete so I recommend the Dave IDE highly.
The next step is to add the ability to beep a warning when someone steps in front of the mobility scooter.
Radar Beep Dave App Archived Project link
There is nothing fancy going on here, I make use of the 1 mS interrupt to make a 500 Hz beep. This is the same interrupt that was used in the previous example to do the timing for the speedometer. I like to reuse a resource to get more than one function out of it when I can.
* main.c
*
* Created on: 2017 Aug 24 08:35:14
* Author: tminnich
*/
#include <DAVE.h> //Declarations from DAVE Code Generation (includes SFR declaration)
uint32_t mS_high_ticks,mS_low_ticks;
uint32_t timings[8],timings_index;
uint8_t data[] = "Infineon Technologies";
uint8_t rec_data[10];
uint32_t pin_status,prev_pin_status,radar_status;
/**
* @brief main() - Application entry point
*
* <b>Details of function</b><br>
* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/
int main(void)
{
DAVE_STATUS_t status;
#define TOM_TIMER_LIMIT 1000000
status = DAVE_Init(); /* Initialization of DAVE APPs */
if(status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
UART_Transmit(&UART_0,data,sizeof(data) - 1);
while(1U)
{
// A very empty background loop at the moment
}
}
void STOPWATCH_ISR(void){
radar_status = DIGITAL_IO_GetInput(&DIGITAL_IO_RADAR_IN);
if(radar_status == 1) {
DIGITAL_IO_ToggleOutput(&DIGITAL_IO_BEEP_OUT);
}else{
DIGITAL_IO_SetOutputLow(&DIGITAL_IO_BEEP_OUT); // use less energy with transistor off
}
prev_pin_status = pin_status;
pin_status = DIGITAL_IO_GetInput(&DIGITAL_IO_HALL_OUT);
if(pin_status == 0)
{
DIGITAL_IO_SetOutputLow(&DIGITAL_IO_LED_1);
mS_low_ticks++;
mS_high_ticks = 0;
}
else
{
DIGITAL_IO_SetOutputHigh(&DIGITAL_IO_LED_1);
mS_high_ticks++;
if(prev_pin_status == 1){
timings[timings_index++] = mS_low_ticks;
timings_index &= 7;
}
mS_low_ticks = 0;
}
}
void EndofTransmit()//
{
UART_Receive(&UART_0, rec_data, sizeof(rec_data));
}
void EndofReceive()//
{
UART_Transmit(&UART_0, rec_data, sizeof(rec_data));
}
Now it is time to put things together and mount them on the hacked RC car chassis!
Adding Speakers
I experimented with a few beeper type sound alert devices and was not pleased with the result. I find that the warning sound is just annoying for everyone that has to hear it. I am adding a stereo amplifier board made by Adafruit and moving coil speakers that have much better sound quality.
Adafruit 2 Watt stereo amplifier - This link has a tutorial on how to connect and use the stereo amplifier.
In the near future
I will add a MP3 decoding board, these are used to make doorbells that play MP3 files when the door button is pressed
With a wide range of sounds that could be chosen for the warning sound, this will improve the appeal of the final product.
I also want to add the smooth braking function to the firmware, this may need to wait until I have a real mobility scooter to work with.
Comments