This project was apart of kit and instructions followed by Dan Block. If you are interested in putting together the base model please contact Dan at d-block@illinois.edu. One key-note is that the board we are using is the TMS320F28379D.
During the creation of the bot, we controlled the 3-Wheeled bot through Serial A TX and RX. This was connected through a wired connection to a PC. The goal of my bot was to do something similar but to control the bot through a wireless connection.
Here is a video of the final product:
For the installation of the Orange PI Zero, Dan Block also had instructions from previous classes on how to install the board. I will summarize below.
The first obstacle was to use the Orange PI Zero (http://www.orangepi.org/orangepizero/) to connect to a local router through an SSH connection. To get the SSH connection configured, I had to download OS for the Orange PI Zero and flash it to a microSD card. I used a 32 gb SD card, which is the max size you can use for this board. I downloaded the Xenial image from this link (https://armbian.hosthatch.com/archive/orangepizero/archive/). To flash the image onto the SD card I used a program called balenaEtcher.
To install the Orange PI Zero onto the board, I soldered 2x20 female header to the "Orange PI Lite" section of the board and a 2x13 male header to the Orange PI facing downwards. This was for quick attachment and detachment of the board. Then taking the Orange PI board and installing it as shown in the picture below.
Another 1x20 header was attached to the right side to connect wires from the Orange PI Board to the TI Board.
After installation of the Orange Pi to the class board, I went ahead and made a wired connection to the Orange Pi Zero board. The red wires as seen in the picture above connect to the serial port "/dev/ttyS0" which provide a terminal to work through. Using a USB virtual COM port cable, I was able to connect to the terminal through my PC. I experienced an issue with the driver for the cable I was given, although I was able to install a new driver through the cable manufacturer site.
Using a software called Tera Term, I connected to the Orange PI Zero to install packages to it, (baurate was 115200).
I then connected the PI board to the internet through
sudo nmtui
Then grabbing the IPv4 address by typing in
ifconfig
Next, I SSH'ed into the machine by using the command below
ssh yourUsername@ip-address
Once I was SSH'ed into my machine, I disconnected the wired connection. (I also assigned a static IP address to it through the MAC address and router)
Next, I installed some essential packages.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git build-essential
sudo apt-get install libopencv-dev python-opencv
sudo apt-get install redis-server
sudo apt-get install pip3
I didn't need OpenCV for this project, but I might attached a camera to the bot later. Most of the PI programming was in python for the Orange PI Zero, so pip3 is useful for installing packages for python.
I then installed the needed python packages to run the project.
python3 -m pip install redis
python3 -m pip install flask
python3 -m pip install flask-requests
python3 -m pip install pySerial
Redis is a key-value database server that is designed for quick access. We need to install the Redis server, then use the python package to talk to Redis. I used Redis to store the data I received back from the TI Board.
Flask is a more lightweight web framework, I used this to host the website on the Orange PI Zero.
Finally, pySerial is Python's way of talking through a serial port. I talked to the TI Board through the serial port on both machines.
For the serial port connections, I used the Orange PI Schematic to determine where to connect.
I connected to the UART2_TX to PIN 43 (TI Board Serial C RX) and UART2_RX to PIN 44 (TI Board Serial C TX).
After the necessary hardware and software was created, I made two scripts on the Orange PI. The first one grabbed the data from the TI board and saved it to the Redis server. The second ran the Flask web server and send the data back to the TI board.
The first script is called 'app.py' and the second is called 'gather.py'. They can be seen in this git repo (https://github-dev.cs.illinois.edu/rsfogle2/me461_project).
The HTML page I used can also be found in 'templates/bot.html'. For the creation of the page, I used a joystick from this link (https://codepen.io/jiffy/pen/zrqwON), and wrote code to make GET to get the data and a POST request to send back the control data. The web routes are specified in the 'app.py' file.
To get both scripts to run on startup I created them as services, the files can be found in 'services' folder in the git repo. I also attached all of these files in the code section.
Using 'systemctl' I was able to enable, start, and stop the services when debugging.
In python, I was able to connect to the serial port by doing the following.
import serial
ser = serial.Serial('/dev/ttyS2', 115200)
ser.read(1) # reads one byte
ser.write(b'a') # writes 'a' to the serial port.
ser.close() # closes connection
To set and retrieve data from Redis I did the following
import redis
r = redis.StrictRedis('0.0.0.0') # if you host on your PC
r.set('data', 'hello world!') # sets the var 'data' to the string 'hello world'
r.get('data') # will return 'hello world!' string
For a simplified chart of the end-user control to motor control works is provided below.
A schematic of the PI motor control is shown below for reference.
The website built for this project includes a JoyStick and slider to control the bot, along with showing the data that is coming from the bot. It looks like the following.
The end product delivered a bot that I can steer from my PC or phone! I could even expose my port 80 and control the bot from anywhere in the world. Please watch my video to see myself controlling the bot. Thanks.
Comments
Please log in or sign up to comment.