DEMO: QuickStart - Push-ON / Push-OFF
Beau Schwabe
Posts: 6,568
{{ ****************************************** * QuickStart Push-On Push-Off Demo v2.0 * * * * Author: Beau Schwabe * * Copyright (c) 2011 Parallax * * See end of file for terms of use. * ****************************************** Revision History: Version 1.0 - (06-06-2011) - original file created Version 2.0 - (07-06-2011) - 1-pin Sigma-Delta-ADC implementation for better noise immunity. - Push-On / Push-Off implemented for easier BYTE reads of the 'buttons' that are pressed. Theory of Operation: This program implements a 1-pin Sigma-Delta-ADC for each of the I/O pins. Each ADC is capable of detecting two distinct thresholds. This creates a hysteresis to the 1.4V threshold of the I/O providing greater noise immunity to external influences. 3.3V ──── VDD 2.2V ──── ADC threshold 2 I/O threshold ──── 1.4V 1.1V ──── ADC threshold 1 0V ──── GND The Idea of a 1-pin Sigma-Delta-ADC is to sample the pin as an input, and then very briefly make the pin an output in the opposite state. i.e. if the input reads a "0", then the output is made a "1" and vise versa. The resting state is a condition where the output state of the ADC is a "1" or "0" every other iteration. If the input is pulled to GND or VDD, then the output of the ADC would be two consecutive states that are the same. In the case with the QuickStart, since the buttons would be pulled to ground, the two consecutive states would both be 1's ... opposite of the GND detected by the input. In another implementation, you could pull to VDD and have two consecutive 0's instead, but the way the QuickStart is designed, the Pull-down is to GND. The ADC's function in this example is to keep track of how many times the I/O voltage needed to be 'bumped' in the same direction. Under normal circumstances, the ADC's returned value would be a "1" indicating the I/O value is somewhere between threshold 1 and threshold 2. If you externally pull the I/O to GND, then the ADC's value would be a "2". Likewise a "0" if you pulled the I/O to VDD. The distinction between a "1" and a "2" from the ADC is the key in order to determine a button press or not. This while at the same time creates the necessary hysteresis that helps to reject noise. Please Note: When programming the QuickStart, make sure that the surface that the QuickStart is sitting on is NOT conductive. This includes surfaces you may not think are conductive, such as polyurethane which can be highly electrostatic. This can cause programming problems under these conditions. }}Video Demo 1 - [video]http://www.youtube.com/user/ICPolyman#p/a/u/2/oPELStFtclI[/video]
Video Demo 2 - [video]http://www.youtube.com/user/ICPolyman#p/a/u/1/5fPtIo82M1Y[/video]
OBEX Link - http://obex.parallax.com/objects/762/
Comments
It should be supplied with that program so that the board does something interesting when it's first plugged in.
Thanks!
All feedback is welcome.
I agree, some sort of program should be pre loaded. We'll see about including something.
Oops, was I not supposed to mention those?
Beau I have a related question - is it possible to buffer and "output" the switching threshold voltage (~1.4v) from the input fets on the die? I think with prop 2 we might be able to output Vdd/2, and also a DAC level, but these aren't quite the same as they don't 'track'. I'm very thankful at least we have the positive feedback counter mode in the meantime.
I understand the benefits of having an I/O threshold reference. If I understand you correctly, the link below is an earlier variation of the 1-pin Sigma Delta ADC that tracks the I/O threshold voltage.
http://forums.parallax.com/showthread.php?105674-Hook-an-antenna-to-your-Propeller-and-listen-to-the-radio!-%28New-shortwave-prog&p=993273&viewfull=1#post993273
Have you tried it while not touching ground with your left hand?
Your internal body resistance is usually quite small compared to your skin resistance...
Touching my left hand to ground doesn't seem to have any affect...
I just did a little experiment though that has me questioning how this is all working... I held a metal screwdriver with my fingers and just touched the center pad and that way all the buttons behave the right way.
Then, I took Scotch tape to cover up the ground pads on one the switches that wasn't working right, and then it works right.
I did this while not touching ground anywhere... This is a little puzzling to me.
Only thing I can think of is thay my body is acting like an antenna and this code picks up on stray RF signals due to it's high input impedance.
Anyway, tape off the ground pads if your switches aren't working!
"I just did a little experiment though that has me questioning how this is all working... I held a metal screwdriver with my fingers and just touched the center pad and that way all the buttons behave the right way." - At very close range you can have capacitive coupling that might cause it to respond this way.
Another couple of thoughts ...
- What kind of lighting do you have? ...noisy fluorescents? ...try moving to another location if that's the case.
- On average, what is the relative humidity?
- Also... what is the surface that the QuickStart is sitting on? I had problems on a polyurethaned table.
Here is a very simple code which makes the same and works quite reliable for me:
Andy
Beau, Ok I did some testing of the idea of just touching the center part of the button with your code. It works everywhere in my house absolutely perfectly. But, way out in my backyard it doesn't work hardly at all. So, I think it's picking up on the 60 Hz radiation field in the house.
So, I'm tempted to cut the ground connections on all the pads... Actually, I just decided that's what I'm going to try.
Now, it works perfectly.
Well, as long as I don't touch ground with my left hand anyway. If I do touch ground with my left hand, then it still works, but in a different way, the LED changes state only when pushed and then goes back when release. This has me a little puzzled at the moment...
The original demo code now works good as long as I hold ground (usb connector) with my left hand.
This version of Ariba's code works well with left hand touching ground or not:
First I check every button separatly because I've seen some crosstalk between adjacent buttons sometimes.
Then I check every button 2 times with a delay of 8..9ms so I hope to eliminate the 50/60 Hz stray signal. Andy
"...I check every button 2 times with a delay of 8..9ms so I hope to eliminate the 50/60 Hz stray signal...." - I like your way of thinking here. I wonder if looking at the buttons in 'quadrature' using a delay of ~4ms would be useful in an inverted logic way of looking at the problem.