Automated Bubble Blower
Priyank Varshney (010515258) and Bobby Haus (010224370),
CmpE 30 Spring 2016, Lab Section 01
Computer Engineering Department, Charles W. Davidson College of Engineering
San Jose State University
Abstract
This report will describe the process required in order to build an automated bubble blower using a light sensor, servo, and a SJSU One board. A diagram of how our circuit was setup, as well as, the design methodology will be provided in the report for reader assistance.
This project will use two SJSU ONE board microcontrollers to control the servo that is attached to the bubble wand that is monitored by the buttons on the board and to turn the fan on based on the light that the board receives. The general purpose input output pins, that are part of the SJSU ONE board, provide allow us to send signals to the servo and the fan. Through these pins, the amount of voltage that is sent to the servo or the fan can be controlled, which consequently means we can turn these loads on and off.
II. Design Methodology
Two separate SJSU ONE are used to make this project function properly. Attached to the breadboard on one side is a 6 Volt battery pack, which is used to power the servo. Then on the other side of the breadboard there is DC barrel connected to a 12 volt wall outlet to power the fan. One SJSU ONE board was used for each side of the breadboard.
In order for this project to work properly, we used jumper wires to connect the GPIO pin on the SJSU ONE boards to the gate channel of the transistor. We did this for both sides of the breadboard in order to control the voltage to both the fan and the servo. From each board there was also a cable that connected from the ground pin to the negative side of the breadboard so the SJSU ONE board could be grounded.
Because the SJSU ONE board can only give an output of 3.3V that is why the external battery sources were connected to each side. Because the 12V barrel was connected to the side of the breadboard where the fan was connected, we needed to use a transistor to complete the circuit and allow us to control the flow of voltage to the fan. If the light sensor on the SJSU ONE Board read a lighting that was less than normal level of light, then the board would signal to allow high voltage to come through which would allow the transistor to let the voltage flow through the circuit and turn the fan on. Otherwise the board would send a signal to set the voltage to zero where the transistor would not allow the voltage to flow meaning the fan would stay in its off state.
On the other side of the breadboard is the circuit required to power the servo with the 6 volt battery pack. The buttons on the SJSU ONE Board on this side of the project are programmed to move the servo in the desired direction. The first button would move the arm up, the second one would move it back down and the third would put the servo on a timer where the the arm would move up and down on its own. This was wired without the transistor because we did not need to control the voltage through a sensor. All of the actions by the servo were controlled through the programmed buttons in the SJSU Board. The code for both the fan and the servo and the state diagram can be found in Appendix B and C.
B. Schematics
Schematics for this circuit design can be found in appendix A.
III. Testing Procedures
A wide multitude of test were performed on our product in order to ensure the best possible reliability and results. The steps included:
IV. Testing Results
We conducted many tests for our project in order to make sure that the product worked smoothly. We ran into a couple of obstacles along the way. One of the first problems encountered was making sure that we had the correct power source for our servo and fan, which were key components in the project. The servo required a 6V battery pack, and the fan required a 12V power source. Initially, we had the 6V battery pack powering both objects, however it wasn't providing enough voltage to the fan to let it run at its highest potential. Next, we ran into difficulties in getting the servo to position itself at the critical points desired. The servo was often getting stuck, and fluctuating a lot. The problem lied in the actual code for the servo, and once that problem was solved we were able to program the servo to run smoothly. We were able to use a special method in order to get the light sensor to calibrate and adjust to different lighting environments. We had the light sensor retrieve six different raw values of how much light was being inputted and had the program average the value out. This allowed the sensor to tell the fan to turn on or off based off of the average reading, as a result making the product more accurate at detecting when the wand was in front of the fan. Overall, a wide variety of obstacles were confronted during testing, and fortunately the team was able to find viable solutions to solve the problems.
V. Conclusion
The purpose of the lab was to build an automated bubble blower using an SJSU One board, and circuitry including a transistor. By the end of the experiment, we were able to create a successful bubble blower that was able to be controlled by the user through switches in the SJSU One board. We ran into many problems during the whole process including the functionality of the servo, powering the fan, calibrating the light sensor, and making sure all aspects of the software were programmed efficiently and correctly. Luckily, for each of the problems we were able to find a resounding solution, and put all of the parts together to build a fully functional bubble blower. This lab has taught us many concepts regarding the relationship between hardware and software and how they can come together and work as one. It shows how even for such a simple project it takes a decent amount of circuitry knowledge, as well as coding knowledge to engineer a product. This project showed us how important testing is in engineering and how large of an impact datasheets and documentation makes when using a multitude of parts. With a more advanced project, no doubt the engineering feats would be greater, however through this project we were able to learn and experience the full engineering process. Ultimately, the experiment was a success as the bubble blower was able to successfully blow bubbles with the designated parts and hardware/software.
VI. Appendices and References
Appendix A: Circuit Diagram
Appendix B: State Machine Diagram
Appendix C: Source Code
Code for SJSU Board #1 (Relates to the Servo):
#include <stdio.h>
#include "utilities.h"
#include "io.hpp"
#include "lpc_pwm.hpp"
int main(void){
PWM servo1(PWM::pwm1, 50);
while(1){
delay_ms(50);
if(SW.getSwitch(1)){
servo1.set(11.3); //Up
printf("Right");
}
if(SW.getSwitch(2)){
servo1.set(7.5); //Down
printf("Neutral");
}
if(SW.getSwitch(3)){
servo1.set(7.5); //wand comes down from initial
delay_ms(1000);
servo1.set(11.3);
delay_ms(5000);
servo1.set(7.5); //wand comes down from initial
delay_ms(500);
servo1.set(11.3);
delay_ms(6000);
}
}
}
Code for SJSU Board 2 (Relates to the light sensor and Fan):
#include <stdio.h>
#include "utilities.h"
#include "io.hpp"
#include "lpc_pwm.hpp"
int main(void){
GPIO pin20(P1_20); /* Use P1.20 as General Purpose Input/Output (GPIO) */
pin20.setAsOutput();
int lightValue1= LS.getRawValue();
delay_ms(100);
int lightValue2 = LS.getRawValue();
delay_ms(100);
int lightValue3 = LS.getRawValue();
delay_ms(100);
int lightValue4 = LS.getRawValue();
delay_ms(100);
int lightValue5 = LS.getRawValue();
delay_ms(100);
int lightValue6 = LS.getRawValue();
int averageLightValue = 0;
averageLightValue = ((lightValue1 + lightValue2 + lightValue3 +lightValue4 +lightValue5 +lightValue6)/6);
printf("Value 1: %i \t Value 2: %i \t Value 3: %i \t Value 4: %i \t Value 5: %i \t Value 6: %i \t Average Value: %i \t", lightValue1, lightValue2, lightValue3, lightValue4, lightValue5, lightValue6, averageLightValue);
while(1){
int light_value = LS.getRawValue();
if(light_value >averageLightValue ){
pin20.setLow();
printf("Fan Off\n");
}
if(light_value < averageLightValue ){
pin20.setHigh();
printf("Fan On\n");
}
}
}
Page of 8