Bluetooth LE controlled car

Nathan Nelson

Overview

The following project, is an accelerometer controlled car via Bluetooth LE mounted on car chassis that was purchased from Target. Upon purchasing the vehicle, the insides were removed and we assembled a new transmitter and receiver that would ultimately control the vehicle by utilizing accelerometer data. The transmitter and receiver are configured as BLE Client and Server, respectively, by implementing a Custom GAP profile.

General view

Transmitter

Hardware

The transmitter works in the following manner: the Bluetooth device begins to broadcast and waits for a connection signal, if a device isn't located it continues to broadcast and then enters low-power mode, or, deep sleep mode when it fails to connect to a device. Upon entering the code for the transmitter, the code will trigger the system to enable global interrupts, it will then begin blinking the LED and once it has been connected it stays on at a steady red (later this was altered to conserve power). The transmitter consumes about 1.7 mA, out of which 1.3 are for the LED. The 5-pin connector is used for loading code and for debugging. The accelerometer is an analog one mahufactured by Kionix.

Schematic Assembly

Software

For this project, I utilized Cypress' PSoC (Programmable System ON-Chip) IDE 4.0. Once the components were decided upon, the components were then loaded onto the design platform, configured, compiled, and then ultimately loaded onto the individual parts. The components utilized for the transmitter were: the Bluetooth module, ADC, and PWM (pulse width modulator).

Block diagram

After initialization the Bluetooth stack awaits advertisement from a transmitter. Upon entering the loop of the project the BLE event handler process events. If no events are registered the system goes into deep sleep mode. While active, it processes any events that are sent to it. Throughout the entire operation, the BLE module continues to check for operation and to see if it can enter deep sleep, if it module detects inactivity. The IMO is stopped to conserve power, and the CySysPmSleep() puts the system to sleep. If the connection is lost during operation, it will await a period for reconnection. Upon connecting to a receiver via Bluetooth, the ADC will search to see if the watchdog timer has been triggered. If it hasn't it will then proceed to connect to it. Once watchdog has been initialized, the code calls ADC_Wakeup function, which gets the ADC (Analog to Digital Convertor) ready for the rest of the code. After successful completion and wakeup of the ADC, it begins to read our accelerometer data, for this code our variables were declared as XA, YA, ZA, pertaining to the x, y, and z coordinates. These coordinates were correlated to the directional and speed control of the vehicle and are checked over 100 milliseconds. This allows the system to detect whether there has been a change in position of the transmitter's accelerometer. This is all done on the same frequency as the receiver. Some of the various files that were utilized during the transmitter execution were: BLEclient.c, HandleLowPower (c and h files), ADC, ADC_intClock, ADC_IRQ, ADC_ISR, and BLEStack.

Receiver

Hardware

The receiver is based on the same BLE module as the transmitter. It is powered from 4xAA batteries via a 3.3V voltage regulator. The motor control is established by a DC motor driver from Texas Instruments. One of its channel is used to drive the main car motor forwards and backwards, while the other channel is used to drive the steering motor. The LED indicates the connection state with the transmitter. When the vehicle does not move, the total power consumption of the board is about 4.7 mA, out of which the LED consumes 1.3 mA.

Schematic Assembly

Software

Once again, I utilized Cypress' PSoC (Programmable System ON-Chip) IDE 4.0. However, this time it was utilized for the layout and configuration of the receiver's modules. These modules included: two PWM timers that would be used for the timing of the clock LED and the cloth PWM. These devices would ultimately control the drive functions and the power going to the LED.

Block diadram

Upon entering the code for the receiver, the code will trigger the system to enable global interrupts, begins blinking the LED and once it has been connected it stays on at a steady red (later on this was altered to conserve power). Bluetooth stack is initialized and awaits advertisement from the transmitter. If the connection is lost, it will await a period of time for reconnection, it then processes data received from the accelerometer and begins to implement the drive function of the code.

Final Thoughts

Finally, I would like to thank Sergei for his time and patience, without his help this project would not have come to fruition and been the success that is. For those considering a project of this sort I would impart this knowledge: read the data sheets and if you don't know, ask. Precious time was wasted because I was hesitant and too proud to ask for help. Finally, if you take your time to understand the data sheets for each component, it will make the implementation of your remaining code proceed in a timely and smooth fashion.

Downloads


Last modified:Fri, Apr 14, 2023.

00152