Download PDF
      SAMOVAR                                  
×
Menu

I2CStepper

 
I2CStepper is a standalone module based on an Arduino Nano with its own stepper motor, four relays, an external sensor, a 16×2 LCD and an encoder. The current firmware uses the I2C v3 protocol.
The module can be used as a standalone device. It can be controlled on its own using the menu on the 16x2 LCD screen and the encoder, or when connected to Samovar.
The expander is connected to Samovar over the I2C bus with four wires (like an LCD screen). Samovar detects that the expander is connected and can control it.
 
Samovar supports up to ten boards with addresses 1–10: an odd address is a stirrer, an even address is a pump/filling board. The boards with the lowest address of each type are the ones used. The stirrer works by speed, run time and pause; the pump works in ml/h; the filling mode works by a set volume and speed.
If the device reports relay support, the first relay can be switched from the I2CStepper page, and all four from Lua. The purpose of the relays is set by the user: the Samovar firmware does not define it.
The modules are searched for on the bus when Samovar boots. If a module is found, an "I2CStepper" tab appears on the pages of the Distillation («Дистилляция»), Wash column («Бражная колонна») and Beer («Пиво») modes; it opens the board's manual control page: speed, number of steps, start and stop, relay 1. The board's own settings (address, mode, speed, stirrer run time and pause, pump feed, filling volume and speed, steps per 1 ml) are edited on the Settings («Настройки») → "I2CStepper" tab and are stored in the Nano's memory. External pump calibration is started with the "External pump calibration" («Калибровка внешнего насоса») button on the I2CStepper page; the result is written to the board's "Steps/ml" («Шагов/мл») field.
 
Wiring diagram
Pinout for connecting peripherals:
 
// Pins for I2C Master - connecting the screen and potentially other devices
// SDA_PIN 0 //A0
// SCL_PIN 2 //D2
 
// Pins for I2C Slave - communication with Samovar
// SDA_PIN A4
// SCL_PIN A5
 
// Pins for the stepper motor
#define STEPPER_STEP 3
#define STEPPER_DIR 4
#define STEPPER_EN 5
 
//Pins for the relays
#define MIXER_PUMP_PIN 13 // RELE_PIN1
#define RELE_PIN2 10      // RELE_PIN2
#define RELE_PIN3 11      // RELE_PIN3
#define RELE_PIN4 12      // RELE_PIN4
 
// Pins for the encoder
#define ENC_CLK 7 //S2
#define ENC_DT 8  //S1
#define ENC_SW 9  //KEY
 
Tip.
If you plan to use the expander as a separate device in its own enclosure, it makes sense to connect it to Samovar with a USB A-B cable (computer - printer). The module's +/- 5 volt power and the two I2C bus signals are taken directly from Samovar's display. A USB-B connector is mounted on the Samovar enclosure.
  A USB-A connector is mounted on the expander enclosure.
This way, when connected to Samovar, the Arduino Nano gets both power and the I2C bus at once. When used as a standalone device, a separate power supply is used instead of Samovar, for example a phone charger.
If you use a built-in power supply, a USB-B connector is placed on the PSU output and the same USB A-B cable is used to deliver power, which rules out accidentally feeding +5 volts into Samovar
.
 
Peripherals.
 
The relay block is used at 5 volts, preferably controlled through optocouplers. 12-volt relays can also be used, with a connection made on the same principle as in Samovar
 
Any pump can be used: a DC motor, or an AC single-phase or three-phase one. This is because the pump motor is started and stopped through a relay and then through any power switch: a contactor or a solid-state relay. For small volumes you can look at the 15RM magnetic drive pump. Stainless steel, quiet, with good output.
 
Any bipolar stepper motor can be used for the stirrer or the NBK (continuous wash column), provided it has enough power and torque. Nema 23 with a suitable driver is recommended.
 
The current Arduino Nano firmware and the description of the v3 protocol are in the I2CStepper repository. After switching to the v3 protocol, check the board address, the mode and the "Steps/ml" («Шагов/мл») calibration: when the version changes, the EEPROM structure is initialized anew.
 

Current modes:
— Mixer: stirrer, revolutions per minute, run time, pause, reverse after the pause and soft start.
— Pump: continuous feed in ml/h with an optional pause.
— Fill: metered filling of a set volume in ml.
An external sensor can stop the pump or pause it. If I2C hangs, the module itself stops the stepper and turns off the relays; after recovery, confirmation with the encoder is required.
 
Warning.
The Lua function set_stepper_target(spd, direction, target) controls only the I2CStepper pump (the working board with an even address): speed, direction and number of steps. If the pump does not respond on the bus, the function returns 0; it does not control Samovar's built-in stepper.
--set_stepper_target(spd, direction, target) //spd - speed in steps per second,
direction - forward or reverse direction,
target - number of steps
When spd = 0 the stepper motor is stopped.
Example
set_stepper_target(950, 0, 1000)
The example sets speed 950, direction 0 and a move of 1000 steps.