Control Stepper Motor 28BYJ-48 with HM-LC-Sw4-WM

Hi all

I’m thinking about to control a Stepper Motor 28BYJ-48 with a Homematic HM-LC-Sw4-WM (as I already have a CCU2 implemented in OH2).

The easiest way for me would be to control the 4 outputs in a rule. So, I have to implement something like that:


(it’s in german)

Finally I have to follow the steps according this table an control the outputs on the HM-LC-Sw4-WM

image

Can someone help me how to write this kind of rule? Or at least a hint how to start?

Thanks
Michael

What are you planning on using the motor for?

I’m not sure that controlling each step over an 868MHz RF link via a CCU2 will give you anything smooth or with enough speed.

I think something better would be to use an Arduino to control the steps and step frequency and link openHAB to the Arduino to control the direction and on/off of the stepper motor.

At the end I would like to change the temperature on my boiler. So, it’s not really time critical and I need only a range of about 90 degrees.

Without actually giving you real rules, you probably need to do something like the following but please note that this is only thoughts put on paper. You’d need to convert it to real items and rules:

You’ll need to know how many steps of the motor are needed to change the dial by 1’C. This would be the steps variable.
You’ll need a currentTemp variable.

rule “Stepper motor control”

if Item TemperatureSet changed

then
if temperatureIncrease {
if temperatureIncrease + currentTemp >Max temp
{
forwardsteps = steps * degrees
Loop
for number = 1 to forwardsteps
[this is one step and will depend on type of motor:

sendCommand(coil1, OFF)
sendCommand(coil4, ON) *
sleep 500
sendCommand(coil3, ON)
sleep 500
sendCommand(coil4, OFF)
sleep 500
sendCommand(coil2, ON)
sleep 500
sendCommand(coil3, OFF)
sleep 500
sendCommand(coil1, ON)
sleep 500
sendCommand(coil2, OFF)
sleep 500
sendCommand(coil4, ON)
sleep 500
]
Next in loop

sendCommand(coil4, OFF)
sendCommand(coil1, OFF)

}}

Same stuff for reverse direction:

 if temperatureDecrease {

if currentTemp - temperatureDecrease + currentTemp >Min temp
{
forwardsteps = steps * degrees
Loop
[ stuff in loop ]

Next in loop

[ turn off any ON coils ]
}}
end

  • Coil Items would communicate with CCU2 and hence relays with MQTT.

In practice, I’d have no idea whether this would work and personally I’d do it another way.