piwebcam / PiWebcam

Turn a Raspberry Pi into a fully-featured and dummy-proof webcam
https://piwebcam.github.io
52 stars 13 forks source link

IR Cut Filter On/Off is Backwards? #57

Open verticon opened 4 months ago

verticon commented 4 months ago

Hello Folks. I am in the process of verifying that my build of this project: https://www.instructables.com/id/Fully-featured-Outdoor-Security-Camera-Based-on-Ra/ is correct. Regarding the IR Cut Filter; something is awry somewhere (hopefully not in my brain).

First, my understanding:

1) In day mode the cut filter should be on (block the infrared). In night mode the cut filter should be off (let the infrared through).

2) BCM pin 20 should be pulsed to activate the cut filter. BCM pin 16 should be pulsed to deactivate the cut filter.

Next my experience:

1) Examining PiWebcam.sh's night_mode function reveals that pin 20 (IR_FILTER_ON_PIN) is pulsed when entering night mode; pin 16 (IR_FILTER_OFF_PIN) is pulsed when leaving night mode. Huh? That is backwards, yes?

2) From a command line (ssh to raspberry) I can issue the command:
    a. "gpio -g write 16 1; sleep 0.5; gpio -g write 16 0" to pulse pin 16 (turn the cut filter off)
    b. "gpio -g write 20 1; sleep 0.5; gpio -g write 20 0"  to pulse pin 20 (turn the cut filter on).

3) From the web UI I can observe the camera (Camera -> View) in day mode while I issue the gpio pulse commands from the ssh terminal. I find that there is more pink in the image when I turn the filter on and that there is less pink in the image when I turn the filter off. Again, backwards.

Finally:

1) My experience in 3) indicates that the night_mode function will perform correctly even though it appears to be incorrectly coded.

2) My conclusion: Something in the wiring from gpio -> H Bridge -> cut filter is backwards and the night_mode function has been jiggered to compensate.

Thoughts?

user2684 commented 4 months ago

Hi! It has been a while since last time I worked on this project, but I remember the behavior I got was the expected one when testing it. Of course trying it at night should give you the final confirmation. But it could be also that something is not coded correctly. Thanks