620Views5Replies

Author Options:

PICAXE Electronic interference? Answered

<Edit>


I have solved the problem by making two changes.

Firstly, a 22k resistor was put from I/O 2 to ground.

Secondly, I had to modify the program to be the following, and accept any value as an input as long as it was not 0. The new program is shown below:

main:low 1 &aposdischarge led on Pin 1input 2 &aposmake pin 2 an inputreadadc 2, b1 &aposread pin 2 using ADCif b1 > 0 then flash goto main &aposloop back roundflash:&aposled sequencehigh 1pause 100low 1goto main

</Edit>


I've been having a bit of an odd problem...

I'm trying to use a PICAXE 08M with a touch input, so a user touches a wire or bridges 2 wires and the uC responds based on the program, at the moment, turns an LED on.

Now, Initially, I've tried a few things, until sort of by accident I noticed that using the program I was, the LED turned on by touching the input pin of the PICAXE, with nothing attached to it except one short piece of wire. I know the human body has certain capacitive qualities, but I wouldn't have thought it would be enough for this. The LED started turning on when I got close to the breadboard it was on, never mind the wire.

I tried moving the board, while I had my finger on the wire, and found that when I got a certain distance from my laptop (About 1 ft or so) the LED would go out, and not come on again. Strangely, it does the same when my laptop is turned off!

So what I was wondering is, what could my laptop be doing that enables the PICAXE to get an input from seemingly nothing? Could it be some sort of EM field from it? Incidentally, the same thing happens close to my TV.

The code i'm using is below.
main:low 1 &aposdischarge led on Pin 1input 2 &aposmake pin 2 an inputreadadc 2, b1 &aposread pin 2 using ADCif b1 < 40 then flash goto main &aposloop back roundflash:&aposled sequencehigh 1pause 100low 1goto main

Discussions

0
None
NachoMahma

10 years ago

. Computers generate a lot of electrical noise. . Keep all wiring as short as possible and reduce the gain of any amplifiers in the sensor circuit. Might help to mount in metal hobby box. . I've never programmed a PIC, but it looks to me as if adjusting "if b1 < 40" might help. Not sure if the number needs to be bigger of smaller.

0
None
whatsisfaceNachoMahma

Reply 10 years ago

I think I may have cracked it. Generally, the inputs for a PICAXE are usually connected to +V and then to the pin, but the pin is also grounded by a resistor, whichI have not done. Now the interference seems to have gone away with a 22k from I/O 2 to ground.

0
None
NachoMahmawhatsisface

Reply 10 years ago

. It may help to ground all unused inputs. Check the docs to make sure it's safe to do so. . Just for my curiosity, does adjusting b1 < 40 have more of an effect now?

0
None
whatsisfaceNachoMahma

Reply 10 years ago

Yes, the new code above works perfectly, it seems the 40 value was way off, the resistance of the body is so high I need to use any values greater than 0 as an input.

0
None
whatsisfaceNachoMahma

Reply 10 years ago

Adjusting that value does have an effect, but when I change it it doesn't seem to do much. I have noticed though, that although the program runs when the programming lead is plugged into the board, it is vastly more sensitive, so i'll have a go at reducing wire lengths. Thanks!