10. Machine design¶
Assignment
There was no individual assignment for this week. The group assignment for this week included the following tasks. We were tasked with designing a machine that includes machinsm, actuation, and automation, building the mechanical parts and operating the machine manually, and documenting the group project and our own individual contributions to the construction of the machine.
Foreword
While the work that is documented below is certainly not my most impressive work, my teammate, Drew Griggs, and I were heavily limited in what we could eventually accomplish due to numerous issues that occurred with our two other groupmates who both were not able to complete the program for different reasons and were therefore unable to assist us in the design and construction process of our machine. Generally, the mechanical design project is accomplished by groups composed of all of Latin's Fab students for any given year, yet due to the amount of students taking Fab this year we decided to diverge into two groups. We lost half of our members during the first week of machine week and were forced to resume the assignment during the week after our final project presentations. I am still proud of our work given the circumstances, but simply wanted to express why the work looks like it was not done by a large group. This is by no means to say that we did not put a significant amount of time into the development and construction of our pinball machine though, because we certainly did.
Deciding what to make
Prior to constructing a machine, we needed to decide what we were going to make. After much deliberation and consideration of a variety of cool machines that we could make, my groupmates and I decided to constructed a fully-scaled pinball macine that would include various mechanisms that the classic arcade machines are known for. We originally wanted to give the machine an interesting theme, but time constrains and problems with groupmates absconding from the program ultimately forced my groupmate and I to construct a relatively barebones machine.
My Contributions to Our Pinball Machine
As this week's assignment was a group assignment, the cumulative effort of Drew and I is documented in extensive detail on our shared CLS group site. My individual contributions to the machine are documented below.
Designing the machine
I did not contribute a significant amount of work to the design of the machine, but I did assist in the design process of various structural elements of the machine, including the pieces that aid in the routing of the pinball throughout the machine, which we decided would slot into an acryllic "playfield" where the ball would roll.
The design for the playfield includes various slots that allow the rails for guiding the balls to slot into, creating an enjoyable and challenging game by sectioning off various sections of the playfield.
After completing the CAD for the models of the ball-routing components, we utilized our lab's printer farm to quickly print out all of the necessary components as efficiently as possible, allowing us to rapidly iterate upon our design.
After printing all of the rails for the machine, we laser cut a rough design of our playfield to test that all of the rails fit into their slots correctly prior to using an expensive piece of smoked acrylic for the final playfield. While all of the slots in the above image functioned as planned, the dimensions of the playfield were slightly off and were adjusted prior to cutting the final piece that was used in the final machine. Documentation for this re-design is included on the group site which is linked at the top of this page.
Writing The Code
As we initially planned to use capacitive sensing to detect the location of the pinball throughout the machine and award points to users accordingly, I wrote an Arduino code that would accomplish this task. This code was never applied in any capacity (no pun intended), but I am relatively certain that it would have worked had we not struggled from issues that prevented us from creating the incredibly-detailed machine that we originally planned to construct. The code that I wrote uses the capacitive sensing library, which allows electric connections to be detected when something comes into contact with copper tape that is grounded and connected to a data line on an Arduino, allowing the location of a pinball to be detected in this application by measuring deviations in the pressure on certain pressure pads that we planned on placing throughout the machine. While it is unfortunate that the component of the project that I devoted the most amount of time to never made it into the final version of the machine, we likely would not have been able to finish the machine in time had we decided to include the capacitive sesning of the pinball as originally planned. Now that the machine has been scrapped for parts, it is unlikely that my code will ever be implemented.
//pinball machine V1.00
#include <CapacitiveSensor.h> //capacitive sensing library
CapacitiveSensor f1Cap = CapacitiveSensor(4, 2); //wire from pin 2 to left side of res w/ 10MOHM res - ABOVE FLIPPERS
CapacitiveSensor f2Cap = CapacitiveSensor(5, 3); //wire from pin 5 to left side of res - BOTTOM OF PLAY FIELD
CapacitiveSensor b1Cap = CapacitiveSensor(6, 7); //wire from pin 6 to left side of res - FIRST SOLENOID BUMPER
CapacitiveSensor b2Cap = CapacitiveSensor(8, 9); //wire from pin 8to left side of res - SECJOND SOLENOID BUMPER
bool game = true;
bool touchedBOTTOM = false;
const int solenoid1 = 10;
const int solenoid2 = 11;
const int threshold = 500;
unsigned long csSum; // for eliminating random errors
const int upperSens = 30; //sensitivity for upper capacitive sensor for rapid debugging
const int lowerSens = 30; //sensitivity for lower capacitive sensor for rapid debugging
const int lThreshold = 20; //threshold for sensor above capacitive sensor
const int uThreshold = 20; //threshold for sensor below capacitive sensor
//SCORING VARS
const int flipAmount = 50;
const int backAmount = 100;
int finalScore = 0;
int balls = 1; //start balls
int score = 0;
void setup() {
const int neoPin = 0; //placeholder for neopixel pin
f1Cap.set_CS_AutocaL_Millis(0xFFFFFFFF);
f2Cap.set_CS_AutocaL_Millis(0xFFFFFFFF);
b1Cap.set_CS_AutocaL_Millis(0xFFFFFFFF);
b2Cap.set_CS_AutocaL_Millis(0xFFFFFFFF);
Serial.begin(9600); //initialize serial monitor for debugging
Serial.print("pinball machine");
pinMode(neoPin, OUTPUT); // initialize pin for neopixel lighting
pinMode(solenoid1, OUTPUT);
pinMode(solenoid2, OUTPUT);
}
void loop() {
while(game == true){
touchedBOTTOM = false;
aboveFlipRead(); //always want to check this first because i said so
checkBalls(); //check if balls are still in play, if not end the game
checkb1Cap(); //check first solenoid capacitive sensor
checkb2Cap(); //check second solenoid capacitive sensor
}//while
}//main
void aboveFlipRead() {
long flipperRead = f1Cap.capacitiveSensor(upperSens); //read top capacitiveSensor, break if normal value
Serial.print(flipperRead);
if(flipperRead >= uThreshold) {
flipCount(); //need to see if capacitive sensor above flippers is triggered again or if sensor below capacitive is triggered, meaning the ball is dead
return; //back to main
}
else{
return; //back to main
}
}
void flipCount() {
long start = millis();
while(((millis() - start) < 1000) && (touchedBOTTOM == false)){ //TIME FOR EITHER SENS TO TRIGGER
Serial.print(f1Cap.capacitiveSensor(upperSens));
Serial.print(f2Cap.capacitiveSensor(lowerSens));
if(f1Cap.capacitiveSensor(upperSens) > uThreshold){
score += flipAmount;
touchedBOTTOM = true;
return;
}
else if(f2Cap.capacitiveSensor(lowerSens) > lThreshold){
balls = balls - 1;
touchedBOTTOM = true;
return;
}
}
return;
}
void checkBalls(){
if(balls >= 1){
return; //return to main
}
else{
game = false; //end the game if balls !>= 1
endGameProcedure(); //DOESN'T EXIST YET!!!!
}
}
void checkb1Cap(){
long flipperRead = b1Cap.capacitiveSensor(upperSens); //read capacitive sensor next to first solenoid
Serial.print(flipperRead);
if(flipperRead >= uThreshold){
digitalWrite(solenoid1, HIGH);
digitalWrite(solenoid1, LOW);
score += backAmount;
return;
}
else{
return;
}
}
void checkb2Cap(){
long flipperRead = b2Cap.capacitiveSensor(30); //read capacitive sensor next to first solenoid
Serial.print(flipperRead);
if(flipperRead >= uThreshold){
digitalWrite(solenoid2, HIGH);
digitalWrite(solenoid2, LOW);
score += backAmount;
return;
}
else{
return;
}
}
void endGameProcedure(){
finalScore = score;
Serial.print(finalScore);
finalScoreLogic(); //determine if new final score exceeds old highscores...
}
void finalScoreLogic(){
//LOGIC
}
When returning to the pinball machine following the presentation of my final project on June 16, 2021, I wrote an incredibly simple code that was applied in order to detect the press of one of the large buttons that are mounted on the left and right sides of the machine on an Arduino and trigger a 12V solenoid that is connected to our power supply and a data line of the Arduino. The dataline is routed through a 12V relay that toggles the relay on the press of one of the buttons on our machine.
#define b1Pin 5
#define b2Pin 6
#define solenoid 3
void setup() {
pinMode(b1Pin, INPUT_PULLUP); //initialize first (right) button
pinMode(b2Pin, INPUT_PULLUP); //initialize second (left) button
pinMode(solenoid, OUTPUT); //initialize solenoid pin as output
}
void loop() {
if(digitalRead(b1Pin) == LOW || digitalRead(b2Pin) == LOW){ //due to internal mechanisms, which button is pressed doesn't matter
digitalWrite(solenoid, HIGH); //turn solenoid on on button press
delay(200);
digitalWrite(solenoid, LOW); //turn solenoid off after short delay, allowing "flip" to occur
}
else {
digitalWrite(ledPin, LOW); //not really necessary for this application but fun to have
}
}
This final code worked on the first try, so no debugging was necessary. It is not complicated by any means, but it allowed to successfully interact with the 12V solenoid through a 5V Arduino by triggering a button running on 9V, which was a pretty complicated task given our poor knowledge of voltage regulation prior to this week's assignment. For a full run-down of all of the wiring within our machine, please visit the group site where this component of the project is documented in very good detail.
Electronics
Due to the extreme size of our pinball machine, lots of wiring was needed in order to connect the power supplies and Arduinos that are mounted in the rear of the machine due all of the buttons that are mounted at the front of the machine where a user interacts with the machine. Additionally, as the Arduino runs on 5V and the solenoid that we used runs on 12V, we needed to create several voltage regulator boards in order to safely power the Arduino. Connecting the common ground throughout the entirety of the machine was another challenging aspect of the wiring of the machine due to its immense size. Many wires were needed in order to connect the ground of each of the many components that are by no means in close proximity to each other within the interior of our machine.
We used proto boards with voltage regulators to step down the 12V from the power supply to the 5V needed for the Arduinos to run. We have one Arduino running the static Neo-Pixels (originally intended to react to in-game events but no capacitive sensing made this impossible) and another that is running the code shared above that controls the solenoids based on input from the on-board buttons. The circuitry for these boards is relatively simple, the 12V is routed to the VIN of the regulator, ground is connected to the common ground of the machine, and 5V comes out of the VOUT to be connected to the 5V headers on the Arduinos.
After connecting all of the internal electronics, the wiring was relatively messy, but it did function as intended. Due to the extreme size of the machine, cable management for anything was incredibly time-consuming and given the very small team that we had during this phase of the project, we figured it was best to leave the cables in this state. Had the machine been smaller than it was, cable management likely would have been necessitated, but because it was so large we were able to route the cables in this manner with ease with lots of room to spare.
The solenoid was connected to a mechanism designed by Drew that allowed a single solenoid to fire both of the flippers at once because we discovered that we did not have enough current to fire each of the solenoids at the same time. The solenoid was connected to the bottom of the final acrylic playfield whose constructino process is documented on the group site.
Final Assembly
The final assembly of the pinball machine required the connection of the final acrylic playfield to the body of the machine. This process was incredibly time-consuming as we did not have many people asssiting with the construction and the machine was incredibly large.
We began the process of the final assembly of our machine by designing several wood beams that spanned across the surface of the acrylic playfield. These beams would serve as supports for the playfield in the machine and keep the entire playfield level, as the surface of the acrylic was relatively warped even before we cut it.
Mounting five beams to the acrylic ensured maximum stability throughout the entirety of the playfield to ensure the most engaging user experience possible during the usage of our machine.
After mounting all of the wood beams to the acrylic playfield, we were ready to install the playfield inside of the physical body of the machine. Drew drilled screws through the body panels into each of the beams on each side of the machine while I held the playfield level from within the machine. This process required contortion and the usage of all of my limbs to complete so there is no video of the lengthy process.
After mounting the playfield within the body of the device, we were ready to test our pinball machine for the first time. We began by operating the machine manually. The video below demonstrates the manual actuation of the flippers that are powered by the solenoid automatically in the final version of our machine.
Next, we began using our machine with an assortment of balls to test how well it performed. We discovered that we were undervolting the machine rather severely, as the solenoid was not receiving enough voltage to prople the balls to the back of the machine as intended.
The image below shows the final assembly of the pinball machine. If you want to read more about the process of designing and constructing our machine, please visit the group site page for this assignment that is linked at the top of this page.