Initially when presented with this task I was unsure what to do and had come up with a short list of ideas and eventually settled on the Radio Controlled Vehicle (RCV). The idea came from a project a previous student had done; the Trackbot. I wanted to do a something a little different and decided to add a remote controller so that it can be controlled. This was actually my third choice and I'm glad I went with it due to the fact that I don't have too much experience coding in this language. Therefore Sergei did most of the coding and I wrote a few lines here and there when I knew how to do it.
General view |
There are five buttons on the remote that will control the movement of the RCV. The button on top of the remote will make the vehicle go forward at a constant rate. The button on the left (closest to the on/off switch) will make the vehicle turn left and to turn right you just press the button on the right. Finally, to make the vehicle reverse you need to press the bottom button, this will be in a continuous motion. To make the RCV stop moving you just need to click the button in the middle of the remote.
The transmitter consists of two main components: the microcontroller and radio module. For the microcontroller I had used the MKL02Z32VFK4-ND and the ZETA-915-ND was our radio module. On the microcontroller we also need to add an on/off switch, 5 buttons and a battery pack. In order for enough energy to be supplied to the transmitter we needed to have at least 2 AAA batteries.
Schematic | Assembly top | Assembly bottom | ||
For the RCV, the receiver was a little more complex. In order for the radio module to work we needed another radio module of the same series, ZETA-915-ND, in the receiver. The reason for this is so that they could communicate with each other. They will communicate functions such as move forward or go left. The microcontroller on the receiver needed more pins and we had to go with a bigger one, the MKL05Z32VFK4-ND. It needed more pin due to the infrared sensors that was added on in case I wanted to make the RCV capable of moving on its own. This microcontroller had 24 pins, whereas the one in the transmitter only had 16. The microcontroller here has to also control the tires of the RCV, specifically the two motors controlling the tires. For this we had gone with the DRV8833PWP stepper driver. Lastly, a battery holder was added, to provide energy, and it held 4 AA batteries.
Schematic | Assembly | |
In the transmitter the SPI interfaces in the microcontroller and radio module were linked together so they could operate hand in hand and understand each other. There were 3 main things that needed to be done in the SPI interfaces: setting the interrupt flag the timer and the baud rate. The interrupt will be used to determine whether or not the 'packet' it created was sent or not; if it was sent then it will clear or delete its content. In order for the microcontroller to communicate in sync with the radio module the timer and baud rate had to be set to the same frequency.
Although this is where the buttons will connect to, the code to make the buttons function will not be written here, it will be written in the receiver's file. Here we are, in a sense, just telling the MKL02 that there will be a button connected to this pin. Therefore they just need to be set for general purpose in/out function. If the button is pressed then it will set the last index in the packet to a symbolic representation (1 for up, 2 for right, 3 for backwards, 4 for left and 5 for stop) of the direction that is to be sent to the RX when the button is pushed. In this part we did need to check and see if the button was push down or not due to the fact that the button sits on a spring and when it is pressed and released it will bounce for a little while. In order to compensate for the bouncing we had to shift the register until we found either 4 zeros or 4 ones. If four are found in a row then the button has been pressed. Once it has been established that the button was pressed, then it will send the packet it has composed. This packet will be an array of length four. The first index will contain the command 0x66, which just allows data to be written into the EZConfig. In the next two indexes the package will contain the TX id and RX id. Finally, the last index of the packet will contain the symbolic representation of the direction, whether it is forward, left, right, and backwards or stop.
Once the packet has been sent the Receiver will look for it. It is important to note here that in order for the RX to start receiving any information it first needs to send something. The RX will look for the packet, or array, that contains the 4 pieces of information it needs: the command code, TX id, RX id and the symbolic representation of the direction the RCV is supposed to go. If the packet is sent in the wrong order or 1 of the 4 pieces of information is incorrect then the RX won't register it as a signal it needs to read. It will ignore it until the right packet comes through. Once the packet comes through correctly the RX will proceed to 'open' the packet. The symbolic representation of the direction will then be compare to the 5 different directions that are available (forward, backwards, left, right and stop). Once the match for the symbolic representation has been found it will continue by performing the function of that button.
When the directions are coded into the RCV there were 2 motors that needed to be programed. Motor A controls the left wheel and Motor B controls right wheel of the RCV. In order to make the RCV go forward the logic of Motor A and Motor B had to be set to the same value; forward PWM, fast decay. When reverse or back button is pushed, both Motor A and Motor B had to be set to reverse PWM, slow decay. It is important to note here that we had looked up slow and fast decay modes and for the RCV we didn't have to worry about using only one or the other modes of decay. To make the RCV turn left Motor A had to be set to reverse PWM, slow decay and Motor B was set to forward PWM, fast decay. To make the RCV turn right we just had to do the opposite of turning left. Lastly, to make the RCV stop moving completely, the PWM in Motor A and B just had to be turned off, or set to low logic.
This was definitely a challenging project for me, since I don't have a lot of experience coding, however with a lot of help from Sergei I learned a lot. I am quite excited to keep working on this project even after the class is done with. I wanted to, at one point in time, to make it be able to run on its own without running into walls. Sergei already put on the infrared sensor that I would need to be able to do this. Therefore all I need to do is start writing the code of this next project.
Although the class was challenging I really enjoyed it and would highly recommend it to anyone. I had so much fun with it so I'm already planning my next microcontroller project!
Last modified:Mon, Jan 23, 2023.