How to automatise my stepper motor

  • I have four dosing stepper motor pump,
  • one sliding gate motor, which work with three trigger position
  1. stop
  2. forward and
  3. backward
    *some micro switches.
    *and three water tanks.

I want to dose chemicals to the three tanks. The chemicals need to put one by one with different volumes with each pump.
The sliding motor move to the first tank and the first dosing stepper motor pump a certain volume, then move to the second tank, then to the third one. And back again for the second dosing stepper motor to pump and so on.
I am using arduino Uno, TB6560 driver for the dosing stepper motor pump.

I am trying to use

#include <Stepper.h>
#include <AccelStepper.h>

#include <Stepper.h>

The Stepper library will not work with those step/dir type stepper drivers. The AccelStepper library will.

What is your question? What, specifically, do you want help with?

Thanks for reply. I am stuck.
I have two sketch and I can’t merge them.
The micro switch is to trigger the gate motor forward, stop and backward a sliding gate motor which will be used to travel upon three tank. Each time the gate motor will stop on a tank, the stepper dosing pumps start to pump for a certain time, then the gate motor move to another tank and repeat the pumping and after the third tank the gate motor return and stop to the initial position. to finish his job.

The stepper dosing pump are fixed on the Gate motor

Micro_switch_and_Relay.ino (3.25 KB)

Multi_stepper_one_by_one.ino (1.56 KB)

It would help if you post a schematic of your project. Include all parts, with part numbers and/or values and all power supplies.

Please find attach photo.

1 Like

Hi All,
It seem that my schematic has been download 10 times.
I want to know if this code can be merge or be written another way.
May be in tabs.
Any ideas ?
Thanks

I have two sketch and I can't merge them.

Forget the two sketches. Define the requirements for THE program you want. Then, set about implementing those requirements. You can certainly rely on the existing sketches for ideas/complete functions, but they are useless blobs of text until you have requirements.

I want to know if this code can be merge or be written another way.

Almost certainly. Whether the resulting program does anything remotely like what you want is a different story. Since we don't know what you want, it is pointless to ask us about how to merge the programs.

May be in tabs.

Or slots.

Thanks for your reply.

I have change the arduino UNO for one MEGA.
One button (4) has been added to start the code.

I wrote another code and its work, but the only problem I got.
Is, my relay are ON when I powered the all system. I have connect the rail motor to the Normally Closed on the relay, Its work but I have conflict.

I want when I power the system all the relay stay Off. and when I press the button 4 the relay got power and become ON and do the sequence.

New_Code.ino (4.22 KB)

Is, my relay are ON when I powered the all system.

Would those be the relays connected to stepPin1, stepPin2, stepPin3, and stepPin4?

Or would those be the relays connected to led1Pin, led2Pin, and led3Pin?

Why don't you write the pins to the state you want them to have, instead of assuming that the Arduino will do that automagically?

  { buttonState1 = digitalRead(button1);
    buttonState2 = digitalRead(button2);
    buttonState3 = digitalRead(button3);
    buttonState3 = digitalRead(button3);
    }

What is this code for? You never use these values.

  while (true)  
  {

Another dweeb that doesn't understand that loop() loops.