This project uses an Arty development board to control a two-wheel robot. The design has a C library for use with the included MicroBlaze soft processor to provide users with a working platform from which to develop robotics applications.
The robot is built on SparkFun's Shadow Chassis. The motors, wheels, and wheel encoder kit are also from SparkFun. The motors are driven by Digilent's PmodDHB1. A 5V power bank available from SparkFun supplies power to the Arty. Four rechargeable AA batteries, also from Sparkfun, supply power to the motors via the PmodDHB1.
After the chassis is assembled, the PmodDHB1 can be connected to the motors and Hall effect sensors. The motors connect to the screw terminals at J5 and J6 on the PmodDHB1. The Hall effect sensors connect to the pins at J7 and J8. Notice that the pinout of the sensors do not match the pinout of the PmodDHB1. The innermost pins at J7 and J8 provide Vcc, the next pin out provides ground, and the output of the sensor must connect to the outermost pins. Then, the PmodDHB1 can be connected to the Arty at the JB Pmod connector. Finally, place the Arty's power bank and the four-AA battery pack inside the chassis. The AA battery pack connects to the PmodDHB1's screw terminals at J4.
The ArtyBot's project archive is available through the Digilent GitHub. See Digilent's tutorial on Using Digilent GitHub Demo Projects for instructions on setting up the Vivado project.
function of the ArtyBot's software application is located in
. Also in
are four demo functions. The version of this file posted with the project contains four lines in
that are commented out. Each line is a call to one of the four demo functions. Select one to uncomment and rebuild the project to get started with an ArtyBot application. Some of these demo functions require a PmodMAXSONAR or a PmodJSTK2, connected to the JC and JD Pmod connectors, respectively. Alternatively, you can replace these four lines with your own functions by using the provided software library.
The library for the ArtyBot is in
, which provides driving and steering functions. Here is a brief overview of the library functions:
are to be called at the beginning and end of an ArtyBot application, respectively.
drive the ArtyBot in the direction indicated by the given distance in centimeters (cm). Then, the robot will come to a complete stop before the next command.
turn the ArtyBot by the angle given in degrees in the direction indicated. The way the robot turns is by driving one wheel forward while driving the other wheel backward. This way, the center of the robot stays in approximately the same place. At the end of the turn, the robot will come to a complete stop before the next command.
For each of these drive and turn functions, there is a "continuous" analog, which have the same function names with "continuous" appended to them. These behave the same way as the functions above except they do not wait for the robot to come to a complete stop. Repeated calls to these functions to drive short distances can be used to allow processing in between calls while creating the illusion that the robot is driving continuously.
turn the ArtyBot by the angle given in degrees in the direction indicated. The difference with these functions is that they drive one wheel forward while leaving the other stationary. This turn makes the center of the robot moves forward and to the left or right. The robot will come to a complete stop before the next command.
will block execution until the robot comes to a complete stop.
When you are ready to program the Arty with your application, be sure that ArtyBot.elf (located in ArtyBot/Debug/) has been updated with the most current form of your program. If ArtyBot.elf is out of date, update it by right-clicking the ArtyBot directory in the Project Explorer and clicking Build Project. The project can also be set to build automatically when changes are made to the software. This setting can be enabled by clicking Project in the upper toolbar and clicking Build Automatically if there is not already a checkmark next to it.
Then, click the Program FPGA button in the toolbar. In the right half of the Software Configuration section, there is a cell that says 'bootloop.' Click the right side of this cell to reveal a drop-down menu. Select ArtyBot.elf from the list, then click Program. This will generate a bit file with the MicroBlaze's memory initialized with the program that you have written.
When this process is done, click the Program Flash button in the toolbar. Next to Image File, click Browse and navigate to the SDK workspace, then into artyBot_wrapper_hw_platform_0. Select download.bit and click open. Next to Flash Type, select n25q128-3.3v-spi-x1_x2_x4. Click Program.
The Arty's non-volatile memory is now programmed with your application and will run on the FPGA on startup.
The hardware programmed onto the FPGA for the robotics platform consists of a MicroBlaze soft processor and IP cores that handle control of the motors. IP cores for peripherals can be added to extend the robot's functionality. The only pins that are required for the platform itself are those for the PmodDHB1 on Pmod connector JB. The rest of the Arty's pins can be used for I/O to interface with peripherals. As a demonstration, the posted Vivado project uses the JC and JD connectors for a PmodMAXSONAR and a PmodJSTK2, respectively.
Here is an overview of some of the IP cores in the ArtyBot's block design:
A Pmod Bridge, an AXI GPIO, and a collection of Slice and Concat IP cores facilitate communication between the MicroBlaze processor and the PmodDHB1. They also break out the pins with feedback from the motor encoders for processing in another IP core in the design.
A custom IP core, called MotorSpeedPosition, contains logic that processes feedback from each of the two motor encoders to measure motor speeds and keep track of the distances traveled by each wheel.
A pulse-width modulation (PWM) IP core outputs PWM signals which are used to control the speed of the motors. The period and duty cycle of the PWM signals are set in software on the MicroBlaze processor.
Another Pmod Bridge connects to a PmodMAXSONAR and breaks out the PWM output of the Pmod to connect to a custom IP core, called MAXSONAR_Processor. This custom IP core contains logic that decodes the PWM signal to determine the distance detected by the PmodMAXSONAR.
A Pmod IP core for the PmodJSTK2 is included to add a PmodJSTK2 as a peripheral to the robot.
The Arty's on-board switches, LEDs, and USB UART have also been added to the design and are available for use in software.
This section will describe code that is used to implement the drive and turn functions in the provided C library. The information in this section will only be relevant if you wish to use the code to implement your own driving or turning functions.
contains functions that compute data for use with control systems for the motors.
computes the current motor speed in revolutions per minute (RPM) and
returns the mean distance traveled by the wheels since the last position reset.
implements proportional-integral-differential (PID) controllers for driving the wheels of the robot equal distances or at equal speeds.
uses PID control to determine new values of duty cycles for the motors' enable signals to drive the motors such that they travel the same total distance. Calling this function at regular time intervals will ensure that the robot maintains the same direction it had at the beginning of the drive command.
also uses PID control to determine new values of duty cycles, but its goal is to drive the motors such that the wheels maintain a given speed in RPM. For examples of these functions in use, see
ArtyBot GitHub Repository
Did you replicate this project? Share it!I made one
Love this project? Think it could be improved? Tell us what you think!