Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 7th August 2007, 10:51 AM   (permalink)
New Member
jimfraseruk is on a distinguished road
Default My button works like magic, I only have to hover my finger over it

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.
Attached Images
File Type: jpg StartGateCircuit.JPG (10.5 KB, 64 views)
Attached Files
File Type: asm StartGate.asm (8.3 KB, 18 views)
jimfraseruk is offline   Reply With Quote
Old 7th August 2007, 11:03 AM   (permalink)
Experienced Member
 
Blog Entries: 1
Gayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of light
Default

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.
__________________
Gayan
Forum Supporter

Last edited by Gayan Soyza; 7th August 2007 at 11:05 AM.
Gayan Soyza is offline   Reply With Quote
Old 7th August 2007, 11:56 AM   (permalink)
New Member
jimfraseruk is on a distinguished road
Default

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.
jimfraseruk is offline   Reply With Quote
Old 7th August 2007, 01:07 PM   (permalink)
Experienced Member
 
philba is just really nicephilba is just really nicephilba is just really nice
Default

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.
philba is offline   Reply With Quote
Old 7th August 2007, 01:59 PM   (permalink)
Experienced Member
 
justDIY is a jewel in the roughjustDIY is a jewel in the rough
Default

make sure the pin is in digital mode too, as porta on most pics defaults to analog.
__________________
If you don't have a planet, what good are gold bars?

want to contact me directly? gmail gordonthree
check out my project website: http://projects.dimension-x.net
Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
justDIY is offline   Reply With Quote
Old 8th August 2007, 05:42 PM   (permalink)
Experienced Member
Mike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to all
Default

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...
Mike, K8LH is online now   Reply With Quote
Old 9th August 2007, 10:35 AM   (permalink)
New Member
jimfraseruk is on a distinguished road
Default

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 is offline   Reply With Quote
Old 9th August 2007, 10:56 AM   (permalink)
Experienced Member
 
Blog Entries: 1
Gayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of light
Default

Increase the pull up resister & see start with 18K,22K,27K etc....not too high then it will not detect.

If not change your input pin & see.
__________________
Gayan
Forum Supporter
Gayan Soyza is offline   Reply With Quote
Old 9th August 2007, 01:13 PM   (permalink)
New Member
jimfraseruk is on a distinguished road
Default

I have tried all pins both porta and b. Same story.
jimfraseruk is offline   Reply With Quote
Old 9th August 2007, 01:24 PM   (permalink)
Experienced Member
eng1 is a glorious beacon of lighteng1 is a glorious beacon of lighteng1 is a glorious beacon of lighteng1 is a glorious beacon of light
Default

Quote:
Originally Posted by jimfraseruk
If I use a long plastic object to press the switch it works fine. Other projects I have created with switches work fine.
Quote:
Originally Posted by jimfraseruk
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.
eng1 is offline   Reply With Quote
Old 9th August 2007, 08:03 PM   (permalink)
Experienced Member
 
justDIY is a jewel in the roughjustDIY is a jewel in the rough
Default

it sure sounds like your pull-up resistor isn't doing its job and the input gate is floating. A floating gate is very sensitive, exactly like you describe.

try a stronger pull-up, like 1000 ohms.
__________________
If you don't have a planet, what good are gold bars?

want to contact me directly? gmail gordonthree
check out my project website: http://projects.dimension-x.net
Favorite numbers:
09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
justDIY is offline   Reply With Quote
Old 9th August 2007, 10:24 PM   (permalink)
Experienced Member
Mike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to allMike, K8LH is a name known to all
Default

The 16F628A does have LVP capability. Have you tried grounding the PGM pin or turning off the LVP enable in the config fuses yet?
Mike, K8LH is online now   Reply With Quote
Old 10th August 2007, 03:24 AM   (permalink)
Experienced Member
 
philba is just really nicephilba is just really nicephilba is just really nice
Default

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.
philba is offline   Reply With Quote
Old 10th August 2007, 03:31 AM   (permalink)
Experienced Member
 
Blog Entries: 1
Gayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of lightGayan Soyza is a glorious beacon of light
Default

His circuit can use as a Proximity Detector.
He has done in a project board.
__________________
Gayan
Forum Supporter
Gayan Soyza is offline   Reply With Quote
Old 10th August 2007, 10:22 AM   (permalink)
New Member
jimfraseruk is on a distinguished road
Default

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 by jimfraseruk; 10th August 2007 at 10:26 AM.
jimfraseruk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
odd project, 1 button adds a light 1 button takes a light away with sound. KevinAlaska Electronic Projects Design/Ideas/Reviews 15 6th June 2007 04:38 AM
1 Hour Timer PIC 16F628A (Set Button) Suraj143 Micro Controllers 11 26th April 2007 03:54 AM
button midi keyboard jjjjjj General Electronics Chat 2 20th March 2006 04:10 PM
Push Button On/Off power to PIC eblc1388 Micro Controllers 8 17th February 2006 01:31 PM



All times are GMT. The time now is 11:22 PM.


Electronic Circuits  |  Radio Controlled
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.