This project was created in Fall 2019 for my final project in the Design with Microprocessors course. Our objective for this project was to create a radio controlled car that operates using a PSOC 5LP Microcontroller. In addition, we included a LCD screen to display our wireless controllers joystick PWM duty cycle values. The micro controller on the car is programmed using C language, which controls the motor driver, wireless receiver, and LCD screen.
The RC car is powered by two 18650 battery cells. There are two 12 volt DC brushed motors for each tank tread. The L298N H-bridge motor driver we used activates the motors using a PWM signal to regulate the speed. The wireless receiver outputs a variable PWM signal based on the direction of the joystick on the wireless controller.
To control the motor driver of the RC car we set up four control registers on the peripherals embedded in the micro controller. Each control register is assigned to either clockwise or counter clockwise for motor A and B. The control registers are activated by writing a high digital signal in the code to activate a certain direction of the motor. The PWM peripheral sends a PWM signal, with a certain duty cycle, to the enable pins on the motor driver to control the speed of each motor. Therefore, depending on the user input on the wireless controller the RC car moves in the direction desired.
For the wireless controller, we needed to analyze the receiver signals when the joysticks were being moved by the user. We first observed the signal for forward and reverse using an oscilloscope. We found that the output signal on the receiver is a PWM signal that adjusts the duty cycle when the joysticks are moved. Therefore, we realized that we needed to identify these thresholds on the micro controller and then output the correct signals to the motor driver.
To correctly observe the input signals on the micro controller we needed to use a timer module to measure the duty cycle on each input signal. The two pins we created for the wireless controller input signals were gas and turn. In our code we used a multiplexer to quickly transition between reading both signals to have an accurate response on the car. The interrupts we implemented are designed to measure the amount of time of each duty cycle to properly observe the signals. Once we figured out the correct thresholds for the correct directions in the PWM duty cycles we created conditional statements to activate the corresponding motor and direction. Overall , the RC car project result was a success and the car move accurately with the wireless controller.