We looked at problems/simulations on the Pearson physics website for section 20.2 LINKAGE
Answers to the questions:
1. λ=2*L
2. λ=h/p = h/(2L)
3. E=p^2/(2m) = h^2/(8m*L)
4. it will decrease
5. ground state ->0 & spacing goes to 0
6. Ground state energy and spacing is 0
7. the center of the box
8. It doesn't, it depends on L
9. Yes, probability of detection stays highest at the center
10. As n gets larger, regions of probability blur together.
Thursday, December 15, 2011
Planck's constant from an LED
In this lab, we can use the principles on which an led operates to experimentally determine planck's constant.
We know the following relationships:
λ=h/mv
E=hf=hc/λ
We used 4 different color LEDs: Red, yellow, green, and blue. We ran the experiment the same exact way as the hydrogen and color spectra lab.
Using the fact that E=hc/λ=q*V, we get that h = q*V*λ/c
From these results, only blue seems to give a value that was within scientifically acceptable bounds of the theoretical value at 1.12% error. Red also came in at a relatively low error of 5.98%. Both Yellow and Green had relatively high error. Coincidentally, their spectra also contained various colors which made it hard to pinpoint the maxima that corresponded to the color of the LED itself. This is likely due to the fact that the green LED had impurities and was contained additional wavelengths. The particular shade of yellow also had an orange tinge to it. Overall, it appears that the colors on the ends of the visible spectrum were much easier to identify.
We know the following relationships:
λ=h/mv
E=hf=hc/λ
We used 4 different color LEDs: Red, yellow, green, and blue. We ran the experiment the same exact way as the hydrogen and color spectra lab.
Color | Distance D (meters) | Voltage (Volts) | Wavelength (nm) | |
Yellow | 0.67 | 1.88 | 592.43 | |
Green | 0.59 | 2.52 | 529.04 | |
Red | 0.735 | 1.82 | 641.93 | |
Blue | 0.525 | 2.64 | 475.63 |
Using the fact that E=hc/λ=q*V, we get that h = q*V*λ/c
Color | Wavelength (nm) | Voltage (Volts) | h |
Yellow | 592.43 | 1.88 | 5.94E-34 |
Green | 529.04 | 2.52 | 7.11E-34 |
Red | 641.93 | 1.82 | 6.23E-34 |
Blue | 475.63 | 2.64 | 6.70E-34 |
From these results, only blue seems to give a value that was within scientifically acceptable bounds of the theoretical value at 1.12% error. Red also came in at a relatively low error of 5.98%. Both Yellow and Green had relatively high error. Coincidentally, their spectra also contained various colors which made it hard to pinpoint the maxima that corresponded to the color of the LED itself. This is likely due to the fact that the green LED had impurities and was contained additional wavelengths. The particular shade of yellow also had an orange tinge to it. Overall, it appears that the colors on the ends of the visible spectrum were much easier to identify.
Color and hydrogen spectrum
This lab uses a diffraction grating to analyze wavelengths of light from a specific light source.
Our setup was as shown.
We placed a light source at the origin of the 2 rulers, placed a diffraction grating at a distance from the bulb, and looked through it and measured the range of wavelengths.We use the following formula:
where λ is the wavelength, d is the slit spacing on the diffraction grating, D is the observed horizontal distance from the light source to the band of light, L is the distance from the diffraction grating to the light.
We took readings at 2 distances to minimize error.
We were then given a gas discharge tube, and our job was to determine what type of gas was in the tube based on the spectral lines we observe.
We compared the spectral bands with a chart of different gasses' spectral lines, and they corresponded almost perfectly with mercury.
We plot the measured values against the theoretical values to get a correction value of 75 nm.
We were then given a hydrogen discharge tube, and measured the spectral lines of hydrogen.
The different spectral lines indicate the different energy levels that the hydrogen can transition between. For each of these transitions, the hydrogen emits a photon corresponding to a specific wavelength. This method can be used to analyze an unknown gas and determine it's composition based on the energy levels.
Our setup was as shown.
We placed a light source at the origin of the 2 rulers, placed a diffraction grating at a distance from the bulb, and looked through it and measured the range of wavelengths.We use the following formula:
where λ is the wavelength, d is the slit spacing on the diffraction grating, D is the observed horizontal distance from the light source to the band of light, L is the distance from the diffraction grating to the light.
We took readings at 2 distances to minimize error.
L (m) | Red(D) | Violet (D) |
---|---|---|
1.5 | 0.65 | 0.3 |
1.8 | 0.745 | 0.35 |
We were then given a gas discharge tube, and our job was to determine what type of gas was in the tube based on the spectral lines we observe.
We compared the spectral bands with a chart of different gasses' spectral lines, and they corresponded almost perfectly with mercury.
color | D (m) | Measured λ | Theoretical λ |
---|---|---|---|
Red | 0.75 | 690 | 690 |
Yellow | 0.61 | 589 | 580 |
Green | 0.54 | 535 | 545 |
Violet | 0.42 | 439 | 435 |
We plot the measured values against the theoretical values to get a correction value of 75 nm.
We were then given a hydrogen discharge tube, and measured the spectral lines of hydrogen.
|
The different spectral lines indicate the different energy levels that the hydrogen can transition between. For each of these transitions, the hydrogen emits a photon corresponding to a specific wavelength. This method can be used to analyze an unknown gas and determine it's composition based on the energy levels.
Thursday, November 24, 2011
Visualizing Wave packets
This time we used python to help visualize wave packets, and better understand the wave function.
We used a python module called pylab to graph functions.
For my program, you can select the number of harmonics and the value for sigma, and compare different arrangements at once.
The plot shows the sum of harmonics of a wave function, with each increasing harmonic having a decreasing amplitude that varies as a gaussian function, with a specific sigma value. The blue plot has a sigma value of 1, the green plot has a sigma of 5 and the red plot has a sigma of 10. This shows that by using the right amplitudes and numbers of harmonics, the superposition of waves can model a wave packet.
We can then use this to answer some questions
a. The graph is a straight line
b.
c. 1*L
d. 2*L
e.
f. 6.63e-34 = h
g. 6.63e-34 = h
We used a python module called pylab to graph functions.
For my program, you can select the number of harmonics and the value for sigma, and compare different arrangements at once.
from pylab import * harmonics,sigma = zeros(5),zeros(5) #### Variables ##### harmonics[1] = 97 sigma[1] = 1 ### harmonics[2] = 97 sigma[2] = 5 ### harmonics[3] = 97 sigma[3] = 10 ### rng = 3.14 #range of x values to plot (-rng to +rng) ############# def gauss(number,sigma): """harmonics, sigma""" gauss_list = [] #empty array coeff = 1/(sqrt(2*pi)*sigma) for x in range(0,number): funcval = coeff * exp(-(float(x) -float(number-1)/2 )**2/(2 * sigma**2)) gauss_list.append(funcval) print gauss_list return gauss_list def sinplot(start, stop, A, harms): """start, stop, amplitude, harmonics""" loop = int() superpos = [] for n in arange( start, stop, 0.01 ): #Create list of zeros superpos.append(0) for i in range( 0, len(harms) ): plot_list = [] domain = [] loop = 0 for x in arange( start, stop, 0.01 ): funcval = A[i] * sin( harms[i] * x ) plot_list.append( funcval ) domain.append(x) superpos[loop] = superpos[loop] + funcval #sum of funciton values loop += 1 #plot( domain, plot_list) #show each harmonic plot( domain, superpos ) #sinamp = gauss(harmonics, sigma) #print sinamp #harmonic = range(1,harmonics+1) try: for i in (1,2,3,4,5): sinplot(-rng, rng, gauss( harmonics[i],sigma[i] ), range( 1,harmonics[i]+1 ) ) except: print("Graphing...") show()The program generates this
The plot shows the sum of harmonics of a wave function, with each increasing harmonic having a decreasing amplitude that varies as a gaussian function, with a specific sigma value. The blue plot has a sigma value of 1, the green plot has a sigma of 5 and the red plot has a sigma of 10. This shows that by using the right amplitudes and numbers of harmonics, the superposition of waves can model a wave packet.
We can then use this to answer some questions
a. The graph is a straight line
b.
c. 1*L
d. 2*L
e.
f. 6.63e-34 = h
g. 6.63e-34 = h
Modern physics: Relativity of Time
In this lab, we looked at some Modern Physics simulations and answered questions about them related to relativity of time in relation to distance and velocity.
Ans: The distance traveled is greater on the moving light clock than on the stationary clock
Question 2: Time interval required for light pulse travel, as measured on the earth
Given that the speed of the light pulse is independent of the speed of the light clock, how does the time interval for the light pulse to travel to the top mirror and back on the moving light clock compare to on the stationary light clock?
Ans: The time for the moving clock is greater than for the stationary clock
Question 3: Time interval required for light pulse travel, as measured on the light clock
Imagine yourself riding on the light clock. In your frame of reference, does the light pulse travel a larger distance when the clock is moving, and hence require a larger time interval to complete a single round trip?
Ans: No, from your frame, the distance is still 2x the distance between mirrors so it takes the same time.
Question 4: The effect of velocity on time dilation
Will the difference in light pulse travel time between the earth's timers and the light clock's timers increase, decrease, or stay the same as the velocity of the light clock is decreased?
Ans: The difference will become smaller as the velocity of the light clock decreases
The relationship between the time interval measured by an observer and the proper time interval is:
Δt = γΔtproper
where γ is related to the relative velocity between the observer and the clock measuring the proper time interval via
γ = (1 - v2 / c2)-1/2
Question 5: The time dilation formula
Using the time dilation formula, predict how long it will take for the light pulse to travel back and forth between mirrors, as measured by an earth-bound observer, when the light clock has a Lorentz factor (γ) of 1.2.
Ans: This is simply γ*Δt_proper = 1.2*(6.67μs) = 8μs
Question 6: The time dilation formula, one more time
If the time interval between departure and return of the light pulse is measured to be 7.45 µs by an earth-bound observer, what is the Lorentz factor of the light clock as it moves relative to the earth?
Ans: γ = Δt/Δt_proper -> 7.45/6.67 = 1.12
Question 1: Distance traveled by the light pulse
How does the distance traveled by the light pulse on the moving light clock compare to the distance traveled by the light pulse on the stationary light clock?Ans: The distance traveled is greater on the moving light clock than on the stationary clock
Question 2: Time interval required for light pulse travel, as measured on the earth
Given that the speed of the light pulse is independent of the speed of the light clock, how does the time interval for the light pulse to travel to the top mirror and back on the moving light clock compare to on the stationary light clock?
Ans: The time for the moving clock is greater than for the stationary clock
Question 3: Time interval required for light pulse travel, as measured on the light clock
Imagine yourself riding on the light clock. In your frame of reference, does the light pulse travel a larger distance when the clock is moving, and hence require a larger time interval to complete a single round trip?
Ans: No, from your frame, the distance is still 2x the distance between mirrors so it takes the same time.
Question 4: The effect of velocity on time dilation
Will the difference in light pulse travel time between the earth's timers and the light clock's timers increase, decrease, or stay the same as the velocity of the light clock is decreased?
Ans: The difference will become smaller as the velocity of the light clock decreases
The relationship between the time interval measured by an observer and the proper time interval is:
Δt = γΔtproper
where γ is related to the relative velocity between the observer and the clock measuring the proper time interval via
γ = (1 - v2 / c2)-1/2
Question 5: The time dilation formula
Using the time dilation formula, predict how long it will take for the light pulse to travel back and forth between mirrors, as measured by an earth-bound observer, when the light clock has a Lorentz factor (γ) of 1.2.
Ans: This is simply γ*Δt_proper = 1.2*(6.67μs) = 8μs
Question 6: The time dilation formula, one more time
If the time interval between departure and return of the light pulse is measured to be 7.45 µs by an earth-bound observer, what is the Lorentz factor of the light clock as it moves relative to the earth?
Ans: γ = Δt/Δt_proper -> 7.45/6.67 = 1.12
CD diffraction
In this lab we measured the width of the grooves in a CD by using the principles we know about laser diffraction
The distance between these groves is far too small for a the human eye to measure. With diffraction however, we can measure the distance between observed maxima on the diffraction pattern resulting from a laser (λ = 670 nm) reflected off of a CD. The grooves in a cd act as a reflection diffraction grating, so the distance from the center to the m'th maximum can be found as sin(θ) = mλ/d where d is the groove spacing.
Our data was as follows:
After plugging in all the numbers, we got an average d of 2.7*10^-5 meters
We had a very large error which probably due to the fact that our laser might not have been perfectly incident on the diffraction grating (ie, flat spot on the cd), and we are getting thin film interference from the plastic disk.
The distance between these groves is far too small for a the human eye to measure. With diffraction however, we can measure the distance between observed maxima on the diffraction pattern resulting from a laser (λ = 670 nm) reflected off of a CD. The grooves in a cd act as a reflection diffraction grating, so the distance from the center to the m'th maximum can be found as sin(θ) = mλ/d where d is the groove spacing.
Our data was as follows:
After plugging in all the numbers, we got an average d of 2.7*10^-5 meters
We had a very large error which probably due to the fact that our laser might not have been perfectly incident on the diffraction grating (ie, flat spot on the cd), and we are getting thin film interference from the plastic disk.
Monday, October 10, 2011
Measuring a human hair
Today we measured the thickness of a human hair by diffraction of light.
For a double slit diffraction of a light beam, light and dark interference spots are created on a surface some distance L from the slots.
If the slots are separated by a distance d, the distance from the center bright spot and bright spot #m is y = λL*m/d
We treat the human hair as the separation between openings and if we shine a laser at the hair, we get a corresponding diffraction pattern on a distant surface.
We placed a whiteboard 1 meter away from the hair, to simplify calculations. our λ was 680nm for a red laser. We measured the distance between the center and the 4th bright spot and got y=4.8 cm
Rearranging and plugging in we got d = 680e-9*1m*4/.048 = 5.67e-5m = 56.7 μm
My hair is on the very lower border of human hair thickness according to google. Makes you think I have alopecia or something haha
For a double slit diffraction of a light beam, light and dark interference spots are created on a surface some distance L from the slots.
If the slots are separated by a distance d, the distance from the center bright spot and bright spot #m is y = λL*m/d
We treat the human hair as the separation between openings and if we shine a laser at the hair, we get a corresponding diffraction pattern on a distant surface.
We placed a whiteboard 1 meter away from the hair, to simplify calculations. our λ was 680nm for a red laser. We measured the distance between the center and the 4th bright spot and got y=4.8 cm
Rearranging and plugging in we got d = 680e-9*1m*4/.048 = 5.67e-5m = 56.7 μm
My hair is on the very lower border of human hair thickness according to google. Makes you think I have alopecia or something haha
Sunday, October 9, 2011
Lenses Lab
In this lab, we looked at the behavior of light through a magnifying glass which is a double convex lens.
We used a light box which illuminated a pattern on a piece of paper, and placed the magnifying glass at specific distances away from the light box, and had a blank sheet on which to project the image.
Before we could do anything, however, we needed to measure the focal length of our lens. To do this, we went outside and focused the light from the sun onto the ground until the light entering the lens was focused at a single point. The focal length was simply the height above the ground.
The focal length of our magnifying glass was found to be f = 14 cm +/- 0.5 cm
After that, we placed the light box at various distances (object distance) from the lens, and found the image distance (where the projection on the sheet was most clear) and measured the image height on the sheet. The object height is constant and is simply the height of the printed pattern on the paper on the light source.
We then tried to get an image when the light box was only 0.5*f away from the lens. We were unable to get a image to show up on the sheet at any distance. However, we are able to see a very clear virtual image by looking through the lens from any point.
We used a light box which illuminated a pattern on a piece of paper, and placed the magnifying glass at specific distances away from the light box, and had a blank sheet on which to project the image.
Before we could do anything, however, we needed to measure the focal length of our lens. To do this, we went outside and focused the light from the sun onto the ground until the light entering the lens was focused at a single point. The focal length was simply the height above the ground.
The focal length of our magnifying glass was found to be f = 14 cm +/- 0.5 cm
After that, we placed the light box at various distances (object distance) from the lens, and found the image distance (where the projection on the sheet was most clear) and measured the image height on the sheet. The object height is constant and is simply the height of the printed pattern on the paper on the light source.
Object distance (cm) | Image Distance (cm) | Image Height (cm) | Object height (cm) | Magnification |
---|---|---|---|---|
5*f = 70 | 22.5 | 1 | 3 cm | 1/3 |
4*f = 56 | 24 | 1.5 | 1/2 | |
3*f = 42 | 28 | 2 | 2/3 | |
2*f = 28 | 43 | 4.8 | 1.6 | |
1.5*f = 21 | 85 | 12.5 | 4.2 |
We then tried to get an image when the light box was only 0.5*f away from the lens. We were unable to get a image to show up on the sheet at any distance. However, we are able to see a very clear virtual image by looking through the lens from any point.
Concave and convex mirrors
In this lab, we looked at reflected images in concave and convex mirrors.
In a convex mirror, (curved outward) objects appear smaller than normal and warped. This stays the same regardless of where the object is in relation to the mirror.
In a concave mirror, however, interesting things happen. Close to the mirror, objects look much bigger than normal. This happens at distances closer than the focal length of the mirror. When the object is moved farther away, the image inverts and appears to shrink.
After observing the concave and convex mirrors, we constructed ray diagrams and calculated magnification.
From the ray diagrams, we measured the object and the image height in order to calculate magnification, which is M = obj height / img height.
For the convex mirror, the theoretical magnification was 1.25/.25 = 5
For the concave mirror, it was negative 5 because the image is upside-down. (the rays don't intersect properly because the focal point isn't placed quite right)
In a convex mirror, (curved outward) objects appear smaller than normal and warped. This stays the same regardless of where the object is in relation to the mirror.
In a concave mirror, however, interesting things happen. Close to the mirror, objects look much bigger than normal. This happens at distances closer than the focal length of the mirror. When the object is moved farther away, the image inverts and appears to shrink.
After observing the concave and convex mirrors, we constructed ray diagrams and calculated magnification.
From the ray diagrams, we measured the object and the image height in order to calculate magnification, which is M = obj height / img height.
For the convex mirror, the theoretical magnification was 1.25/.25 = 5
For the concave mirror, it was negative 5 because the image is upside-down. (the rays don't intersect properly because the focal point isn't placed quite right)
Wednesday, September 28, 2011
Reflection and Refraction
In this experiment, we begin looking at light waves and how they refract. We had a light box with a narrow slot to let a thin ray of light out, a protractor, and a semicircular clear plastic disk.
For the first set of data, we had the light entering the flat side of the disk, and exiting the curved side. We recorded the angles of incident and refraction as theta 1 and 2 respectively.
When we plotted the SINE of the angles against each other, we got a nearly perfectly linear trendline.
For our second data set, the incident ray entered on the curved side and exited on the flat side of the half-disk. At 45 degrees for the incident angle, no light exited the plastic disk.
When the sin of these two angles were plotted against each other, the graph was exactly the same, except the axes were reversed.
The slope of theses lines must represent the ratio for the index of refraction of the materials. Since the index n for air is 1 we could easily figure out the refraction index for the plastic.
For the first set of data, we had the light entering the flat side of the disk, and exiting the curved side. We recorded the angles of incident and refraction as theta 1 and 2 respectively.
Trial | ϴ_1 | ϴ_2 | sin(ϴ_1) | sin(ϴ_2) |
1 | 5 | 4 | 0.087156 | 0.069756 |
2 | 10 | 7 | 0.173648 | 0.121869 |
3 | 15 | 10 | 0.258819 | 0.173648 |
4 | 20 | 12.5 | 0.34202 | 0.21644 |
5 | 25 | 16 | 0.422618 | 0.275637 |
6 | 30 | 19 | 0.5 | 0.325568 |
7 | 40 | 26.5 | 0.642788 | 0.446198 |
8 | 50 | 31 | 0.766044 | 0.515038 |
9 | 60 | 35 | 0.866025 | 0.573576 |
10 | 70 | 39 | 0.939693 | 0.62932 |
When we plotted the SINE of the angles against each other, we got a nearly perfectly linear trendline.
For our second data set, the incident ray entered on the curved side and exited on the flat side of the half-disk. At 45 degrees for the incident angle, no light exited the plastic disk.
Trial | ϴ_1 | ϴ_2 | sin(ϴ_1) | sin(ϴ_2) |
1 | 0 | 0 | 0 | 0 |
2 | 5 | 7.5 | 0.087156 | 0.130526 |
3 | 10 | 16 | 0.173648 | 0.275637 |
4 | 15 | 23 | 0.258819 | 0.390731 |
5 | 20 | 32 | 0.34202 | 0.529919 |
6 | 30 | 48 | 0.5 | 0.743145 |
7 | 35 | 63 | 0.573576 | 0.891007 |
8 | 40 | 75 | 0.642788 | 0.965926 |
9 | 45 | 75 | 0.707107 | 0.965926 |
When the sin of these two angles were plotted against each other, the graph was exactly the same, except the axes were reversed.
The slope of theses lines must represent the ratio for the index of refraction of the materials. Since the index n for air is 1 we could easily figure out the refraction index for the plastic.
Standing Waves on a string
For this lab, our goal was to analyze mechanical waves on a string, specifically standing waves. We were given a frequency generator, a long string, a ruler, some weights, and a mechanical oscillator. This is a picture of our setup. Not visible is the hanging mass, which is over the opposite end of the table.
When a vibrating string produces standing waves, the number of nodes and antinodes that appear depend on the tension in the string, the length of the string, and the frequency of oscillations. By counting the n number of loops, we can easily come up with wavelength because wavelength is simply 2L/n
The velocity of a wave on a string is denoted by v = √(T/µ) where T is the tension in the string and µ is the mass per unit length of the string.
For our first set of data, the oscillating length of string was 133 cm with a hanging mass of 200g. Our velocity was therefore √(200g/1.38g/m) = 12 m/s
For data set 2, we reduced the tension to 100g
When a vibrating string produces standing waves, the number of nodes and antinodes that appear depend on the tension in the string, the length of the string, and the frequency of oscillations. By counting the n number of loops, we can easily come up with wavelength because wavelength is simply 2L/n
The velocity of a wave on a string is denoted by v = √(T/µ) where T is the tension in the string and µ is the mass per unit length of the string.
For our first set of data, the oscillating length of string was 133 cm with a hanging mass of 200g. Our velocity was therefore √(200g/1.38g/m) = 12 m/s
Freq. | Nodes | Wavelen | |
---|---|---|---|
17Hz | 2 | 2.66 m | |
32Hz | 3 | 1.33 m | |
46Hz | 4 | 88.7 cm | |
63Hz | 5 | 66.5 cm | |
76Hz | 6 | 53.2 cm | |
109Hz | 8 | 38 cm |
For data set 2, we reduced the tension to 100g
Freq | Nodes | Wavelen |
---|---|---|
27Hz | 2 | 2.66 m |
48Hz | 3 | 1.33 m |
71Hz | 4 | 88.7 cm |
88Hz | 5 | 66.5 cm |
113Hz | 6 | 53.2 cm |
134Hz | 7 | 38 cm |
Friday, September 23, 2011
Mechanical waves
For this lab, we were supposed to come up with an experiment to relate period to wavelength.
The materials we had to use were a stopwatch, a long spring, and a meter stick.
We decided that we would hold the spring at a specific length, and then start a standing wave on it, and measure the time for 10 cycles and divide by 10 to get the period of oscillations.
By changing the distance between the 2 people holding it, and the number of nodes, we could determine the relationship between period and wavelength.
We got the following results:
8 meters 1.04 sec
4 meters .587 sec
2.66 met. .350 sec
2 meters .262 sec
When we plotted this on a graph, the curve was very linear which makes sense since
T=1/f and f=v/λ so T = λ/v
Here is a video of our method.
The materials we had to use were a stopwatch, a long spring, and a meter stick.
We decided that we would hold the spring at a specific length, and then start a standing wave on it, and measure the time for 10 cycles and divide by 10 to get the period of oscillations.
By changing the distance between the 2 people holding it, and the number of nodes, we could determine the relationship between period and wavelength.
We got the following results:
8 meters 1.04 sec
4 meters .587 sec
2.66 met. .350 sec
2 meters .262 sec
When we plotted this on a graph, the curve was very linear which makes sense since
T=1/f and f=v/λ so T = λ/v
Here is a video of our method.
Wednesday, September 7, 2011
Fluid dynamics lab
Our second lab we did was investigating fluid dynamics using Bernoulli's Equation. Our job was to calculate the amount of time it would take to empty a specific volume of water from a larger bucket with the setup as shown:
Using a stopwatch, we measured how long it took to fill up a 200 mL beaker, and repeated the measurement to calculate error. Numbers are in seconds
1. 3.82
2: 4.75
3: 4.35
4: 4.30
5: 4.38
6: 4.52
Using error calculations, we came up with a average time of 4.35 +/- .31
The height of water in the bucket was 144.5 mm +/- 0.5mm
The area of the drain hole was 3.85e-5 m^2 +/-0.025e-5
Calculating the theoretical time with uncertainty yielded a time of 3.48s +/- .39
Comparing the theoretical with the actual value, we have a difference of 25% which is acceptable considering the amount of error introduced from drain hole inaccuracies, and delay in operating the stopwatch.
Calculating backwards, the actual drain hole diameter is 14% smaller than the measured 7mm hole at 5.99mm
Thursday, February 17, 2011
Wed. Final Week
Today was the day for presentations.
The link for our presentation: WALDO PRESENTATION
And my video of the performance:
After the presentations, we took apart our robots (*sadface*) and inventoried our kits.
The link for our presentation: WALDO PRESENTATION
And my video of the performance:
After the presentations, we took apart our robots (*sadface*) and inventoried our kits.
Tues. final week
--DANGER-- Possible infinite loop--
I'm writing a blog about Mason presenting a presentation on how to give presentations.
Mason outlined the parameters for how to structure the presentations we have to give on wednesday on our can finding robot.
After that, we spent the rest of the evening working on writing them
I'm writing a blog about Mason presenting a presentation on how to give presentations.
Mason outlined the parameters for how to structure the presentations we have to give on wednesday on our can finding robot.
After that, we spent the rest of the evening working on writing them
Saturday, February 12, 2011
Can finding robot code
Here's the final program i used on my can finding robot:
#pragma config(ProgramType, StandaloneWithWiFi) #pragma config(Sensor, in1, colorsense, sensorLineFollower) #pragma config(Sensor, in2, line, sensorLineFollower) #pragma config(Sensor, in3, eleft, sensorRotation) #pragma config(Sensor, in4, eright, sensorRotation) #pragma config(Sensor, in12, sonar, sensorSONAR, int1) #pragma config(Sensor, in13, BLU, sensorTouch) #pragma config(Sensor, in14, GRN, sensorTouch) #pragma config(Sensor, in15, RED, sensorTouch) #pragma config(Sensor, in16, , sensorTouch) #pragma config(Motor, port1, right, tmotorNormal, openLoop, reversed) #pragma config(Motor, port2, left, tmotorNormal, openLoop) #pragma config(Motor, port3, clawleft, tmotorServoStandard, openLoop) #pragma config(Motor, port4, clawright, tmotorServoStandard, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// ////////////////////////////////////////////////////////////////////////////////////// int nearest=50,inch=11.6,linesense_type=0; bool override=false,init1=true; char can_color,ground_color; char target_can_color,target_ground_color; bool foundcan=false,can_seek; /////////////////////////////////////// void clawclose(); void clawopen(); void encoder_clear(); void goforward(int dist, bool length, int power); void goback(int dist, bool length, int power); void turnleft(int amount); void turnright(int amount); void scan(); char colorcheck(); char foundedge(); ////////////////////////////////////////////// ////////////////////////////////////////////// task find_can() { int tries=0; if (init1==true) // Probably un-needed { can_seek=true; init1=false; } while(can_seek==true) { if(foundcan == false) { if(nearest > 8) //If the nearest obstacle is more than 8 inches away { scan(); //////////// ///// //Go forward the distance of the nearest object goforward(((nearest)*inch-100),true,50); wait1Msec(1000); tries++; } else if(nearest <=8) //If it detects an object within 8 inches { goforward((nearest*inch+30),true,50); //Go to the object and grab clawclose(); foundcan = true; //Set global variable to indicate a can is found wait1Msec(1000); } if(tries>=6) //If it's tried to find the can 6 times and failed { turnleft(120); //Try looking somewhere else tries=0; } } else if(foundcan==true) //If a can is found { clawopen(); wait1Msec(250); //Get into position to check color goback(3,true,30); //(These numbers need to be tweaked depending on ambient light) motor[port8] = 30; //Point the color sensor at the can wait1Msec(500); can_color = colorcheck(); //Check the color goforward(10,true,50); //Go grab it again clawclose(); wait1Msec(250); //What to do with the object now? if(can_color == target_can_color) //If it's the right color { motor[port8]=-35; //Point color sensor at the ground wait1Msec(500); linesense_type=1; //Change the line detection mode can_seek=false; //Stop looking for a can tries=0; wait1Msec(50); } else //Otherwise { clawopen(); //Release the can wait1Msec(1000); // FLING THE CAN AWAY >:D // motor[left]=-100; wait1Msec(250); motor[clawright]=-10; turnright(20); goforward(100,true,70); turnleft(20); ////////////////// nearest = 50; foundcan = false; // Start searching again tries = 0; wait1Msec(50); } } } while(can_seek==false) //When looking for the target zone { goforward(0,false,80); //Just go forward } } //////////////////////////////////////////////// ////////// LINE DETECTION "THREAD" ///////////// //////////////////////////////////////////////// task line_detect() { char edge; while(linesense_type==0) //Mode when looking for a can { if (SensorValue[line] > 750) //The lower bound for dark line { override = true; StopTask(find_can); // Halt all current activity edge = foundedge(); // Run the edge checking function if(edge == 'R') // If it reports the line to be on the right { turnleft(100); // Turn left } if(edge=='L') // If it reports the line to be on the left { turnright(100); // Turn right } override = false; goback(5,true,50); // Back up a bit StartTask(find_can); //Resume searching } } /////////////////////////////// while(linesense_type==1) //Mode after a can has been found { if (SensorValue[line] > 700) { override = true; StopTask(find_can); wait1Msec(40); goback(1,true,50); //BRAKE motor[port8]=-35; // Make sure the color sensor is looking at the ground. (redundant) wait1Msec(200); ground_color = colorcheck(); //Check the ground color if((ground_color==target_ground_color) && (SensorValue[line]<600)) //If the ground is the target color, and not a floor tile { clawopen(); //Let it go wait1Msec(500); goback(100,true,80); motor[left]=-120; motor[right]=120; /// Spin for joy!! wait1Msec(1000); StopAllTasks(); //Shut down } else if((ground_color != target_ground_color) || (SensorValue[line]>700)) { // If it's not the target color, or it's a floor tile goback(325,true,120); wait1Msec(250); //Go way back turnleft(120); wait1Msec(200); //Turn left and try a different direction goforward(0,false,50); wait1Msec(1000); StartTask(find_can); } } } } task main() // EXECUTED AUTOMATICALLY BY THE VEX BRAIN { goforward(100,true,60); //Enter the arena StartTask(line_detect); //OTHER TASKS MUST BE INITIALIZED StartTask(find_can); while(true) //UNLESS MAIN TASK IN MAINTAINED, EVERYTHING ELSE STOPS { /*SensorValue[RED/GRN/BLU] are simple jumper ports that read '1' when a jumper is plugged in */ if(SensorValue[RED]==1) //Jumper settings for different colors { target_can_color = 'R'; target_ground_color = 'R'; } else if(SensorValue[GRN]==1) { target_can_color = 'G'; target_ground_color = 'G'; } else if(SensorValue[BLU]==1) { target_can_color = 'B'; target_ground_color = 'B'; } else {StopAllTasks();} wait1Msec(1000); } } ////////////////////////////////////////////////// //////// MAIN ADVANCED FUNCTIONS /////////////// ////////////////////////////////////////////////// void scan() { short range = 30; //Minimum Sonar range. Any less, the bot grabs the can short delay = 30; //mS delay for increments short increment = 2; //amount for each increment clawopen(); wait1Msec(500); if(override==false) { int oldval=50,newval=50; //intialize the values high for safety /// Pivot left ///////////////////// for(int i=0; i<35; i++) { if ((SensorValue[sonar] < range) && (SensorValue[sonar]>0)) //Sensor sometimes returns -1 { oldval = SensorValue[sonar]-5; //Set goto END; //Stop searching } turnleft(increment); //Turn left a bit newval = SensorValue[sonar]; //Read sonar value into newval if((newval<oldval) && (newval > 0)) //if the value is any closer than the previous {oldval = newval;} //Store the value into oldval wait1Msec(delay); //Pause } wait1Msec(100); //Waiting before turning the other direction prevents skidding ////////// Repeat the same procedure for the other directions //// Return to center //////////////////// for(int i=0; i<40; i++) { if ((SensorValue[sonar] < range) && (SensorValue[sonar]>0)) { oldval = SensorValue[sonar]-5; turnright(5); //Correction to center the sensor goto END; } turnright(increment); newval = SensorValue[sonar]; if((newval<oldval) && (newval > 0)) //if the value is any closer than before {oldval = newval;} //update wait1Msec(delay); } /// Continue to pivot right ///////////// for(int i=0; i<40; i++) { if ((SensorValue[sonar] < range) && (SensorValue[sonar]>0)) { oldval = SensorValue[sonar]-5; turnright(5); //Correction goto END; } turnright(increment); newval = SensorValue[sonar]; if((newval<oldval) && (newval > 0)) //if the value is any closer than before {oldval = newval;} //update wait1Msec(delay); } wait1Msec(100); /// Return to center heading /////////////// for(int i=0; i<40; i++) { if ((SensorValue[sonar] < range) && (SensorValue[sonar]>0)) { oldval = SensorValue[sonar]-5; goto END; } turnleft(increment); newval = SensorValue[sonar]; //read sonar value into newval if((newval<oldval) & (newval > 0)) //if the value is any closer than before {oldval = newval;} //update wait1Msec(delay); } //Set the variable "nearest" to be the smallest value found by sonar END: nearest = oldval; ///// ***nearest is global*** } } ////////////////////////////////////// ///////// Edge avoidance ///////////// ////////////////////////////////////// char foundedge() { long leftval=0,rightval=0; int howfar=0; goback(25,true,60); //First action when encountering edge, back up turnleft(30); //Then turn left encoder_clear(); //reset encoders for(int i=0; i<35; i++) /////Check line stuff to the left { goforward(0,false,40); //goes forward a bit howfar=SensorValue[eleft]; //records the distance leftval += SensorValue[line]; //Each iteration, store the line sensor value incrementally wait1Msec(10); } goback(howfar,true,40); //Back up the amount traveled howfar=0; turnright(60); //Position to check line stuff to the right encoder_clear(); //reset encoders for(int i=0; i<35; i++) { goforward(0,false,40); ///REPEAT howfar=SensorValue[eleft]; rightval += SensorValue[line]; wait1Msec(10); } goback(howfar,true,40); //backup to starting position howfar=0; if(leftval<rightval) //Compare the amount of light discovered on each side {return 'R';} //Return the value of the side that has more dark else // which will indicate the side the line is on {return 'L';} } /// Simple color checking function //// char colorcheck() { char color; for(int i=0; i<4; i++) // Check the value 4 times to eliminate error { if(SensorValue[colorsense]==11) // PWM converted signal for RED {color = 'R';} //PWM converted signal for GREEN oscillates around 340 if(SensorValue[colorsense]<400 && (SensorValue[colorsense]>300)) {color = 'G';} //PWM converted signal for BLUE is around 670 if(SensorValue[colorsense]<700 && (SensorValue[colorsense]>600)) {color = 'B';} //PWM converted signal for NOCOLOR is ~1024 if(SensorValue[colorsense]>950) {color = 'W';} wait1Msec(250); } return color; } ///////////////////////////////////////////////////// //////// OTHER BASIC FUNCTIONS ///////////////////// ///////////////////////////////////////////////////// void clawclose() { motor[clawright] = -15; //Tweak these to change the gripping force motor[clawleft] = 35; } //////////////////// void clawopen() { motor[clawright] = 75; //NO LARGER THAN 80 FOR EITHER MOTOR, motor[clawleft] = -60; //CHASSIS IN THE WAY } ///////////// void encoder_clear() //Zeroes the encoders (**use before moving a specific distance**) { SensorValue[eleft]=0; SensorValue[eright]=0; } ////////////////////////////////////////////// void goforward(int dist, bool length, int power) { //Options to choose between specific distance, or just turn on the motor // and how fast to move (power). if(length == true) //If specific distance req'd { encoder_clear(); while((SensorValue[eleft] < dist) && (SensorValue[eright] < dist)) //while shaft encoders are less than specified distance { motor[right] = power; //Engage motor[left] = power; } motor[right] = 0; //Turn off the motor motor[left] = 0; //Turn off the motor } else if(length == false) //If just turning the motors on { motor[right] = power; motor[left] = power; } } ////////////////////////////////////////////// void goback(int dist, bool length, int power) { if(length == true) { encoder_clear(); while((SensorValue[eleft] < dist)&& (SensorValue[eright] < dist)) { motor[right] = -power; // ONLY DIFFERENCE FROM ABOVE CODE motor[left] = -power; // IS RUNNING THE MOTORS IN REVERSE } motor[right] = 0; motor[left] = 0; } else if(length == false) { motor[right] = -power; motor[left] = -power; } } ///////////////////////////////////// void turnleft(int amount) { //Input value happens to be close to the turn angle in degrees. Nice :D encoder_clear(); while((SensorValue[eright]<amount) && (SensorValue[eleft]<amount)) { motor[right] = 50; //Right motor forward motor[left] = -50; //Left motor reverse } motor[right] = 0; //Stop motor[left] = 0; } //////////////////////////////////// void turnright(int amount) { encoder_clear(); while((SensorValue[eright]<amount) && (SensorValue[eleft]<amount)) { motor[right] = -50; //Right motor reverse motor[left] = 50; //Left motor forward } motor[right] = 0; //Stop motor[left] = 0; } /*///////////////////////////////////////////// --END OF LINE */
Week 5
Monday, Tuesday, and Wednesday were spent programming the can finding robot.
My code went through many changes, but I stuck with the same basic plan.
The first objective was to have the robot go out on the field and simply find a can. I did this by making the robot go out and pan left and right recording sonar values, and going forward the smallest amount recorded. It would then repeat this process until it found a value within 7-8 inches, at which point it goes forward and closes the claw.
The first objective was to simply have the bot find the can, grab it, move the can and drop it. This is our attempt:
My code went through many changes, but I stuck with the same basic plan.
The first objective was to have the robot go out on the field and simply find a can. I did this by making the robot go out and pan left and right recording sonar values, and going forward the smallest amount recorded. It would then repeat this process until it found a value within 7-8 inches, at which point it goes forward and closes the claw.
The first objective was to simply have the bot find the can, grab it, move the can and drop it. This is our attempt:
Saturday, February 5, 2011
thursday week 4
First thing in class, we talked about planning and how to stay organized on a project. Me and my teammate got together and made a gant chart for what we needed to accomplish on our robot and when, for it to be ready in time. The first thing we did was to mount all the sensors and get some basic reading code done for them. My color sensor reads a value of 11 for red, 365 for green, 650 for blue, and 1024 for no color.
Our next step was to figure out how we wanted to make a grasping device for the robot. After brainstorming ideas for about 30 -45 min, we started a prototype claw design.
The final claw looks like this:
My partner also added some little finger type things to prevent the can from sliding out.
Our next step was to figure out how we wanted to make a grasping device for the robot. After brainstorming ideas for about 30 -45 min, we started a prototype claw design.
The final claw looks like this:
My partner also added some little finger type things to prevent the can from sliding out.
Wedneday week 4
The color sensor i built was nice, but now we need a way to interface it and do something useful.We modified our circuit to produce a single signal line to interface with the VEX PIC microcontroller. The options were to use the original code and output 2 digital signals (1 or 0) or output an analog signal using a single 3 pin connector. I chose the latter. I modified my code to produce a PWM out signal depending on the color the sensor "sees".
The old output section of the code looked like this:
The old output section of the code looked like this:
nocolor: serout 0,N2400,("nocolor",13,10) high 4,5 goto main red: serout 0,N2400,("red",13,10) low 4 high 5 goto main blue: serout 0,N2400,("blue",13,10) high 4 low 5 goto main green: serout 0,N2400,("green",13,10) low 4,5 goto mainI modified it to look like this:
RED: pwmout 2, 99, 0 ; Set the Ouput to 0V goto main GREEN: pwmout 2, 99, 125 ' Set the Output to 1.5 V goto main BLUE: pwmout 2, 99, 250 ' Set the Outut to 3 V goto main NONE: pwmout 2,99,400 ' Set the Output to 5V goto mainThe vex brain's sensor ports don't recognize PWM inputs directly, but by adding a capacitor on the PWM signal line, we can change the signal into a (mostly) continuous voltage which the brain can interpret as analog signal. The duty cycle of the PWM signal determines voltage. My next step was to put it all on perfboard so it's nice and compact. After doing this, I'm done! I now have a sensor for our vex robot!
tuesday week 4
Today we worked on building a color sensor for our robot. Using a 14 pin picaxe, I built the circuit on a breadboard and did some test code. The test circuit I built:
When you shine a red, blue, and green light on a red paper, the red light reflects back most brightly, on a blue paper, the blue reflects back most, etc. How this circuit works is that we have a 3 color LED and a CdS cell connected to a pic microcontroller. The 3 colors take turns lighting in sequence and the pic reads the brightness reflected for each one. It then does a comparison of the 3 reflected values and determines what color the object being illuminated is.
The "screenshot" is the serial message i got when holding a green card in front of the sensor, so it works!
I put electrical tape around the CdS cell and LED to reduce error and noise caused by ambient light.
My code:
For this test version, I had a pair of LED's that would light in different pattern to indicate color.
When you shine a red, blue, and green light on a red paper, the red light reflects back most brightly, on a blue paper, the blue reflects back most, etc. How this circuit works is that we have a 3 color LED and a CdS cell connected to a pic microcontroller. The 3 colors take turns lighting in sequence and the pic reads the brightness reflected for each one. It then does a comparison of the 3 reflected values and determines what color the object being illuminated is.
The "screenshot" is the serial message i got when holding a green card in front of the sensor, so it works!
I put electrical tape around the CdS cell and LED to reduce error and noise caused by ambient light.
My code:
high 0,1,2,3,4,5 pause 1000 main: debug w3 = 0 low 1 high 2,3 pause 50 readadc 0,b0 low 2 high 1,3 pause 50 readadc 0,b1 b1=b1+20 low 3 high 1,2 pause 50 readadc 0,b2 w3 = b0 + b1 +b2 if w3 > 450 then nocolor if w3 < 220 then nocolor if b0<b1 and b0<b2 then red if b1<b0 and b1<b2 then green if b2<b0 and b2<b1 then blue goto main nocolor: serout 0,N2400,("nocolor",13,10) high 4,5 goto main red: serout 0,N2400,("red",13,10) low 4 high 5 goto main blue: serout 0,N2400,("blue",13,10) high 4 low 5 goto main green: serout 0,N2400,("green",13,10) low 4,5 goto main
For this test version, I had a pair of LED's that would light in different pattern to indicate color.
Thursday, January 27, 2011
Thursday week 3
Today we spent class time working on programming and testing our vex bots.
We were given a maze and had to program the squarebot to navigate through it. The fisrt time, we simply used timing commands, and saw how inacurate it was. We were put into groups, given rotary encoders and did it again. Programming the robot with shaft encoders results in much more accurate results. The video shows the results of the encoders, and my code posted afterwards.
We were given a maze and had to program the squarebot to navigate through it. The fisrt time, we simply used timing commands, and saw how inacurate it was. We were put into groups, given rotary encoders and did it again. Programming the robot with shaft encoders results in much more accurate results. The video shows the results of the encoders, and my code posted afterwards.
#pragma config(Sensor, in3, eleft, sensorRotation) #pragma config(Sensor, in4, eright, sensorRotation) #pragma config(Motor, port1, right, tmotorNormal, openLoop, reversed) #pragma config(Motor, port2, left, tmotorNormal, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*// #define sec 10000 #define rev 12.56 #define inch 8 //counts #define foot 105 //counts //1 count = .1256 void reset() { SensorValue[eleft]=0; SensorValue[eright]=0; } void goforward(int power, int dist) { while((SensorValue[eleft] < dist*105-100)&& (SensorValue[eright] < dist*105-100)) { motor[right] = 60; motor[left] = 60; } while((SensorValue[eleft] < dist*105)&& (SensorValue[eright] < dist*105)) { motor[right] = 30; motor[left] = 30; } motor[right] = -1; motor[left] = -1; wait10Msec(10); motor[right] = 0; motor[left] = 0; wait1Msec(1000); } void turnleft() { while((SensorValue[eright]<110) && (SensorValue[eleft]<110)) { motor[right] = 50; motor[left] = -50; } motor[right] = 0; motor[left] = 0; wait1Msec(1000); } void turnright() { while((SensorValue[eright]<110) && (SensorValue[eleft]<110)) { motor[right] = -50; motor[left] = 50; } motor[right] = 0; motor[left] = 0; wait1Msec(1000); } task main() { SensorValue[eleft]=0; SensorValue[eright]=0; while(true) { goforward(80,4.5); reset(); turnright(); reset(); goforward(80,1.8); reset(); turnright(); reset(); goforward(80, 3.5); reset(); turnleft(); reset(); goforward(80,1.5); reset(); turnleft(); reset(); goforward(80,3.5); reset(); turnright(); reset(); goforward(80,1.5); reset(); turnright(); reset(); goforward(80,5); reset(); turnright(); reset(); goforward(80,1.8); wait10Msec(800); //goforward(100,1000); } }
Wedneday week 3
Today we presented our projects and worked with the 555 timer and oscilloscope. The first thing i did was to build a simple 555 driver circuit to make an LED blink. The circuit is shown at right.
The two potentiometers fine tune the frequency and pulse width output by the 555, and the capacitors are the coarse adjustment. The larger the capacitor the lower the frequency.
I then replaced the LED with a piezo speaker and reduced the capacitance to increase the frequency to audio range. I played with it and viewed the output on the CRO, signal shown left A part of the class portion was to learn how to use an O-scope, but since I already knew how, I spend the time playing with more advanced functions for the 555.
I was partially successful in getting the 555 to control a servo position. I did some basic calculations to get values for resistance and capacitance to get the correct on and off time of the signal. By rotating the larger potentiometer, the position of the servo would change, but i couldn't get a full range of motion.
The two potentiometers fine tune the frequency and pulse width output by the 555, and the capacitors are the coarse adjustment. The larger the capacitor the lower the frequency.
I then replaced the LED with a piezo speaker and reduced the capacitance to increase the frequency to audio range. I played with it and viewed the output on the CRO, signal shown left A part of the class portion was to learn how to use an O-scope, but since I already knew how, I spend the time playing with more advanced functions for the 555.
I was partially successful in getting the 555 to control a servo position. I did some basic calculations to get values for resistance and capacitance to get the correct on and off time of the signal. By rotating the larger potentiometer, the position of the servo would change, but i couldn't get a full range of motion.
Wednesday, January 26, 2011
Tuesday week 3 - Hacking a Toy
Today I spent the class time working on hacking my toy. The first thing i wanted it to do was to move the head to the beat of a song. So I built a circuit that took an audio input, passed thru a low pass filter and into the PIC ADC. This way, everything but the kick drum would be filtered out. I wrote a simple program that triggered an output to the motors when the ADC voltage peaked from the kick so the fish would headbang to the beat. It worked quite well for the song I tweaked it to, but had to be tweaked for every song played. I only had 3 I/O pins on my PIC available and eventually disassembled the circuit in pursuit of more user interactive control.
I went back to my old code for moving the fish head around and added some sound capabilities. I wired up the outputs to a speaker and to a darlington transistor for motor control. The fish has 2 functions: "Talk" and "Spaz"
The talk sequence causes the fish to perk up, open it's mouth, and generate a series of random pitches. It's speaks binary! I first had the Pic simply driving a piezo element as a speaker but it simply wasn't loud enough. So I built a simple 1 transistor darlington audio amplifier and used the on-board speaker on the fish. I used the following schematic.
The circuit:
The code:
main:
serout 0,N2400,(10,13,"\nI are binary fish")
serout 0,N2400,(10,13,"Press T for talk, ")
serout 0,N2400,("Press S to spaz")
serin 1,N2400,b1
if b1="s" then spaz
if b1="t" then talk
pause 100
goto main
spaz:
serout 0,N2400,(10,13,"\nHeRpA dErP!")
for b6 = 1 to 15
random w0
w1 = b1/127
w2 = b1/2
high 4
pause w2
random w0
w1 = b1/127
w2 = b1/2
low 4
pause w2
next b6
goto main
talk:
serout 0,N2400,(10,13,"\n11001010 10011011!!!")
for b7 = 1 to 50
high 4
random w0
w1 = b1+500
sound B.2,(b1,7)
next b7
low 4
goto main
I went back to my old code for moving the fish head around and added some sound capabilities. I wired up the outputs to a speaker and to a darlington transistor for motor control. The fish has 2 functions: "Talk" and "Spaz"
The talk sequence causes the fish to perk up, open it's mouth, and generate a series of random pitches. It's speaks binary! I first had the Pic simply driving a piezo element as a speaker but it simply wasn't loud enough. So I built a simple 1 transistor darlington audio amplifier and used the on-board speaker on the fish. I used the following schematic.
The circuit:
The code:
main:
serout 0,N2400,(10,13,"\nI are binary fish")
serout 0,N2400,(10,13,"Press T for talk, ")
serout 0,N2400,("Press S to spaz")
serin 1,N2400,b1
if b1="s" then spaz
if b1="t" then talk
pause 100
goto main
spaz:
serout 0,N2400,(10,13,"\nHeRpA dErP!")
for b6 = 1 to 15
random w0
w1 = b1/127
w2 = b1/2
high 4
pause w2
random w0
w1 = b1/127
w2 = b1/2
low 4
pause w2
next b6
goto main
talk:
serout 0,N2400,(10,13,"\n11001010 10011011!!!")
for b7 = 1 to 50
high 4
random w0
w1 = b1+500
sound B.2,(b1,7)
next b7
low 4
goto main
Thursday, January 20, 2011
thursday week 2
We talked about transistors and how they can only pass a limited amount of current because of their gain. We first built a circuit which uses a small transistor with low gain to turn on a incandescent 12v bulb. The light is unable to fully illuminate because of the limit of the small transistor. If we use a single larger transistor, the PICAXE is unable to provide enough current to fully "turn on" the transistor. The dimly lit bulb:We can use the small transistor to power the base of the larger transistor. This is the result:
As you can see, much more current gets to the bulb. However, this dual transistor arrangement is commonly used, so we can use an already manufactured transistor called a darlington transistor which is the same thing in a single transistor package.
I used this transistor along with the PIC to control the motors on my fish.
After that I looked at the PWM capabilities of the pic and then serial interfacing with the computer. I wrote a program that allows the computer key presses to send data to the pic which would return the data to the screen. This required building a circuit that could switch between program mode and serial interface mode:
To do that I just have to move the white serial wire between pins on the breadboard. I went home and programmed the pic to turn on and off an LED with a keystroke. And slept.
wednesday week 2
First off we learned some basics of serial communications and soldered together a RS-232 connector to interface the computer with our breadboard. We recieved a PICKAXE microcontroller and began construction of a basic programming circuit. The first program we wrote was to make a simple flashing LED. Here it is functioning with the logic probe showing the switching between high and low:
and the basic code used:
main:
high 1
pause 1000
low 1
pause 1000
goto main
For the next while I familiarized myself with the BASIC programming language, and wrote some other programs. I learned how to interface input sensors both analog (like a CdS cell) and digital (a momentary switch). The following video shows the program i wrote. It senses variable values from the cds cell between 0 and 255; if the values are above a specified threshold (bright), the one LED lights, if it's below a threshold the other LED will light, and if the values are in between, neither will light.
The last thing I did was to crack open a "Billy Bass" singing,talking toy. I cut the motor wires and rerouted them out of the device so i could acess them easily. I then made a simple program for the PIC to make a spazzing mouth movement. I had the signal from the PIC trigger the base of a larger transistor to switch on and off the motors:
and the basic code used:
main:
high 1
pause 1000
low 1
pause 1000
goto main
For the next while I familiarized myself with the BASIC programming language, and wrote some other programs. I learned how to interface input sensors both analog (like a CdS cell) and digital (a momentary switch). The following video shows the program i wrote. It senses variable values from the cds cell between 0 and 255; if the values are above a specified threshold (bright), the one LED lights, if it's below a threshold the other LED will light, and if the values are in between, neither will light.
The last thing I did was to crack open a "Billy Bass" singing,talking toy. I cut the motor wires and rerouted them out of the device so i could acess them easily. I then made a simple program for the PIC to make a spazzing mouth movement. I had the signal from the PIC trigger the base of a larger transistor to switch on and off the motors:
Tuesday, January 18, 2011
Tuesday week 2
We started off by introducing the transistor, an electronic switch. The circuit i constructed applied voltage to the base of an NPN transistor, which switched it on, passing the voltage from collector to emitter and turned on the LED.We then replaced the Base resistor with two wires and held them in our fingers. We saw that as we varied the voltage going to the base by squeezing tighter, the LED grew brighter. A transistor amplifies any change in voltage applied to the base and applies it to the emitter as a change in current!
After that, I constructed a basic logic probe. The concept for the basic one is that when the probe is disconnected, the LED is dim, when it recieves a HIGH logic signal (~5v) it goes bright, and when it recieves a LOW (0v) it goes off. This is my basic logic probe receiving a high signal:
After i did that, I spent the rest of the evening working on building the advanced version. The difference is that it uses 2 LED's. When the probe is unconnected, both stay dim. When it receives a high signal, the green LED illuminates, and if it's low, the red LED lights. The circuit uses an NPN and PNP transistor, one for each signal type. The hardest part was choosing the correct value of resistor to match the gain of the transistors and get the correct brightness on the LEDs. The prototype on the breadboard, and the completed perfboard.
After that, I constructed a basic logic probe. The concept for the basic one is that when the probe is disconnected, the LED is dim, when it recieves a HIGH logic signal (~5v) it goes bright, and when it recieves a LOW (0v) it goes off. This is my basic logic probe receiving a high signal:
After i did that, I spent the rest of the evening working on building the advanced version. The difference is that it uses 2 LED's. When the probe is unconnected, both stay dim. When it receives a high signal, the green LED illuminates, and if it's low, the red LED lights. The circuit uses an NPN and PNP transistor, one for each signal type. The hardest part was choosing the correct value of resistor to match the gain of the transistors and get the correct brightness on the LEDs. The prototype on the breadboard, and the completed perfboard.
Saturday, January 15, 2011
Thursday, week 1
To start off, we talked about mechanical toggles and momentary switches. All switches were double throw switches. I first constructed a simple dual way "light switch" so no matter the state of the switches, flipping one will always change the state of the LED between on/off.
Next thing we did was learn about relays which are just electronic activated switches. I made a circuit which has an LED normally on, then when the relay is switched, it turns off and a different LED is turned on.
Finally we made a buzzer circuit so the relay switched itself off. When power was applied, the relay broke connection to the power, causing it to turn off. But when it turned off, connection was restored and this process repeated very rapidly causing a buzzing action.
The last thing we did was to finish building out vex squarebot and get it driving around. I souped mine up with extra large wheels
.
Next thing we did was learn about relays which are just electronic activated switches. I made a circuit which has an LED normally on, then when the relay is switched, it turns off and a different LED is turned on.
Finally we made a buzzer circuit so the relay switched itself off. When power was applied, the relay broke connection to the power, causing it to turn off. But when it turned off, connection was restored and this process repeated very rapidly causing a buzzing action.
The last thing we did was to finish building out vex squarebot and get it driving around. I souped mine up with extra large wheels
.
Thursday, January 13, 2011
Jan 12 - intro to breadboarding
Today we started off with learning how to use a multimeter to measure continuity, resistance, and AC & DC voltages. I tested my power supply and it worked.
Then we went over resistors and potentiometers and breadboarding. Our first circuit was to light an LED thru a resistorAfter that i played with a CdS cell which is basically a light sensitive resistor. The values ranged from roughly 1.0 kΩ to 20 kΩ when fully covered. When put in series with the LED, this was the results:
Then we went over resistors and potentiometers and breadboarding. Our first circuit was to light an LED thru a resistorAfter that i played with a CdS cell which is basically a light sensitive resistor. The values ranged from roughly 1.0 kΩ to 20 kΩ when fully covered. When put in series with the LED, this was the results:
Uncovered vs Covered:
Next we discussed schematics and how to interpret them. We then played with different values of resistors to power the LEDs. The lower the resistor value, the brighter the LED, however an LED always needs a resistor otherwise it goes POOF as we found out by blowing one up :-D
We then learned about Kircshoff's voltage law and Ohms law and used them to calculate the required resistor for an LED, given its datasheed and forward voltage. The optimum value for mine was 150Ω:
Finally, we recieved a vex kit and inventoried it and began construction on a squarebot.
Next we discussed schematics and how to interpret them. We then played with different values of resistors to power the LEDs. The lower the resistor value, the brighter the LED, however an LED always needs a resistor otherwise it goes POOF as we found out by blowing one up :-D
We then learned about Kircshoff's voltage law and Ohms law and used them to calculate the required resistor for an LED, given its datasheed and forward voltage. The optimum value for mine was 150Ω:
Finally, we recieved a vex kit and inventoried it and began construction on a squarebot.
Subscribe to:
Posts (Atom)