This repository is a fork of Peter Harrison's code for the MMKit. The repository was created to make it easier to run Peter's code using the Arduino IDE, as well as to help in the calibration processes needed to get the micromouse running correctly.
The following diagram was already provided from Peter's original repository.
There's no installation required, to run the code first download its latest release. After, uncompressed the code in the desired location on your machine and just open the project through the Arduino IDE.
Before starting the calibration process, it is required to have a Serial connection to the mouse via the Bluetooth Connector (Label 10), not necessarily needing to be a Bluetooth adapter, any UART to USB adapter should work in this case.
The MMKit UART connection is as follow:
To connect to the UART you can use the program Putty, with the baud rate being 57600 or, alternately, the Arduino Serial Monitor, also using the same baud rate, just remember to change the connection port before using the Serial Monitor.
After the Serial connection is made, you can press 'h' to get the full list of commands available through it.
NOTE: Please take note that this UART connection is only for receiving and transmitting data from/to the MMKit at runtime, you still need to use the USB Connection to upload the sketch.
The calibration consists of 4 parts:
- Side sensors raw calibration
- Front sensors raw calibration
- Front sensors sum/diff calibration
- Adjust the threshold values
To help with this process a routine was created to help you calibrate the robot, you cal call it if connected through the UART by pressing the key 'c'.
The first step in calibrating the raw value of the side sensors is to place the robot in the center of a cell, with a wall in each of the sides. The side sensors should be in an angle so as to detect the edges of the front wall.
When reading the sensors values, they should be similar in both sides, if not, adjust the sensors so that the read values are as close as possible.
Finally, save the read values in the variables LD_CAL and RD_CAL, for the Left Diagonal value and Right Diagonal value correspondingly, inside the file parameters.h.
For the front sensors raw calibration, the steps are similar to before. Start by placing the mouse in a cell with a wall in each of the sides, except, this time, the mouse should be place against the rear wall, instead of centered in the cell.
As before, when reading the sensors values, they should be similar in both sides, requiring an adjustment of the sensors if the values are not alike.
To finalize, the read values must be saved in the variables LF_CAL and RF_CAL, for the Front Left value and Front Right value correspondingly, inside the file parameters.h.
The next step is to calibrate the sum/diffs for the front sensors. To do so, position the mouse against the rear wall, but with the front of the mouse faced to it.
Before continuing, be sure to remove the back wall, as the mouse will move in reverse for this calibration.
When the mouse is moving, be sure to not influence its movement, if connected to the UART by cable. If the mouse doesn't moves in a straight line, run the subroutine again.
After the subroutine is finished, save the first array of values in the variable frontSumTable, and the second array of values in the variable frontDiffTable, inside the file sensors.cpp.
NOTE: If the mouse moves forward, instead of backwards, you have the motors connected in the wrong order, and you will need to swap the left with the right motor connection.
The final step for the calibration is to adjust the threshold values, for this you can use the command 'S' under the serial port that shows the walls the mouse is currently detecting together with sensor calibrated values. You can change DIAG_THRESHOLD, FRONT_THRESHOLD and FRONT_WALL_INTERFERENCE_THRESHOLD, in the file parameters.h, so the mouse sees the walls correctly.
The FRONT_THRESHOLD must have a value that allows the MMkit to see the wall in front when it is positioned in the first part of the cell just before entering the cell.
The DIAG_THRESHOLD must have a value that if the mouse is bettewen two walls and is near on of the walls he still can see the other.
The FRONT_WALL_INTERFERENCE_THRESHOLD is the sum of the value that the side sensors see when they MMkit is in the midle of the cell, as the MMkit reaches the wall in front this values start to have the reflex from the front wall so they are unrealiable to use for adjustment, therefore the MMkit must align using the front sensors.
To start a new run, position the mouse against the rear wall in the initial cell, make sure that the switch labeled 1 is faced to the right, and move switch 2 left to right, as to simulate a button. After, a red led should be turned on, just occlude the left sensors to start the discovery run.
After the mouse as finished its discovery phase, it will return to the start cell. When he reaches it, don't move the mouse to the rear wall again, only adjust its angle if needed, and occlude the left sensors to start the run to the finish line.
Some additional documentation is also available in the latest release page in a zip file named MMKit-doc. This includes:
- Code documentation generated from Doxygen
- The MMKit's layout
- The MMKit's schematic