Help/opinions please on a possible noise source in circuit.

PaulRB

Senior Member
All,

Having a problem with an new version of an old project. Here's the link, with pictures, code & schematic: http://www.picaxeforum.co.uk/showthread.php?19178-My-first-PICAXE-project-Chicken-lights-Greenhouse-watering&p=229434&viewfull=1#post229434

The problem is this: sometimes the lights are getting activated for no apparent reason. I can't detect a pattern to when it happens, so it could be noise. Given how the code works, there are two triggers to switch the lights on:

One is the voltage from the LDR, i.e. the light level. But I don't think that can be the problem, because the hardware and software are identical in this respect to the old version of the circuit, and there was no problem with that. There is some "hysteresis" built into the code to prevent re-triggering due to small changes in the light level.

The other is the push switch. This part of the circuit has changed compared to the previous version. It is now connected between pin C.3 on the 08m2 and 0V. The Pullup command replaces the series resistor on the old version of the circuit.

My suspicions centre around the switch: I have had trouble using pin C.3 before, which is the input-only pin on 08m2. It does seem to be more suceptible to noise. Also, the internal pullup resistors are sometimes described as "weak" pullups, not certain exactly what this means but suspect it means the equivalent external resistor could have a very high value - M-Ohms?

2 solutions I can though of, assuming my suspicions are correct:

1) set Pin c.3 to Schmitt Trigger. Am I correct, reading the manuals, this is not possible on 08M2, even though it can be done on other M2 series?
2) abandon internal pullup and attach 10K between pin C.3 and 5V.

Thoughts/advice please?

Paul
 

boriz

Senior Member
Definitely use external pull-up for button. Should also prolly have a pull-down (maybe 100K) from the MOSFET gate to ground. Then use a multimeter or better still a 'scope to see what's happening.
 

PaulRB

Senior Member
Thanks broiz, will try that external pullup.

I don't think there is a problem driving the fet's gate: when the light switch on unexpectedly, they don't switch on suddenly, it does look like the "fadeUp" subroutine is being executed.
 

boriz

Senior Member
When I breadboard a new Picaxe project, the first thing I put on the board after the Picaxe and download circuit is an LED on out0 (the serial pin). Then I burn a simple LED flash program. The LED flickers during the serial coms and flashes when the program starts. Now I know the Picaxe and download circuit are functioning correctly. It's my debug LED.

I suggest you do something similar. Toggle the LED at some crucial juncture, or the start of each procedure or something like that. I don't use the simulator much, but I use the debug LED all the time. Helps me a lot.
 

hippy

Ex-Staff (retired)
Definitely use external pull-up for button.
It's not usually required if internal pull-up is used but is worth trying and particularly if the button is on a length of wire and may be prone to pick-up noise.

A bit of code that just looks for pin 3 going high and indicates that may be worth running and leaving to see if pin 3 is activating when it shouldn't.
 
Top