14.4 - Implementation

Fabrication and Assembly

Our system was manufactured out of acrylic to achieve both higher strength and a more attractive design. We started by laser cutting our links out of 6mm thick acrylic. We used hot glue to create a more snug press fit for the bearings into our links. Additionally, a 450 x 350 mm base plate was cut to build our system on top of. Below is an image of our links and base plate.

In order to allow to attach a motor to the machine, we laser cut legs for it. Additionally, to affix the cat toy to the output link, we attempted to glue the toy to the small hinged attachment on the output link. These had the same problem: hot glue does not create a strong enough connection for acrylic. To solve this problem, we purchased acrylic specific super glue that chemically bonded the two pieces together. Using this, we created four legs, gave the entire system a bottom baseplate and created a new hinged attachment which held the cat toy. We also created a small table with M3 holes to hold the heavy motor and it was attached to the bottom baseplate. Attached is an image of the machine after day 2 and the acrylic glue we used.


Finally, we laser cut our cam-walls. They were firstly affixed to each other with the acrylic glue and then attached to the top plate. One difficulty we had was the size and weight of the cam-walls. Careful pressure needed to be applied while fabricating them as they would often collapse under their own weight. Finally, we added the Arduino, breadboard, motor controller, and joystick and affixed them with velcro. 


Electronics and Circuitry

The electronics is a simplified version of the car, the arduino gets power from the battery, which is connected to the motor controller, and then the motor controller is wired to the motor which outputs to the 4 bar rocker mechanism.


Software Development

The coding really came down to 3 different objectives, with those being:

  • Working button with joystick switch
  • Able to swap between different modes (idle, automatic, manual)
  • Making those 3 modes work as intended


We decided to work on the button first, as the button seemed the most difficult because of how the switch gives its analog signal. For reference, the switch gives an analog signal of 0 when the switch is pressed, but because the sampling rate of the arduino needs to be fast so the manual mode has little input lag, the switch samples many 0’s when a button is pressed. Because of the many zeros that are sampled, if we just coded something that responds to a 0, we would have many false positives. The image below shows how a single button press generally looks like. The 0’s are the switch’s analog reading, with the last reading being 77. The 2 at the end is indicating the counter.

The way we get around this is that we sample twice, with the second sampling having just a slight delay compared to the first, then with the second sample, we code a button that responds to the first sample being a 0 and a second sample being any number above 1. In testing, this had around a ~95% success rate, and very little false positives unless there was something wonky with the power/quality of the joystick. This method is essentially just manually debouncing a switch. 



The second objective is to be able to switch between different modes. Now that we have a button that is able to register button presses, we need to create something that combines button presses and the ability to switch between cases. For this, we just create a counter with the following code:

And then we just make the 3 place holders for the 3 cases. 


For the last part, actually making the 3 modes, we just need to look back to previous projects because those have similar code that we are able to just use.

For case 1, it is easy. We just need to set the PWM amount to zero. It is now idle.

For case 2, automatic, we just need to set the PWM amount to a constant amount. Through trial and error, we decided on the number below, as that number went over the cam just the right amount without being overly erratic and derailing from the cam.

For case 3, the code is similar to the car, as it is just a more simplified version of it. As shown below, if the analog reading from the joystick is less than 400, which would be going left, then the motor turns counterclockwise. If it reads more than 600, then the motor turns clockwise. If it's between 400 and 600, it's idle. 


It is important to note that in order for this to work more than just once, we need to have a counter resetter at the end, which resets the counter entirely back from 3 to 1. The code is as shown below.