Pulse logic input

From Let's Control It
Jump to navigation Jump to search


Just as the ESP may be used with specific pulse counters it may also be used with any generic pulse based unit as long as the pulses are not giving to high voltages. Two examples in this example is a generic water flow sensor and a pulse wheel. Other, more specific, examples is the TCR5000 and LJ12A3.


Anything that gives a pulse within reasonable voltage levels may be used as input. Please refer to this page for pulse levels that are higher than 3.3V (or 5V for some ESP units)

Flow sensor

A generic 5V flow sensor that gives a pulse each complete revolution. You may have to measure what each revolution/pulse means in volume. The one used in this example is called YF-S401, a 5V unit, which is great to use for watering systems or in this case to measure a drainage system.
Flow sensor pulse.jpg Flow sensor in action.jpg

Pulse wheel, rotary encoders (as simple pulse inputs)

In general: A pulse wheel (generally 100 pulses per rotation) could also work as a input for pulses, good pulse wheels will give the direction of the rotation on different output ports. That means that you will have to use 2 GPIO if you you plan to use that feature (see guide here). Some pulse wheels have 4 outputs, for direction and (for example) 100 pulses per rotation and 25 pulses per rotation. A pulse wheel may be good to use in conjunction with a stepper motor. Smaller pulse wheels are called rotary encoders or digital potentiometers and work pretty much as a real pulse wheel except that they generally do not give the resolution per rotation as a pulse wheel does. They are a lot cheaper though and some also work as a button making them great to use for human interaction with GUI.
Pulse wheel.jpg Rotary encoder 002.jpg

In the context of using a 5V pulse wheel or 3.3V rotary encoder as a simple pulse input you may only use 1 GPIO and have some other input device tell in which direction the rotation is. A possible example which we will try to cover as soon as possible is to have a rotary encoder with a wheel or cog wheel which is rotated by the wire/chain of a garage door opener (see picture below for simple example). Another example maybe to use the encoder in conjunction with a simple electric motor which opens the curtains. The polarity of the motor gives the direction of the movement.
Rotary encoder simple example.jpg

This is just a proof of concept. You would connect the (cog) wheel to the rotary encoder and when the wire/chain is moving the wheel is turned and the encoder would turn as well giving you a simple pulse generator telling you in what position the (for example) garage door or curtain is at.

ESP Easy

Within the ESPeasy devices you will have to set up the device using the Pulse Counter type. In the example that follows we use a flow sensor to measure the amount of water that flows out of a system. The delay is set to "5" which equals to five seconds. The GPIO is connected to the pulse output signal cable (in the flow sensor example this cable is yellow). And we have to use the "Debounce Time" in order to filter out some false signals. In this case the debounce is set to 100mSec, please observe that lower debounce time may completely flood your ESP so start from at least 500mSec and work your way down to a good level.
Pulse logic input Setup.PNG

In this example we converted the pulses to mL after measuring 1.5L and divided that volume with the numbers of pulses to reach that volume. This left us with a value of 0.65mL per pulse. Thus the formula for the value was set to "%value%*0.65".

If you use a pulse wheel or rotary encoder you could turn the pulses into speed by calculating the wheel circumference times the number of pulses and dived that with the time. I.e. if the wheel is 15cm in circumference and during the examples 5 second time period is given 10 pulses (for simplicity we say that the rotary encoder gives 1 pulse per rotation) the speed would equal to 30cm/second! So with only one GPIO you could still get the position (15cm * 10 pulses = 150cm or %value%*Circumference) and the speed (15cm * 10 pulses / 5 seconds = 30cm/seconds or %value%*Circumference/(Delay*PulsesPerRotation)). More on circumference is found here.

With the some older versions you need to REBOOT the ESP Easy to get the show running. With later versions we have restricted possible task to have the pulse counter to TASK 1 - 4. This is done to make less interrupts in the polling cycle.

That should be all.