Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

My button works like magic, I only have to hover my finger over it

Status
Not open for further replies.

jimfraseruk

New Member
I am slowly building an start/ finish beam break gate for a timer. I have setup a couple of the bits that I think I need, PWM for IR beam, Piezo buzzer to signal the start/ stop, now I wanted to test the break by using a button rather than the IR receiver just. But the event is triggered when my finger goes anywhere near the button or its pull up resistor, I don't have a chance to press it. If I use a long plastic object to press the switch it works fine. Other projects I have created with switches work fine.

So why does my finger not the switch trigger the event and how can I fix it?

I think I narrowed it down to be something to do with TMR1 as when I comment out that code the button works fine to turn the buzzer on when I hold the button down.

Rough circuit diagram and code attached. I have set it up on a breadboard with 5v regulator.
 

Attachments

  • StartGateCircuit.JPG
    StartGateCircuit.JPG
    10.5 KB · Views: 197
  • StartGate.asm
    8.3 KB · Views: 136
Try giving supply through batteries & see also did you place decoupling capacitors very closer to the PIC power rails?Also the original code is to detect the IR beam but when you testing with a button you need to add button DEBOUNCE coding as well.
 
Last edited:
I have a 100nf and 10nf capacitor around the 5v regulator, thats it. I will lookup decoupling capacitors and give that a go.

I can add debounce, but that does not stop my button from being magic.
 
Even though your asm file shows MCLRE_OFF, the PIC is behaving like MCLR is floating - randomly resetting due to stray electric induced by your fingers. try pulling it up to +5V via a 10K resistor. Some PICs don't like both internal MCLR and INT OSC,

Decoupling caps are always a good idea.

Debouncing a switch is necessary if you are using the edge to initiate something. If you are just using the level to turn on or off the peizo, then it's not really an issue. I would debounce it as a matter of course but I doubt that's your problem.
 
Not sure what PIC you're using but if it's one that has a LVP pin then I suspect you need to disable Low Voltage Programming option in the config fuses. I got those same type symptoms long ago when I left LVP enabled but left the actual LVP pin floating...
 
Philba; the PIC is not resetting, it works just as I want apart from the swtich is my finger.

justDIY; I have disabled the analog comparators

Mike; I am using a PIC16F628a. I will look into turning off LVP pin.

Further investigation shows that if I have the switch miles away from the PIC it works fine, but if I put my finger anywhere near the pull-up resistor it triggers?

I have put decoupling caps in.
 
jimfraseruk said:
If I use a long plastic object to press the switch it works fine. Other projects I have created with switches work fine.

jimfraseruk said:
Further investigation shows that if I have the switch miles away from the PIC it works fine, but if I put my finger anywhere near the pull-up resistor it triggers?

Looks like your circuit is very sensitive to electrostatic discharge from your finger.

Does the false triggering happen every time? Have you tried to discharge static electricity from your body before pushing the button?

Hopefully you won't have that issue when you'll place the IR receiver.

Good luck with your project.
 
The 16F628A does have LVP capability. Have you tried grounding the PGM pin or turning off the LVP enable in the config fuses yet?
 
his source code has LVP turned off. (assuming that source is what was used to builf the .hex).

Verify your configuration settings (aka fuses) in your programmer. Make sure LVP is off, internal mclr, INTOSC and so on.

something is floating. you need to find it.

With the power off, I would measure between the input pin and +5. If it doesn't measure very close to your resistor value, verify the connections and perhaps replace the resistor.

if that checks out, put a 10K pullup on MCLR.
 
OK one at a time here.

ENG1; Thankyou for wishing me luck, I feel I need lots of that at the moment, it seems so stupid.

Yes it happens everytime, and now I have replaced the button with an IR receiver TSOP1738, it still happens (I put my finger just infront of the IR receiver) and it triggers the buzzer. And no its not being triggered by an actual beam break.

JustDIY; Now I am confused, Gayan said go higher and you are saying lower. The pull up resistor I am using is 10,000ohms, the only higher one I have is 100,000ohms, which is probably too high.

Mike; LVP is turned off on the fuses. I have not tried grounding LVP pin or MCLR yet. Will try tonight if my wife will let me (I am spending too much time trying to sort this out)

Philba; Will try that all out, does that mean reading the hex code to see if the fuses have been set correctly?

Thanks again for all your suggestions.
 
Last edited:
I know it's not much help?, but it's either a design error (your circuit design is flawed in some way), a construction error (you've made an error building it), or a software error (you've written the software wrong).

I suggest you post the FULL circuit, every capacitor, every resistor, every single component (the partial diagram above is of no use). Then take a picture of your construction, and post that!.
 
stronger pull-up means less resistance ... 1000 ohms < 10000 ohms

edit:

I'm not sure why a higher pull up is suggested ... if your 10k is connected correctly and you're still experiencing high sensitivity on the pin, then the pull up is not strong enough, and your mere touch is enough to pull down the pin. a stronger pull up uses more current to bias the pin to the high rail - more current will also be required to affect a change in the state of the pin, pulling it low. I = V / R tells us a 1kohm pull-up at 5v will limit current to 5 ma - so to change the pin from high to low, you'll need to sink more than 5ma of current. This is no problem for a mechanical switch or most modern digital parts, but double check your component ratings just to be sure.
 
Last edited:
Extremely likely that the OP has not masked other bits from the result of reading the input port and then performs a software test based on zero/not zero instead of testing specific bit position.
 
eblc1388 what does that mean, below is the code i use to check a button press.

Code:
Check_Keys
		btfss	PORTA, IRR		; is there an input (low)
		call 	Send_StartStop		; Yes send start/stop signal to display
		return				; No do nothing

What is an OP (apart from being me)?

Nigel; I will do as you say over the weekend.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top