Help Request - Defeat random interferrence on pins?
Kirk Fraser
Posts: 364
How can I·defeat random interferrence on input pins?· I wrote a·radio directed·limit switch·toggle program to control·a hydraulic valve test,·which follows.· The input pins cause unexpected 1 answers which seem to be affected a little by the length of Pause statements in the Move loop.·
What can be done to clean up the interferrence?· I'm using long leads but there should be no induction on limit switch inputs.· In the following program the Start loop works ok with input from an attached Parallax radio keyfob device but the Move loop never works·right.· What·I want it for it to·toggle between forward and reverse·until it hits a limit switch then·switch direction (and stop on a radio command).· The radio commands work adequately but the·debug results show more than expected executions of the LUP and LDN routines.· Should I try to debounce the switches with Button or PulseIn·or put some electronic devices on the pins to reduce long-lead interferrence?
Thanks much,
Kirk Fraser
'{$STAMP BS1}
SYMBOL GOING = B0
START:
LOW 3········· 'Up Coil off
LOW 4········· 'Down Coil off
GOING = 0
IF PIN0 = 1 THEN MOVE·· 'R2 = Remote On· Pushed
PAUSE 5
QUIT:
DEBUG "LOOP "
GOTO START······ 'loop forever
MOVE:
IF GOING = 0 THEN LUP
PAUSE 5
IF PIN6 = 1 THEN LUP·· 'Limit SW UP on
PAUSE 5
IF PIN7 = 1 THEN LDN·· 'Limit SW DN on
PAUSE 5
IF PIN1 = 1 THEN QUIT· 'R4 = Remote Off Pushed
PAUSE 5
DEBUG "MOVE "
GOTO MOVE
LUP:············ 'Go Down
GOING = 1
HIGH 4
LOW 3
DEBUG "LUP "
GOTO MOVE
LDN:············ 'Go Up
GOING = 1
HIGH 3
LOW 4
DEBUG "LDN "
GOTO MOVE
What can be done to clean up the interferrence?· I'm using long leads but there should be no induction on limit switch inputs.· In the following program the Start loop works ok with input from an attached Parallax radio keyfob device but the Move loop never works·right.· What·I want it for it to·toggle between forward and reverse·until it hits a limit switch then·switch direction (and stop on a radio command).· The radio commands work adequately but the·debug results show more than expected executions of the LUP and LDN routines.· Should I try to debounce the switches with Button or PulseIn·or put some electronic devices on the pins to reduce long-lead interferrence?
Thanks much,
Kirk Fraser
'{$STAMP BS1}
SYMBOL GOING = B0
START:
LOW 3········· 'Up Coil off
LOW 4········· 'Down Coil off
GOING = 0
IF PIN0 = 1 THEN MOVE·· 'R2 = Remote On· Pushed
PAUSE 5
QUIT:
DEBUG "LOOP "
GOTO START······ 'loop forever
MOVE:
IF GOING = 0 THEN LUP
PAUSE 5
IF PIN6 = 1 THEN LUP·· 'Limit SW UP on
PAUSE 5
IF PIN7 = 1 THEN LDN·· 'Limit SW DN on
PAUSE 5
IF PIN1 = 1 THEN QUIT· 'R4 = Remote Off Pushed
PAUSE 5
DEBUG "MOVE "
GOTO MOVE
LUP:············ 'Go Down
GOING = 1
HIGH 4
LOW 3
DEBUG "LUP "
GOTO MOVE
LDN:············ 'Go Up
GOING = 1
HIGH 3
LOW 4
DEBUG "LDN "
GOTO MOVE
Comments
I would try lowering the value of that resistor. Try to draw between 10 to 20 milliamp when the switch is closed.
That would be between 250 and 500 ohms.
Terry
·· That sounds like your problem right there...Long lengths of wire can act like an antenna and pick up stray RF and cause all kinds of weird signals on inputs.· You should definately do as Bean suggested!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
The next problem is my output pins which I have wired to Radio Shack's 5vdc relays. They apparently draw too much of the pinout current. The program controls the pins correctly but at the high pin there are under 2 volts with the relays attached. What I'm trying to do is cascade from these smaller relays upto automotive 12vdc relays which can then run most anything.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas, TX· USA
Next, I can't get the relays to activate by supplying 5 vdc to the base of my 2N2222's and connecting the negative side to the ground. So I suspect something is wrong in that area of the circuit also. But I'm not sure how to test it more thoroughly. Is it possible the Vdd 5v on Stamp supply isn't strong enough to trip the Radio Shack 5Vdc relays? What next steps does anyone suggest? Thanks.
PS: The inputs from the limit switches and radio still work fine. So I just need to know how to get the output to work. I tested the relay cascade from 5 v to 12 V and it appears to work, just something between the output pins, transistor, and 5v relay seems to be not working.
·· Are you connecting 5V directly to the base of the transistor?· If so, you should put a 220 ohm - 1K resistor between the output pin and the base of the transistor...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
I used the 220 ohm resistor both in the real circuit and a breadboard version. Since I didn't get any reply to this until now, I reposted it in another thread where a person suggested a different transistor. My local Radio Shack is too small to stock it so I'm going to the next larger one tomorrow.
I'm also going to have to ask my Digital Electronics teacher how to decide which components to choose when looking at a generic unlabled schematic like that. The teaching also has a generic treatment of transistors so far.
Kirk
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
How do you figure out which transistor to use when you see an unlabeled circuit like that?
Thanks much for your assistance.· I misunderstood the transistor pinout diagram on the back of the package·and your mention of the correct pinout helped find my mistake.· Reversing the emitter and collector leads·solved the switching problem on the breadboard so I'll try it on the Stamp circuit.
This may be a bit bigger than a Stamp project but I'm also·wondering -- you know how Magnetic Resonance Imaging·shows the interior of a person -- what sensor system would show the spiritual effects of prayer?
Kirk
·
As for knowing what type of transistor to use, it's a matter of voltage and current requirements.· Switching a 5V Relay is one of those things that requires no more than a small-signal transistor or General Purpose Switching Transistor.· The 2 numbers you want to look at are (Looking at the back of a Radio Shack 2N2222 package) the Vce, which is the Collector-Emitter Voltage.· This is how much voltage the transistor can switch.
Next thing you need to know is how much current your load (Relay) draws.· In your case it's probably less than 100mA, however the 2N2222 is rated at 800mA (MAX).· I myself would probably use a Power Transistor if I were drawing that much power though, since it's the MAX rating for the 2N2222.
Basically just make sure that your load is within the ratings of the transistor.· The 2N2222 and 2N3904 are the more common NPN transistors for general hobbyist interfacing, such as switching Relays, Lamps (6-12V), High-Current LEDs or even larger capacity transistors.
Usually if you have a project that requires something larger you might use the TIP31/TIP41, which can handle 60 Volts and 3A.
Next up from there I think would be something like the 2N3055 which can do 60V and something like 4-10A depending on the package and heatsink.· Hope this helps you out.
Also, while the schematic you had shows a 220 Ohm resistor, a 1K resistor usually is the better choice for the experimenter, since that value works on that transistor over a much wider range of control voltages.
As for your last question, I don't have the answer...I'm not sure prayer is what's usually going through my mind when something won't work!·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Knight Designs
324 West Main Street
P.O. Box 97
Montour Falls, NY 14865
(607) 535-6777
Business Page:·· http://www.knightdesigns.com
Personal Page:··· http://www.lightlink.com/dream/chris
Designs Page:··· http://www.lightlink.com/dream/designs
·
Emotional constructs are ofen viewed with the aid of P.E.T. scans. P.E.T. is positron emission tomography. The image of the barin lokks something like what you'd expect to see in a tehrmograph if you've ever seen one of those which shows temperature differentials within a body (human or otherwise).
Regards,
Bruce Bates
On prayer, the reason I asked is I've had lots of answers to prayer including earlier this month I had a "loop of Death" on my WinXP computer where it asks to boot in safe mode and every choice leads back to that screen. I put up with it for a while, trying to boot with the A: drive, etc. but I only had a DOS boot which can't read WinXP files. So I remembered how lots of things work by prayer and prayed for it as I walked away and when I came back it was fixed!!! I'm not strong enough at it to do everything that way but it's very interesting how God's kingdom works. So I guess if there were a display that would show a person when they are praying and it's effects on their bodies, that could help others do it or get better at it. I think I have a clue but not a full solution -- when I've inadvertently put my hand on 120VAC but been in prayer it didn't hurt but when out of prayer in myself it hurts a lot. Somehow I think that could lead to a sensing system if I were or knew a scientest. Oh well, I'd better get back to getting ready for my electronics class.
Thanks for the P.E.T. scan tip. I'll look into it.