Door control not working propperly

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
xxx_turbo_xxx
Normal user
Posts: 8
Joined: 12 May 2021, 17:01

Door control not working propperly

#1 Post by xxx_turbo_xxx » 15 Jun 2021, 08:32

Hi everybody,

I have a problem which is driving me crazy! I have a "chicken house" with an automated door. It is pretty simple but for whatever reason it does noct work reliable!
Huehnerklappe_Schema.JPG
Huehnerklappe_Schema.JPG (55.51 KiB) Viewed 3351 times
Code:

Code: Select all

// 0=aktiv, 1=inaktiv

On System#Boot do        
   GPIO,3,1                   // G3:  Taster_Stopp aus
   GPIO,12,1                  // G12: Taster_auf aus
   GPIO,13,1                  // G13: Taster_zu aus
   GPIO,14,1                  // G14: Reed_oben aus
   GPIO,2,1                   // G2:  Reed_unten aus
Endon


On Taster_auf#State=0 Do
  if [Reed_oben#State]=0
     WemosMotorShieldCMD,0,Brake
  else
     WemosMotorShieldCMD,0,Forward,50
  endif
EndOn


On Taster_zu#State=0 Do
  if [Reed_unten#State]=0
     WemosMotorShieldCMD,0,Brake
  else
     WemosMotorShieldCMD,0,Backward,30
EndOn


On Clock#Time=All,%sunrise% do // Klappe auf bei Sonnenaufgang
  if [Reed_oben#State]=0
     WemosMotorShieldCMD,0,Brake
  else
     WemosMotorShieldCMD,0,Forward,50
  endif
EndOn


On Clock#Time=All,21:30 do // Klappe zu bei 21:30
  if [Reed_unten#State]=0
     WemosMotorShieldCMD,0,Brake
  else
     WemosMotorShieldCMD,0,Backward,30
EndOn


On Taster_Stopp#State=0 Do
     WemosMotorShieldCMD,0,Brake
EndOn


On Reed_oben#State=0 Do
     WemosMotorShieldCMD,0,Brake
EndOn


On Reed_unten#State=0 Do
     WemosMotorShieldCMD,0,Brake
EndOn



Huehnerklappe_Hardware.JPG
Huehnerklappe_Hardware.JPG (155.34 KiB) Viewed 3351 times
Reed.JPG
Reed.JPG (36.88 KiB) Viewed 3351 times
It looks likt that the reed sensor starts to toggle from 0 to 1 at one stage and this leads the system to freeze/crash. No matter which butten I press then the system does not respond anymore! What di I miss in my code or is there some other error?

TD-er
Core team member
Posts: 5520
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Door control not working propperly

#2 Post by TD-er » 15 Jun 2021, 09:03

I don't see a time scale on your chart, so it is hard to tell in what order of magnitude the switching frequency is.

Reed switches are not only reacting to a magnetic field, but also to mechanical vibration.

Apart from mechanical vibration, you may also pick up noise via the wires to the switch.

A few things you can do to limit the effect of noise:
- Twist the wires, just like is done in pairs in UTP network cable
- Increase the current through the switch by lowering the pull-up resistor value.
- Add some capacitor over the GPIO pin and the ground

With a high resistance pull-up resistor, you don't need a lot of energy to switch the logic state due to noise.
I would suggest something like 1k - 3k3 so you have a current of 3 ... 1 mA at 3.3V

The wires act as an antenna. By twisting the wires you reduce the effect of noise as noise induced signal picked up on one part of the wire is inverted at the next twist.

Adding a small capacitor at the ESP side you introduce some kind of delay in the signal. Thus very short pulses cannot increase the voltage fast enough to switch states.
I would start with somethig like 10 nF, but the value also depends on the used pull-up resistor.

xxx_turbo_xxx
Normal user
Posts: 8
Joined: 12 May 2021, 17:01

Re: Door control not working propperly

#3 Post by xxx_turbo_xxx » 15 Jun 2021, 10:01

Thanks for your quick reply! Reading your answer I would guess the problem might be caused by the fact that I did not install any resistors (due to missing knowledge). My layout looks like this. I havent found the wemos motor shield in the library but I hope you can understand it anyway!
shematics.JPG
shematics.JPG (118.82 KiB) Viewed 3344 times
Here the komponents I use...
Taster.jpg
Taster.jpg (3.88 KiB) Viewed 3344 times
Reed_.jpg
Reed_.jpg (4.87 KiB) Viewed 3344 times
D1Z_MOTODRIVER_01.jpg
D1Z_MOTODRIVER_01.jpg (32.24 KiB) Viewed 3344 times
The buttons and reed contacts are configured like this...
Taster_config.JPG
Taster_config.JPG (74.69 KiB) Viewed 3344 times
Do I need to insert some restistors?

xxx_turbo_xxx
Normal user
Posts: 8
Joined: 12 May 2021, 17:01

Re: Door control not working propperly

#4 Post by xxx_turbo_xxx » 15 Jun 2021, 10:04

Forgot to mention that dte toggle between 0 and 1 from the reed is approximately within 15 zo 20 sec.

Micha_he
Normal user
Posts: 323
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Door control not working propperly

#5 Post by Micha_he » 15 Jun 2021, 10:19

First, I would enable the "Internal PullUp", if you didn't use extenal pullup's. Otherwise the signal floats somewhere between 0 and 3.3V.

In a second step, you can set the debounce time to about 100-300ms. If this not help and a little (~500ms) delay is exceptable, than you can set the "Longpress interval" to 500ms and use the longpress-events (10/11) to react in the rules.

TD-er
Core team member
Posts: 5520
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Door control not working propperly

#6 Post by TD-er » 15 Jun 2021, 10:25

You should not use GPIO-15 for this switch as that pin needs to be in a specific state during boot.
So better use other pins.

GPIO-0, -2 and -15 are special as they need a specific state at boot.

You can first try to check the "Internal PullUp" checkbox in the settings, but those only can pull up slightly as the internal pull-up resistors are between 50k - 80k
Better use 10k (or 12k), the value doesn't matter a lot.
But 12k is used on most ESP boards as typical pull-up for GPIO-0 and -2.
Maybe on longer cables you may need to get lower pull-up resistors, but let's start first with the 10k-ish ones.

xxx_turbo_xxx
Normal user
Posts: 8
Joined: 12 May 2021, 17:01

Re: Door control not working propperly

#7 Post by xxx_turbo_xxx » 16 Jun 2021, 07:46

So it looks like it stays stable either on 1 or on 0! Thanks for your help so far...

But...

I recognised a second issue. The controller hangs/crashes from time to time. I guess it is due to the fact that the WIFI connection is pretty poor. I'm sending the states via MQTT to a Raspi to log the data in a database. I have the impression that if the WIFI looses connection the system gets overloaded somehow which has the effect that the Wemos is not responding anymore neither on pressing button nor on reaching the device via HTTP.

How can I fix this?
Screenshot 2021-06-16 074546.png
Screenshot 2021-06-16 074546.png (20.08 KiB) Viewed 3320 times

Micha_he
Normal user
Posts: 323
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Door control not working propperly

#8 Post by Micha_he » 16 Jun 2021, 08:08

TDer works to stabilizate the WLAN connection.
The last versions from this month seems better in the WLAN-connecction.

Maybe you can test this version: https://github.com/letscontrolit/ESPEas ... s/67516566 (you need a Github-account) from 2021-06-14 or wait for the next release...

TD-er
Core team member
Posts: 5520
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Door control not working propperly

#9 Post by TD-er » 16 Jun 2021, 08:51

Or try this beta test for web flashing: https://td-er.nl/ESPEasy/
Builds are made yesterday.

xxx_turbo_xxx
Normal user
Posts: 8
Joined: 12 May 2021, 17:01

Re: Door control not working propperly

#10 Post by xxx_turbo_xxx » 16 Jun 2021, 10:19

I just flashed the recommended bin. Let's see if it helps

Thanks again for your quick reply!

xxx_turbo_xxx
Normal user
Posts: 8
Joined: 12 May 2021, 17:01

Re: Door control not working propperly

#11 Post by xxx_turbo_xxx » 17 Jun 2021, 08:06

Update: Don't want to be too excited already but until now it works flawlessly! Hope it will remain like this :D

Thanks guys!

TD-er
Core team member
Posts: 5520
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Door control not working propperly

#12 Post by TD-er » 17 Jun 2021, 08:25

Great, good to hear the WiFi part does seem to work better now.

chromo23
Normal user
Posts: 140
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Door control not working propperly

#13 Post by chromo23 » 23 Jun 2021, 11:06

I recognised a second issue. The controller hangs/crashes from time to time. I guess it is due to the fact that the WIFI connection is pretty poor. I'm sending the states via MQTT to a Raspi to log the data in a database. I have the impression that if the WIFI looses connection the system gets overloaded somehow which has the effect that the Wemos is not responding anymore neither on pressing button nor on reaching the device via HTTP.
I have exactly the same issue with my chicken door. :)
Great, good to hear the WiFi part does seem to work better now.
Thank you! I´ll give this a try too....

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests