PDA

View Full Version : Explaining buttons to h.s. Students

rtmorris
01-19-2006, 08:57 PM
I need a good way to explain to high school students·how the bs2 recognizes a change to a·high signal when a button active high·circuit is pressed, and how the bs2 recognizes a change to
a low signal when a button in an active low circuit is pressed.· Let's say that pin 5 is the input
pin sensing the change.· I am refering to the button diagrams in WAM I believe chapter 3 or 4.

-Rob Morris

PJ Allen
01-19-2006, 10:43 PM
Active low -- seeking 0V

Active high -- seeking 5V

rtmorris
01-19-2006, 11:06 PM
I like your diagram, but why does the bs2 see the five volts in the active low before the switch is closed, is vdd dropping off only some of the voltage over the 1 k resistor leaving over 1.4 volts for the input pin...the manuals say that over 1.4 Volts is a high signal, and less than 1.4 Volts is a low.....am I thinking about this correctly? and if I am how many volts are actually dropped over the 1k resistor?

Jonathan
01-19-2006, 11:12 PM
Rob,

I always start with an explanation of digital signals as a binary language of communication, like Morse code. I explain that like Morse code, a Stamp understands two states. In the case of Morse code of course, it is "dit" and "dah" and for a Stamp "high" and "low".

With this concept already in place, when we discuss input switches, I explain that we can get the Stamp to look for a "dit' or a "dah". high and low. I take a 'scope and show them what happens with an input without a pullup/down resistor, running a simple program that debugs the state of the input. Then add the resistor and show the difference and explain that the resisitor puts the input in a "known state" so that we can reliably detect the oposite state. When we get to debouncing, I use the 'scope again.

HTH,

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

rtmorris
01-20-2006, 11:19 PM
Jon,

I really like your example.· I went and gathered data for the active low circuit, finding the potential

difference over the 10k pull up resistor and the 220 ohm resistor going into an input pin on

the stamp.· I dropped 5 volts over each????· I guess maybe I am trying to understand how

the stamp is knowing that 5 volts is dropped over the resistor going into its input pin, and the

physics behind why I'm getting 5 volts over each?· I'll be teaching this next semester, and

I can anticipate students asking me why this happens.

Thanks,

Rob

Jonathan
01-20-2006, 11:54 PM
Rob,

I don't see how you are dropping 5V across the resistor. I'd have to look up what a Stamp pin draws in input mode, but I'm sure it is in the low uA's, so the voltage drop should only be able to be read with an accurate low scale voltmeter. I just checked, and I see a .6mV drop. I assume you have something like this:

220 10k
Stamp pin ----/\/\/\/\----|-------/\/\/\/\-----5V
|
|------- switch------ GND

Perhaps you mean that you measure 5V between the 10K and 220ohm rersistors? If so, that is normal. As to how the Stamp knows, think of the input pin as a comparator. When the threshold voltage is exceeded (1.4V springs to mind, but I'm not sure) the Stamp sees a high. Below the threshold it sees low. I explain the threshold using a balance beam scale (we have some in the room, we use the physics lab). The threshold is the balance point of the scale, and the weights are voltage.

Hope this helps!

Jonathan

BTW, ain't teaching the Stamp to high school students grand? They love it and are at an age where they can easily come up with and implement ideas. I have a student this year who is puting a Stamp and an accelerometer on a remote controlled gas powered car he has and trying to improve the handling to hold the road doing curves as fast as possible. Fun stuff, and they can't help but to learn a ton. Me too!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Jonathan
01-20-2006, 11:57 PM
Rob,

Sorry, but the forums ate my ASCII drawing! I don't mean it as it looks!

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

rtmorris
01-21-2006, 12:40 AM
Jon,

Not sure if my first reply got through, but see attached to be sure we are talking about the same circuit.

Thanks again,
Rob Morris

rtmorris
01-21-2006, 12:43 AM
attached circuit for previous posting.

-Rob Morris

Jonathan
01-21-2006, 01:25 AM
Rob,

Yup, that is the circuit I was *trying* to draw. But, I don't quite get your question. With the Stamp pin as an input, I get a .6mV drop between VDD and the Stamp pin with the switch open. Of course, when the switch is pressed, the Stamp pin will read very close to 0V.

Jonathan

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

rtmorris
01-21-2006, 02:39 AM
Jon,

Very sorry,· I just took readings again, and yes when the button is pressed, I am dropping 5 V over the 10k, but almost nothing over the 220 ohm.· When the button is not pressed I am dropping zero volts over both resistors.· Now how does the bs2 interperet a 5 volt drop over the 10k as a high?· If we follow the path of conventional current, then in our circuit, the 220 ohm resistor is at a lower potential than VDD right?· So should p5 be low when the button is pressed?· I need a good way to explain how the bs2 is interpereting·the voltage from the circuit.

Thanks again,

Rob Morris

Tracy Allen
01-21-2006, 02:42 AM
I think it's worthwhie to introduce the voltage divider equation. This equation is so, so important in electronics. It applies not only to digital inputs as you have it here, but also to any other situation of matching input and output impedances to transfer signals or power.

Here is that circuit:

Vp R1, 220 Vx R2,10k
Stamp pin ----/\/\/\/\----|-------/\/\/\/\-----Vdd
Rp |
infinite `------- switch------ GND
Rs,infinite or zero ohms

There are 4 resistors in the circuit, when you also include the switch R3 with either infinite or zero resistance, and the Stamp input resistance which is practically infinite. The Stamp responds to the voltage level Vp at the input pin. Greater than 1.4 volts is HIGH and less than 1.4 volts is LOW. Voltage Vp has to get to the pin through R1, the 220 ohm resistor, and that attaches to Vx. Here is the voltage divider equation for that:

Vp = Vx * Rp / (Rp + R1) = Vx

You can have fun with your students to see that {infinity /(infinity + 200)} equals 1. Have them subtitute a series of successively higher numbers for infinity. The point is, Vp=Vx.

Now look at the equation for Vx. Again a voltage divider with the switch resistance Rs:

Vx = Vdd * Rs / (Rs + R2) = Vx

Have the students substitute Vdd = 5 volts, R2=10000, and Rs = infinity.
They will find Vx=5 volts. Then have them close the switch so Rs=0.
They wil find Vx= 0 volts.
And according to the first voltage divider equation, those values pass right through the 220 ohm resistor to the input pin.

Some student is going to ask why the 220 ohms is there at all. The reason is, it protects the Stamp pin in case somebody shuffles across the carpet on their way over and touches the switch and a spark jumps across and Vx suddenly becomes very high. The 220 ohms is called a protection resistor. There is more of a story there, too, on how the 220 ohms limits the fault current.

And some student might ask why R2 is 10 kohms and not 1 kohm or 100 kohm. And that is right. It could be those other values and the voltage divider equation will show that it should work. However, when the resistor is too low a value, the current through the switch (ohms law, Vdd/R2, when the switch is closed) might become too high, or wasted. On the other hand, when the resistor is too high, say 10000000 ohms, the voltage at Vx will pick up noise from the environment and just touching or waving you hand near the pin will be enough to trigger the button. You might have them try it. Leave off the resistor R2, so R2=infinity, and have them touch the pin while running a program like this:

DO
DEBUG BIN IN5
LOOP

It can give a kind of random series of zeros and ones. But if they put back in R2=10000 ohms, that won't happen. 10000 ohms is a practical compromise, between current when the switch is pressed and noise when the switch is not pressed.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Kevin Wood
01-21-2006, 02:22 PM
If you are using the WAM Kit, try building the circuit first without the BS2, so you just have Vdd, a 10K Ohm, a 220 Ohm, and Vss, connected in series.

Have your students use Ohms law to calculate the voltages dropped across each resistor, and then measure to get the actual readings. Measure at 3 points: 1) the Vdd side of R1, 2) between R1 & R2, and 3) the Vss side of R2.

This should allow them to see that the voltage dropped across each resistance is a percentage of the total dropped. Remind them that the numbers they get from Ohms law will be be "ideal," and that they need to account for the tolerances of the resistors, as well as the measuring instrument.

Once they see how it works without the Stamp, introduce them to the concepts in Tracy Allen's post.

Also, there is a BS2 tutorial (PowerPoint & HTML) on the Educational downloads page that covers active high and low, it might help.

rtmorris
01-22-2006, 11:19 AM
Kevin, Tracy, and Jon,

Thanks so much for your help.· Your comments led me to a great way to explain to my students, how the high and low
signals are·detected.· Specifically, Tracy your comment about the effectively infinite resistance of the stamp.
Here is my new take on it:· In an active low circuit, the resistance of the 10k and 220 ohm resistors are low
in comparison to the almost infinite resistance of the stamp.· Therefore, with the switch open we essentially have a series circuit, and in series, the most voltage is dropped over the highest resistance aka the stamp.· Since the input voltage is the voltage between the pin and ground, this voltage is almost totally 5V or a high.· If the switch is closed, the switch is effectively in parallel with the 220 ohm and the stamp.· This new parallel connection's resistance is extremely low of course, and therefore the most voltage will be dropped over the 10k resistor·leaving very·little voltage left to be dropped over the stamp, resulting in a low.·

Again, thanks very much everyone,

-Rob Morris

Kaos Kidd
01-24-2006, 03:23 AM
Tracy:
Thank you! I have a much clearer view on the issue between the "protection" resistor, and the actual current limiting resistor.
Can the sircuit be made to intentionally trip when you wave your hand over it? I guess what I'm asking is what determins what is noise, and can that its self be controlled?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
------------------------------------------------

Just tossing my two bits worth into the bit bucket
------------------------------------------------
KK
·