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 module 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 board supports relays, all four can be switched from the I2CStepper page and Lua. In Beer mode, relay 1 of the working board serves the wort transfer pump; the user assigns the other relays.
Boards are searched for once when Samovar boots; discover new boards or address changes with "Rescan I2C devices" («Пересканировать I2C-устройства») in the settings. If at least one board is available, the "I2CStepper" button appears on the main page of every mode. The control page sets speed (stirrer: rpm, pump: l/h), direction and pump volume in ml; it provides start, stop and four relays. Board settings are stored in the Nano and edited under Settings → I2CStepper («Настройки → I2CStepper»). Open calibration of the selected external pump with "External pump calibration" («Калибровка внешнего насоса»). See the I2CStepper page in the operating manual for the detailed procedure.
 
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 flashing the Nano, check the address, mode and pump calibration.
 

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.
The external sensor connects to D6; by default the input has a pull-up and is active when connected to GND. It can stop any active operation. In Pump mode, with sensor pause enabled, pumping resumes after the configured delay following sensor release. If the Nano receives no communication heartbeat from Samovar for more than 10 seconds during remote control, it stops the motor and turns off all relays; the local menu becomes available without separate encoder confirmation.
 
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.