Use Sensors and Actuators to Make a Mechanical Labyrinth Maze
by Kinoma in Circuits > Sensors
9115 Views, 183 Favorites, 0 Comments
Use Sensors and Actuators to Make a Mechanical Labyrinth Maze
A three-axis accelerometer captures the tilt of the Kinoma Create. Kinoma Create processes the tilt data in software to control the rotation of two servo motors connected to the maze. The result is intuitive movement of the maze relative to the controller. Mechanical gears convert the 180 degrees of servo rotation into 16 degrees needed for maze control.
Parts List:
For control we use a triple axis accelerometer, Servo Controller board, level shifter, metal gear based servos, large drive gears, and a battery pack. For the frame we use assorted aluminum stock and some wood parts.
- Download Kinoma Studio
- Kinoma Create
- ADXL335 Triple axis accelerometer
- Servo motor (Hitec HS-625MG)
- Servo mount
- SSC-32U USB Servo Controller (Lynxmotion)
- Battery pack
- Servo 12 tooth gear (Hitec)
- 128 tooth servo gear (Actobotics)
- Large gear hub adaptor
- Flanged bearings
- 1 1/2 x 1 1/2 x 1/8 Angle aluminum stock
- 3/4 x 3/4 Box section aluminum stock
- 3/4 x 1/2 U section aluminum stock
Basic Measurements
We have proven Kinoma Create can control multiple servos and that basic servos when geared down are strong enough to easily move the gimbled maze. We would be delighted to see others push this concept further with larger and more complex labyrinths.
Outer Frame
The outer frame needs to be rigid, because it is carrying the weight of the inner frame, maze and inner servo and gears. We did everything we could to keep the parts moved by the servos both lightweight and stiff. After working out the part fit we replaced nuts and bolts with rivets. We used flanged bearings on all the pivot points. A sample of the aluminum stock is below.
We used a cut off saw to miter the outer box stock. We cut our own angle brackets from the 1 1/2 inch angle material.
We used two brackets in each corner for added stiffness. Make sure to offset your bolt/rivet holes so there is internal clearance for the rivet backs.
Outer frame with rivet fasteners.
Center the large gear on the axle and attach to outer frame.
Because our outer frame has an interior dimension of 5/8 inch square we could insert hardwood stock to make the axle area stiff and allow installation of threaded nutserts to greatly simplify assembly and disassembly.
Once both tables and maze are in place, balance the frame/maze assembly by adding weight to the outer frame on the side opposite the servo and gear. This reduces the strain on the outer frame servo. We added weight inside the outer frame and put steel bar stock under the frame.
Inner Frame
The inner frame is smaller in one dimension to allow space for the gear to control the inner table rotation. It is U shaped stock to capture the maze element and has one end fastened with bolts so the maze can be changed. Similar angle brackets set up the corners.
Servos, Gears, and Axles
Using threaded bolts as axles simplifies disassembling the labyrinth for travel. The axles are 1/4 inch bolts. With 1/4 inch bolts we can use standard bearings which helped smooth the motion. The servos had to be mounted so they could pivot away from the large gears for disassembly and setup. The servo mounts from SparkFun are very rigid and take minimal space on the frame.
The large gears have oversized center openings. We chose these gear hub adaptors so we could accurately get them centered on our axels, eventually fastening them directly onto the frames.
The servos need to pivot away from the large gears for disassembly and to adjust gear lash. For the inner frame we made a pivoting bracket out of angle material with a threaded nutsert to fine-tune the servo gear engagement.
The outer frame servo is mounted on a similar pivoting angle bracket on the inside of the table support. Oversizing the hole in the table support gives play for final adjustment.
Do what you can to keep all the holes straight and true.
Maze
We made the maze from PVC material. We purchased our material at Tap Plastic in California. We had 1 inch strips cut out of 1/4 inch material so we could easily make our wall sections. The base was 1/8 inch sheet. Working and gluing the PVC is simpler than other materials and it is fairly light and stiff. You can come up with any interesting maze design challenges. We tried wooden, steel and acrylic 1 inch balls. The acrylic gave best game play. We painted a clear off-the-shelf sphere.
Supports
The base and supports are wood. We put threaded inserts here to make working with the axles simpler. We added nutserts on the bottom of the supports to make mounting cleaner. Once you have the supports and frames built you can adjust final positioning with 1/4 inch nylon spacers.
Control Boards
We used a Lynxmotion Servo Controller which generated very stable PWM signals. We made a small proto-board to shift the voltage of our signal from the Kinoma Create's 3.3v to the 5v expected by the Lynxmotion Servo Controller. Depending on the servos you use, supply the needed motor power. We used 9 volts with these Hitec HS-625MG servos. We added some strain relief to the connection cable on the base and in the Kinoma Create.
Accelerometer Module
Install the Accelerometer Module in the front sensor bay. Here we used the left side. Configure the pins to match the placement of the module using the Front Pins app.
Kinoma Create Labyrinth App (LabAccel)
Download LabAccel source code.
Import the app and needed BLL's into Kinoma Studio. First download the code. The zip file contains the app code and required BLL's. Leave it as a .zip file.
Step one, in Kinoma Studio select Import from the File Menu.
Step two, select Existing Projects into Workspace.
Step three, choose the select archive file option and navigate to the downloaded LabAccel.zip file. The project and associated BLL directories should show in the import panel. Select the "Finish" button to complete the import.
At this point you can edit and run the main application file src/main.js. To run the app click the Run button on the LabyrinthAccel/application.xml page. You will see your Kinoma Create device if it is on the same Wi-Fi network.
Tip: If you select the gear next to your Kinoma Create in your studio page you can check the box "Install on launch" which will install the app on your Kinoma Create for future use without re-running from the Studio IDE. Without checking that box the app is only temporarily installed.
After you launch the LabAccel app put the Kinoma Create on a flat surface and single tap on the axis of the cross hairs to center the servo motors.
Downloads
Code Snippets
The KinomaJS application has two essential tasks: monitoring the accelerometer and translating the sensed acceleration data into matching motor commands. A basic configuration and reading of the analog accelerometer data could be accomplished in a BLL like this:
It would be better, however, to add a couple of features to our accelerometer BLL. The first is calibration: the option to tell the BLL when the device is level. The second is smoothing: reducing the noisiness of the analog input to prevent jitter of the labyrinth. In the full project source, there are implementations of these two features. The smoothing is accomplished using a simple low-pass filter.
Sending commands to the motors is accomplished in two parts. The BLL side listens for commands from the app and converts them into serial messages following the SSC32u's communication protocol (as specified in its user guide). The BLL looks like this:
The app communicates with the motor BLL every time it gets data back from the accelerometer BLL. This begins when the 'data' handler of the app is invoked as the accelerometer's callback. This handler updates the display, calculates the proper angles for the two servo motors, and then calls the doMotorControl function. doMotorContorl invokes the 'sendDualCommand' function of the motor BLL:
Congratulations!
You’ve done it! Or if you got stuck along with way, we’re here to help — come visit us at our forum and let us know how we can help.