Thursday, June 14, 2012

PING-PONG SHOOTER



Goal
The Ping-Pong shooter, as its name , is able to shoot Ping-Pong balls, and the machine can simulate a real-world situation that if there is a player in front of it, it starts shooting; otherwise, it stops working. 

Criteria of Success 
Able to control the system intangible 
Able to control the machine i.e. control weather the ping-pong ball will shoot or not 
A machine that can shoot 


PERT Chart 


How It Works 
The Ping-Pong shooter mainly contains three parts. The first one is a switch which is made by connecting to a photoresistor. The second one is two DC motors to shoot the balls. The last one is a stepping motor.


Main component 
Photoresistor 
DC motor 
Stepping Motor (28BYJ-48) 
Microcontroller (89s51) 
Octal high voltage high current Darlington transistor arrays (ULN2803) 
Voltage regulator(L7805CT) 



ULN 2803 
A ULN2803 is an Integrated Circuit (IC) chip with a High Voltage/High Current Darlington Transistor Array. It allows you to interface TTL signals with higher voltage/current loads. 
The chip takes low level signals (operate at low voltages and low currents) and acts as a relay of sorts itself, switching on or off a higher level signal on the opposite side. 


L7805CV 
Disadvantage: Input voltage always needs to be higher than the regulated voltage
I.E. 7805 = 5V, 7812 = 12V 
The 78xx family is commonly used in electronic circuits requiring a regulated power supply due to their ease-of-use and low cost .


Miscellaneous Component 
Resistor (10k Ω *2) 
Capacitor (33pF *2, 100nF *1 ) 
Oscillator (12MHz *1) 
Wires 
PVC tube (2” Diameter) 


Schematic 



Function 1: Switch 
Electronic switch on pin 9 (reset) of microcontroller 
Using a photoresistor and a suitable resistor with voltage divider 
Photoresistor: 

  Bright= Small resistance; Dark= Large resistance 






   Voltage out connect to pin 9 
Pin 9: 
   High = turn off , Low = turn on 



Theoretical Calculation 
Photoresistor: 1k ~ 14k Ω 
R1, R2: 10k Ω 
Vin : 5V 
On:
 








Off:


Analysis 




Light On 


Light Off 


Function 2: DC Motor (Shooter) 
Two DC Motors - one is spinning counterclockwise, and another is spinning clockwise 
Rubber on Cap to increase the friction between surfaces 


Function 3: Stepping Motor (Gate) 
Brushless DC motor 
Divide full rotation into a number of parts 
28BYJ-48: 
Four phases five wires 
12VDC 
1100 0110 0011 1001 1100 
Advantage: Precisely control the position of rotation



Serial Programmer 
Homemade programmer 
Connect to print port 





To Control the Stepping Motor 
Pre-programmed microcontroller 


Criteria of Success 
1. A machine that can shoot ✓ 
2. Able to control the machine i.e. control weather the ping-pong ball will shoot or not ✓ 
3. Able to control the system intangible ✓ 



Cost 
Home Made 

eBay 
Joola Joola iPong Topspin (Green) Table Tennis Ball Machine i0 
$77.00 
Conclusion: 

Cheaper to build than buy one Component





Price/unit 
ULN2803 
0.32 
AT89S51 
0.75 
L7805CV 
0.2 
Oscillator(12MHz) 
0.04 
Laser Diode 
0.99 
PVC TUBE 
3.00 
Stepper Motor 
0.40 
DC Motor 
0.00 
Miscellenuos i.e. resistor, capacitor 
0.05 
Bread Board 
1.67 
Total 
7.42 







Saturday, May 19, 2012

FreeMat Activity in Complex Calculation

Purpose
  The purpose of this assignment is to know how to do complex calculation by hand and compared the results to FreeMat.

Assignment


Assignment 1 answer
By Hand
By FreeMat

Assignment 2 answer

Assignment 3 answer
By Hand

By FreeMat

Assignment 4 answer



Impedance and AC Analysis I

Purpose
    This lab has been broken into two parts. The purpose of the first part is to investigate a real-world inductor which is equivalent to connect with RL and L in series, so the impedance ZL can be determined as ZL = RL + jwl and determine the inductance by looking for the ratio of magnitude of the terminal voltage and current phasors by following circuit.
Figure 1. Designed Circuit to Determine L in Part 1.

For second part of this lab, we want to find out at which frequency will the impedance become pure resistive by connecting to the circuit with a capacitor, in other words, the current is at maximin value, and we use that to know how a capacitor will affect the current and impedance of the circuit by adjusting the frequency of function generator in a series RLC circuit. 
Figure 2. Designed Circuit to Determine C to Obtain Pure Resistive Impedance in Part 2.

Assemble
Figure 3. Build-up Circuit

Figure 4. Build-up Series RLC circuit connected to FG, O-scope, and Multimeters.

Approach
    First, we set up the frequency and RMS value of function generator to 20.0kHz and 5.00 V and the output signal is sinusoid. After we build the circuit as showing above , the Vin,rms and Iin,rms reading are 4.52 V and 88.0mA. The reason why the reading differ from the FG display is due to the FG's internal     
resistance. So, the total impedance of the circuit is 4.52/88mA which equals to 51.36 ohms. Since we know that Z can be written as Z=(Rext+RL)+jwl, and its magnitude is square root[(Rext+RL)^2-(wL)^2]. The angular can be calculated as w=2pi*f = 2 *pi *20k = 125664 rad/s. By substitute all data into square root[(Rext+RL)^2-(wL)^2] = abs(Z), we can get the impedance is 0.4 mH.
Next, we want to figure out at what C value  can cancel the imaginary part of the impedance due to L from previous part of lab. We simply set up XL=XC, and then we can get XC is equal to 50.27. Since XC = 1/wC ==> C= 1/(2*pi*20k*50.27) = 1.58*10^-7 F. However, we get only reach 0.151 uF of capacitance, so we redo the math to calculate the frequency that will cancel the imaginary part of the impedance which is our goal. f = 1/(2*pi*50.27*.151u) = 20.97 kHz.

Data
We take scope measurement at 20.97 kHz.
Vp-p,ch1 = 23.08 V
Vp-p,ch2 = 19.49 V
delta t = 19.46 us
The phase difference = delta t * f *360 degree = 19.46 u* 20.97k * 360 degree = 146 degrees
Recorded the DMM measurements by adjusting the frequency of FG

Table 1. Recorded data of voltage, current and computed Z in Part 2.
Follow-Up Questions
  • Why is the input current the largest at 20.97 kHz?

At 20.97 kHz, the imaginary part of Z will be cancel, so Z value is at the minimum. Also, by Ohm's Law, I = V/Z. When Z is minimum, I will be maximum.

  • Calculate the theoretical voltage phasor across the real inductor at 20.97 kHz. Compare this with the scope measurements by converting those into RMS. 

Theoretical Value (volts):

Experimental Value (volts):
% error:
  • The circuit looks more capacitive at frequencies below 20.97 kHz; the circuit looks more inductive at frequencies above 20.97 kHz.











AC Signal #1

Purpose
    The purpose of this lab is to explore the phase difference between AC sine signals at the same frequency in a simple RC circuit; besides, by adjust the frequency of the signal and resistance in the circuit, the phases will be different. Also, we can learn how to read the value of current or voltage on the scope display.


Knowledge
    If we can find that the amplitude of voltage is 6 divisions in 2V/Div scale from the scope, we can know the reading of voltage is 12V. Assumed that 6 divisions of horizontal time base set to 10 us/div, and we can find the period is 60 micro sec, and frequency is 1/T.  Between two peaks of two different channel of the signals, the phase difference between them would be t*f*360 degrees. If one peak of Ch1 is before Ch2, we call Ch1 signal is leading Ch2 signal.

Circuit
Figure 1. The Desired Circuit
Figure 2. Build-up Circuit connected to O-scope and Multimeter

Set-up
    First, We want to know the phase difference between CH1 and CH2, so we set the FG to produce 1 V peak-peak sine wave at 1k Hz. The RMS value for DMM is 0.318 V. The complex impedance of the 100 nF capacitor can be calculated as 1/(2*pi*C) = 1592 ohms. Next, we connect CH1 to FG and CH2 to the top of capacitor, and then Resistor box and C connected as shown above. After we assemble our circuit, we start measure our data.

Results
Part A
  • peak-peak of CH2 = 0.852 V
  • Vrms CH2 = 0.23 V
  • tx =105.41 micro sec.
  • Phi = tx * f * 360 = 37.9 degrees
==>CH1 is leading CH2 by 37.9 degrees

Part B
Next we adjust the frequency of input signal to 10 kHz rather than 1k Hz. 
  • V peak-peak CH2=0.154V
  • Vrms = 0.033 V
  • tx=23.78 micro sec
  • Phi = tx * f * 360 = 85.6 degrees
Part C
In order to see the impact of resistance, we adjust the resistor box to 10 Kohms, and we take the measurements.
  • V peak-peak CH2 = 0.178 V
  • Vrms = 0.049 V
  • tx = 221.62 micro sec
  • Phi = tx * f * 360 = 79.8 degrees
Figure 3. Time Difference between the Peaks of two Waveforms


Compare experimental phase difference to the theoretical value
Figure 4. Phase Relationship of VR and Vc in RC Circuit
Phi = arctan(VR/Vc)
      = arctan(R/Xc)
      = arctan(2*pi*f*R*C)

In Part A, the theoretical value is arctan(2*pi*1k*1k*102.6*10^-9) = 32.8 degrees
% error = (37.9-32.8)/32.8*100% = 15.5 %

In Part B, the theoretical value is arctan(2*pi*10k*1k*102.6*10^-9) = 81.2 degrees
% error = (85.6-81.2)/81.2*100% = 5.42 %

In Part C, the theoretical value is arctan(2*pi*10k*1k*102.6*10^-9) = 81.2 degrees
% error = (79.8-81.2)/81.2*100% = 1.72 %

Conclusion
    At low frequency range the capacitor voltage amplitude is the greatest; at high frequency range the capacitor voltage amplitude is the smallest. We also know that at very high frequency, the phase difference of two signals tend to be 90 degrees. So, we can treat this circuit as a lowpass filter. 








First-Order OP AMP Circuit(Integrator)

Purpose
    The purpose of this lab is to explore the OP Amp integrator, and make sketches of output waveforms for 1kHz sine wave, triangle wave, and square wave inputs.

Analysis    
    To illustrate how these circuits perform integration, consider the circuit in Figure 1.  


Figure 1. A Practical Integrator.


Since we can treat the voltages at the op amp inputs are equal and practically zero. Plus, the currents going into the op amp inputs are ideally zero, then the current through R1 is equal to the sum of the currents through C and Rf. From Figure 1, making Rf>>R1 will make the R1 current practically the same as the C current, ic.  The current through R1 is Vin/R1, so ic is very close to Vin/R1 if Rf>>R1.
By KCL,
Vin/R1 = ic + (0-Vout)/Rf (this term can be ignored since Rf is greater than R1 by a factor of 100 times)
==>Vin/R1 = -C*(dVout)/dt
==>Vout = -1/C * integral (Vin/R1*dt) + Vinitial


Assemble
Figure 2. Build-up Circuit on Breadboard

Figure 3. Build-up Circuit connected to MAC


Results
  • Sine wave input

Figure 4. Output Obtained from Sine Wave Input

  • Triangle wave input
Figure 5. Output Obtained from Triangle Wave Input

  • Square wave input
Figure 6. Output Obtained from Square Wave Input

Questions
    What is that 10M resistor (Rf) for? What happened when it is removed?
If a small DC component was present in the input waveforms, the capacitor (C) offers infinite resistance and so the integrator circuit will be like an inverting opamp amplifier with infinite feedback resistance (Rf = ∞). The equation for the voltage gain (A) of an  opamp amplifier in inverting mode is  A = -(Rf/R1). Substituting Rf=∞ in the present scenario we get A=∞. Therefore the small input offset voltage will get amplified by this factor and there will be an error voltage at the output. In addition, Vinitial would be affected by a small DC component of input. Adding a feedback Rf in parallel with the capacitor will fix the low frequency gain (A) of the circuit to a fixed small value and so the input offset voltage will have practically no effect on the output offset voltage and variations in the output voltage is prevented. The gain goes from negative infinity to some finite value -Rf/R1.

Friday, April 27, 2012

Capacitor Charging/Discharging

Purpose
The purpose of this lab is to understand the concept of RC charging and discharging circuit and then see how a real capacitor works in the circuit.

Background
In the RC charging circuit, the voltage and current across capacitor can be express as V(t)=Vs(1-e^(-t/tau)) and I(t)=Vs/R*e^(-t/tau), where tau is time constant which is Rcharge*C. In addition, in the discharging circuit the voltage and current across the capacitor are V(t)=Vic*e^(-t/taud) and I(t)=-Vic/Rdiscahrge*e^(-t/taud), where taud is time constant in discharging circuit. However, in real capacitor model the capacitor connected to resistor Rleak in parallel, so we must apply Thevenin's theorem to find out the real value of resistance.

Problem
We use a 9V power supply to employ a charging interval of about 20 s with a result stored energy of 2.5mJ, and then discharges that 2.5mJ in 2s.

Approach
So, the value of capacitance can be determined by applying w=0.5*cV^2, which is 61.7 uF. For R(charging), we can use 5 R(charging)*C=20, so R(charging)=64.8k ohms. From the values above, we can determine peak current and power in the charging circuit which are 0.139 mA and 1.25mW. For discharging circuit, 5 tau = 2, so R(discharging)=6.48k ohms. The peak discharge current and power are 1.39 mA and 12.5mW respectively.

Assemble
R(charging) = 65k ohms
R(discharging) = 6.47k ohms
C=63.6 uF
All values above are measured.
Figure1. Build-up Circuit on Breadboard
Figure 2. Build-up Circuit Connected Logger Pro and MAC

Graphs
  • Charing

Figure 3. Vc v.s Time When Charging

  • Discharging

Figure 3. Vc v.s Time When Discharging


Data Analysis
Vs = 9.01 V
Vfinal = 8.562 V = Vs*Rleak/(Rleak+65k), so R(leak)=1.24 Mohms
The Thevenin equivalent voltage and resistance seen by the capacitor during charging are
Vth=9.01*1.24M/(1.24M+65k)=8.55V and Rth=1.24M and 65k in parallel which is 61.8k ohms, and the Thevenin equivalent voltage and resistance seen by the capacitor during discharging are
Vth=9.01*1.24M/(1.24M+65k)=8.55V and Rth=1.24M and 6.47k in parallel which is 6.44k ohms 

Op Amp Application

Purpose
   The purpose of this lab is to use a scaling and level-shifting op-amp circuit which is LM741to process the output signal from an electronic temperature sensor so that the output can show reading in degrees Fahrenheit converting from Centigrade reading.

Background
   The temperature sensor we have used is AS35 which produces an output voltage that is proportional to the air temperature based on a scale factor of 10mV/degree C. Also, AS35 requires an 4 to 20V to operate.

Pin Connection
Figure 1. Front View of AS35
Figure 2. Top View of AS35


Design
   The converting formula between Centigrade and Fahrenheit readings is TF = 1.8TC + 32. So, we can use a single 741 op-amp to scale and shift a signal. our design is shown as following,
Figure  3. Designed Circuit

By assuming the op amp is ideal, so V+ = V-= Vc. Using nodal analysis on the node which is just above R1, we can write (Vc-Vref)/R1 = -(Vc-Vf)/R2 
==> Vf/R2 = (Vc/R2+Vc/R1)-Vref/R1 
==> Vf = R2*(Vc/R2+Vc/R1)-R2/R1*Vref
==> Vf = (1+R2/R1)Vc-R2/R1*Vref. Comparing the equation to TF = 1.8TC + 32, we can get (1+R2/R1)=1.8 and 0.8*Vref = 0.32, which means Vref = 0.4V; however, Vref has to be negative if the overall shift is to be positive. The design also has constraint which the output current from the op-amp is much less than the maximum allowable output current specified in the data sheet which is 25 mA for LM741.

Assemble
R1=0.999 M ohms
R2=0.812 M ohms (both readings from multimeter), so that the ratio of R2/R1=0.813 which is close to the ideal value, 0.80. Two power supplies, one used as positive 9V and the other used as negative 9V, must connect to AS35 and LM 741 properly. In addition, we use a variable power supply to provide 0.4V as Vref instead of using a power supply and two resistors as a voltage divider. 
Figure 4. Build-up Circuit Connected to Multimeter and Power Supply

Figure 5. The Build-up Circuit

Data Analysis
Vc=0.228V
Vf=0.711V(readings from multimeter)
Theoretical Value of Tf = (1.8*0.228+0.32)*100=73.04 degree Fahrenheit
% error = (73.04-71.1)/73.04*100% = 2.66%