Dosing peristaltic pump (PWM SSR), HX711 scale and an FSM

Finite state machine, DC motor variable speed (PWM, solid state relay), software timer objects, HX711 scale and WawiLib. Tutorial value!
Hardware Components
OOTDTY 2 Channel SSR Solid State Relay High Lever Trigger 5A 5v12v For Uno R3 APR11_10
X 1
DC Small Dosing Pump 3V 6V 12V 24V Micro Self priming Mute Mini Peristaltic Liquid
X 1
Software Apps and online services


Original Post :



This application shows a dosing application using 2 peristaltic pumps (PWM driven via solid state relays), 1 digital weight transducer (using a HX711), a LED traffic light and an Arduino Mega2560 with an Ethernet shield.

First the vessel on the scale is filled in 15 ml steps up to 100ml and then it is emptied. Commands to start and stop are issued via Ethernet using WawiLib to read and write sketch variables. The state changes of the state machine are reflected to the output window of WawiLib.

There are 3 movies documenting the application:

Application demonstration.

The hardware explained (SSR and flywheel diode concepts)

Software with WawiLib variable access, C++ timer objects, PWM Solid State Relay and FSM

Technologies used and explained in detail:

// Finite state machine code expamle:
   case FsmState::STEP3_WAIT_CMD_FILL:    
     if (cmdFill) 

Arduino “millis()” based software timers (as a C++ object in a separate file in the sketch). The use is different from what you normally see (millis() is encapsulated in the C++ object and the object is added in a separate file to the ide). All is explained step by step in the.pdf that can be downloaded from

// blinking 2 timers at the same time with variable time period:
#include "WawiTimer.h"
// blinker bit helper timers(software timers):
WawiTimer tBlink250; // 250 ms on
WawiTimer tBlink500; // 500 ms
// blinking bits that toggle:
bool blink250;
bool blink500;
// create blinkbits:
void Loop()
  if (tBlink250.isZero())
      blink250 = !blink250;
      blink500 = !blink500;
   tBlink250.loop(); // 250 ms 
   tBlink500.loop(); // 500 ms

Forget about millis()! Add your C++ timer object that is counts down so your loop is not interrupted: the only thing you need to do is add 2 files to your sketch! (The documentation explains in detail how.)

– PWM (pulse width modulation) via SSR (solid state relay) on a DC motor.

Pulse width modulation is a technique used to control (e.g.) the speed of an DC motor. Some of the Arduino outputs can switch on and of very fast (hardware based) at multiple kHz. If you use this function to regulate the current to a DC motor you can make it run at variable speed. The movie and documents explain in detail how to do this.

A DC motor contains a coil. As a coil is an inductance. You must make sure that its current flow is not interrupted when the relay opens. A diode is the ideal component to do this. This tutorial explains the concept of a flywheel diode in detail.

– The AppNotePeriPump.pdf detailed tutorial can be downloaded from explaining the details step by step. Go to the documentation page of the Sylvester Solutions website.

Sylvester solutions site.

If you do not know how to program an automation task properly (i.e. without delay statements). Look at this tutorial and you will learn a lot. All concepts are in detail explained in the pdf and the.ino source code is also included.

The code can be used as a framework for many other applications as it is structured like the pro’s do.

Have fun and learn!

SSR power section
Fig 3 imduyrwbzz


Please Login to comment
Notify of
Reusable S/W