Translate

Saturday, February 12, 2022

Bathroom fan controller - tests and refinements

 


After building a prototype some more considerations did come up from testing and installation planning.





Safety

Safety is paramount especially in a bathroom.
This why I did built a PCB even for the prototype rather than do it point-to-point in a breadboard.

Still there are considerations like fire hazard when playing with current in a bathroom.
Because of that one of the requirement is to use an approved electric box to contain the circuit since they are flame retardant,
As additional measure the original switch used to turn on/off manually the fan, become the main power switch.
In case of problems, or just for maintenance, is possible to remove totally power to the entire circuit.


Control

Event/Action table

  • Humidity > upper threshold (above ~65%)
    • Fan ON
  • Humidity < lower threshold (below ~50%)
    • Fan OFF
  • Humidity <> upper/lower threshold 
    • Fan untouched
  • Pushbutton pressed
    • If FAN OFF
      • Turn Fan ON for about 15 minutes
    • If FAN ON
      • Turn Fan OFF

The new circuit

A new circuit and PCB is arrived.
Compared with the older one currently in the box in the wall, has a trimmer to offset the humidity measurement and an extra pad to solder the live wires.

Of course a new PCB is created 



Testing 

The test bench

In order to test and do measurements, a test bench was built with another unit assembled (I always order more than 1 PCB).
Beside, the assembled PCB is the new one, compared with the older one currently in the box in the wall, has a trimmer to offset the humidity measurement.



Tests to execute


In order to catch problem and be sure the circuit act as designed, there are a series of tests to perform with an expected result.

Test 1 - humidity start/stop FAN

Setting
  • Power up the circuit
  • Breath over the humidity sensor until the fan start
Execution
  • the FAN should start when the humidity measurement is above the upper marker
  • the FAN should stop when the humidity measurement is below the lower marker

Test 2 - manual start/stop FAN (before timer)

Setting
  • Power up the circuit
Execution
  • press the pushbutton - when release it :
    • the FAN should start 
  • press again the pushbutton - when release it :
    • the FAN should stop 

Test 3 - manual start FAN - stop on timer

Setting
  • Power up the circuit
Execution
  • press the pushbutton - when release it :
    • the FAN should start 
  • after more or less 15 minutes the FAN should stop 

Problems

This section collects "accidents" and/or suggestions to improve the circuit.

Micro freeze

  • HW version : 1.0
  • SW version : 1.0
  • Event/problem description : pushed the button to activate the Fan, Fan turned ON but then circuit frozen.
    Had to remove power to reset it
  • Possible diagnose : having the wiring bringing power to the Fan very close to the circuit, is possible that when power is applied to the Fan, spikes are generated along the line (induction) and disrupting the MCU normal work.
    Also the antibump SW is not working very well with that specific pushbutton, creating sometime a stream of ON/OFF commands to the rele'.
  • Possible solution 
    • implement a more robust anti-bump algorithm, allowing more time before to switch the state
    • implement a watchdog in order to restart the code in case of freezing/crashing due to spikes
    • insert filter capacitors to the micro power supply
  • Notes : first installation/activation of the circuit done January 29, 2022
  • HW version : 1.0
  • SW version : 1.0
  • Event/problem description : circuit frozen after the Fan was activated by high humidity condition. Not sure when the freeze happened
    Had to remove power to reset it
  • Possible diagnose : as before, seems that when the motor is running spikes or EMI are generated and if reach the Trinket, freeze it.
  • Possible solution 
    • implement a more robust anti-bump algorithm, allowing more time before to switch the state
    • implement a watchdog in order to restart the code in case of freezing/crashing due to spikes
    • insert filter capacitors to the micro power supply
  • Notes : first installation/activation of the circuit done January 29, 2022
Unable to read the sensor
  • HW version : 1.1
  • SW version : 1.1
  • Event/problem description : after the motor starts or stop, the Trinket is unable to read the sensor. Had to remove power to reset it or at least remove the power to the sensor
  • Possible diagnose : as before, seems that when the motor is running spikes or EMI are generated and if reach the sensor, it stops to work properly
  • Possible solution 
    • instead to keep it powered all the time, control the power with a signal
  • Notes : test bench - it is possible can happens also on the already mounted circuit on the bathroom

The problems

As pointed out in the problem section above, I did notice  random problems when the motor starts or stops.
Using the test bench I was able to actually identify the problem, related to the power supply.
Depending when the motor starts, probably in relation with the phase, a spike (about 200 uS) is generated and propagated to the AC/DC step-down converter (diymore  AC/DC 5V).
Probably the spike is the feedback on the DC from a dropping of the 110 V when the motor starts.

The 200 us initial spike (seen over the DC Line in this case)

When this happens, due the spike, the AC/DC step-down converter drops the power from 5 V to 2 V for at least 50 ms !!

The loss of power after the initial spike (50 ms)


Clearly this is something the Trinket doesn't like and in fact triggers the watchdog now present in the code.
Without the watchdog, the effect is to have the Trinket frozen or, very rarely, reset.

So clearly the AC/DC converter is not really good.
Did try another one, a Delinx AC/DC, same characteristics, and already the improvement is big !
No more voltage dropping, it remains only a 6 to 14 V peak to peak spike sometime, it can still reset the MCU or cause problems to read the sensor but it doesn't happens often !

The spike on Delinx when the motor starts. Much better than the voltage drop of the diymore.
Sometime the spike goes well below the 5V, for about 14 V peak to peak


Adding a capacitor (.01 uF) helps little bit but want to try with a diode suppressor before to close the problem.

Enhancements


Because the freezing problem it is a good idea to enable a watchdog to restart the system when freeze.
An 8 seconds watchdog is now active in the code.

Also a better anti-bump algorithm for the push-button is now in place. 

In future versions, since a new PCB is required, would be nice to have :
  • a TRIAC instead a rele'
  • embed the Delinx in the PCB
  • a better way than the trimmer to select offset
  • cover the circuit with a protective box to avoid to touch parts under 110V

Resources







No comments:

Post a Comment