Electrical

We broke our electronics up into a series of different modules that could be constructed one at a time and tested with the C32. We had 5 modules: Elevation Control, Penny Sensing, Firepower Charging, Score/Prize, and Firing/Ammo. These modules interfaced with the C32 in the following way:

 

Elevation Control Module:

The elevation control module was reponsible for gathering analog user input and passing it through the C32 to determine which direction to spin the elevation drive. The basic design consisted of a potentiometer read by an A/D converter. If the C32 saw above an upper threshold voltage, the motor would turn one one. If it saw below a lower threshold voltage, the motor would turn in the opposite direction. The speed of the motor was dependant on the difference from the threshold votlage. We used that difference to set the PWM duty cycle. We also created a deadband between the upper and lower threshold voltage so the user could return the knob to a neutral position where the motor would stop turning. The circuit also contains two limit switches. When the switches are triggered, the circuit cuts power to the motor. This limits the firing range from 15-80 degrees so that the cannon does not damage itself or fire outside the envelope.

 

Penny Sensing Module

The penny sensing module was relatively straightforward. We detect the penny with a coin sensor (optointerruptor). When the C32 detects a penny, it pulses output to a buzzer which beeps. Our system was set up so that the game could take up to 3 consecutive pennies as long as they were inserted in a 3 second window.

 

Firepower Charging Module

The firepower module was responsible for determining how long the user had held down the firepower button and lighting the corresponding percentage of the LED bargraph display. It would then control the motor speed using PWM to set the distance the balls would be shot. We used an LED bargraph driver chip to light our display without taking up too many pins. The driver required analog input so we created a D/A circuit using PWM and a low pass filter with a giant time constant. We controlled motor speed with PWM to an H-bridge.

 

Firing and Ammunition Module

This module was responsible for firing the cannon and decrementing the shot display accordingly. When the C32 saw high from the switch, it would actuate a solenoid which knocked the balls into the spinning wheel, firing them out of the cannon. The module also used a shift register to decrement the display showing how many shots the user had left.

 

Score and Prize Module

This module kept of the score. We used an optointerruptor to sense when a target had been hit. Target sensing was done entirely in hardware by our electronics genius Shaoqing. Using a comparator and a shift register along with some good old fashioned magic, he designed a circuit that would light a bargraph display to show how many targets had been hit without using the C32. At the end of the game, the C32 would read the data from the shift register and determine how many targets had been hit. We spun the prize motor using a MOSFET for 1 second per target hit. This would actuate the firing mechanism on our candy dispenser using a nifty cam and shoot candy at the lucky winner.