....but it works of the sensor is exposed to quickly changing light levels....On the contrary. I'd say that suggests hardware working OK and a software error! I'll try to spend some time looking at your code but probably not soon.
....but it works of the sensor is exposed to quickly changing light levels....On the contrary. I'd say that suggests hardware working OK and a software error! I'll try to spend some time looking at your code but probably not soon.
sort of defeats the object of using the PIC.... ?...no.....?Re post #26:
.........why not just use your LDR with whatever resistance works, and run it through a CA3140 configured as a voltage follower?
er, no, smacked wrists !.......still a bit rusty on what & where to enter to check this type of thingI take it you haven't done any debug/sertxd 'test prints' in situ to check the route your code takes?
It may help.
David,..... remind me if you will where this lives...I have seen it but cannot find it !
Thanks
Nope, didn't make any difference, neither did adding a 0.1uF capacitor ....back to the drawing board I guess....Davidwf - Testing the ADC input every 5 mins? Of course. That probably is the answer!!
Yes I have....but it didn't make any difference at all - apart from altering the trigger threshold of courseBefore you commit to buying a different sensor, have you actually tried changing R4 to say 47k and putting 100nF on the ADC input?
On the bench it functions correctly - i.e. with rapidly changing light levels it switches OK, in situ with slowly changing levels it does not switch at all.Can you pls restate the problem.
These are the levels returned by debug - with readadc10 they are now around 200 at the required switch on and 400 at the required switch off light levels....BUT I have noticed that under a constant light level they very considerably, e.g. up to 300+ and down to 100the required levels are around 10 to 20
.......with a constant light level, the voltage is constant as you would expect but the ADC is changing a LOT (as above)If you put an LDR in series with a resistor and measure the point at which they join
In light = 50 ohms, in dark >2meg ohm, at the required trigger level approx 80K ohmCan you take an LDR, not connected to any circuit, and measure the resistance
No it is terminated with a 1K to +5V, I just showed the relevant parts of the cct......on the original circuit no reset circuit is shown. It could also be randomly resetting if that pin is floating.
Yes it did, absolutely stable....so with a bit more experimenting I found that a 100uF cap across the LDR (i.e. +5v to ADC input pin) also gave a dead stable reading - 10uF, 47uF weren't enough .....I then increased the source resistor to 82K (actually it was OK up to 220K but the LDR is about 80K at the required light level) and the ADC value is around 500 which gives a bit more scope for adjustment.Get a 10k pot and put it on your ADC input. Does that give you a stable reading?
Yes, the op amp cct. seems to be OK - with a pot replacing the LDR it tracks the input voltage as it should....Get back to basics and just write a few lines to read the ADC and experiment with things. Try a pot AS SAID BY BB (perfectly visible and we have all read it) and then your LDR circuit and then a buffered LDR circuit. You've got something wrong somewhere.
I wouldn't have been surprised by fluctuating numbers from an LDR as a high impedance source - I got similar behaviour when i tried it before. But with an op amp buffer? That sounds odd assuming your op-amp circuit is OK of course.
I agree it shouldn't be required but......I think you were meant to put the cap between ADC & Gnd/0V. It then acts as a reservoir to dump into the ADC tiddly cap.
But an explanation of this is tricky as I don't know the ins & outs of the READADC firmware. And that makes a difference with respect to the ADC cap charging times.
Shouldn't be necessary at all with op-amp buffering, but then I don't know how you wired your op-amp. Odd.
Yes that's right - ACROSS the LDR, haven't tried it LDR to 0V - too late to try it tonight, maybe tomorrow, curtain motor might wake the Mrs !!!Have I got this right, you put the cap between 5v and the ADC input?
Agree but like I said, the supply voltage is rock steadyIt should go between 0v and the input. Connecting to 5v will reflect any supply fluctuations straight into the ADC
- which is what we suspected originallyIf the LDR is 80k at the required level and your tests were OK up 220k using a resistor, then that confirms that the underlying issue is NOT impedance related.
Yes but it only takes about 5 seconds to settle - no problem with that, and the reading remains rock solid after settlingPutting 100uF on the ADC input is a MASSIVE slug
It is about 2 feet - same as "on the bench", I agree with your thoughts but even with it directly onto the input terminals it made no difference.In your "real" setup, have you put the LDR out on a long lead from the PICAXE?
correct...when the level falls below 500 it should - after a delay of 20 mins - turn the lights on [lines 75 to 86] (o/p 7) and close the curtains (o/p 1), likewise when it rises above 700 the curtains should open [lines 108 to 124] listing attachedYou said "On the bench it functions correctly - i.e. with rapidly changing light levels it switches OK, in situ with slowly changing levels it does not switch at all."
It doesn't switch. Ie - is it reading the correct value but not turning something on? .
Er, no....smacked wrists....I still can't quite get my head around that procedure - sorry...perhaps an example or 2 ?Still haven't tried little Sertxd messages at the start of each subroutine?
So you can follow your code on the Terminal screen?
How do you know what your code is doing?
......it SHOULD (I think) be trapped by the "still dark" / "final dark" & "still light" / "final light" functions that I added just for that purpose........ One thing which concerns me is what happens when it is seen as dark and then goes light again before 1 minute has elapsed. ....