Controllino 2 steppers

Dear Jacques,

Digital output from 0-7 i mean on Controllino (you sended picture - where you connected wires).

and i write a pair for which number i need to put in arduino code to control stepper motor

Controllino - digital output no (d0,d1,d2,d3)

Arduino code -- Stepper myStepper1(motorSteps, 4, 5, 6, 7); (d4,d5,d6,d7)

Stepper myStepper2(motorSteps, 8, 9, ?, ?);

For d6 and d7 i dont know wich number to put (i tried some but it doesnt work) - on Controllino mini pinnout is written that it is A4 and A5. - you can see in my last post.

I really dont understand!

Hi,
Have you looked at the Controllino site.

https://controllino.biz/

It has tutorials, examples and documentation on programming your controller.

Tom.... :slight_smile:

Yes but i dont find solution

On the video, with only one motor:

Digital output. In arduino code
Digital 4 - 4
Digital 5 - 5
Digital 6 - 6
Digital 7 - 7

On the video, with two motors:

Digital output. In arduino code
Digital 0 - 0
Digital 1 - 1
Digital 2 - 2
Digital 3 - 3
Digital 4 - 4
Digital 5 - 5
Digital 6 - 6
Digital 7 - 7

Jacques

Hi,
To help, here is the top of a Controllino mini;


Tom... :slight_smile:

Hi,

Really thank you guys for effort, i already tried it in past like you said, i tried now also but it isnt working.

I case like you said (i posted code), i have leds at controllino - WORKING- d0,d1,d2,d3, COMPLETLY OFF - d4,d5,d6,d7,

Also IN1 and IN0 are WORKING (as arduino code 2 and 3 are for Interupt 1 and 0),

if you look at picture in attachment - it seems logic as:

d4 - arduino code "8"
d5 - arduino code "9"
d6 - arduino code "A4"
d7 - arduino code "A5"

i dont understand, sorry!! There is code and picture on which i refer my conclusions!

2_stepper_test.ino (1.07 KB)

Hi,
What does your monitor display show?
OPs code

/*
 Stepper Motor Control - one revolution

 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 - 11 of the Arduino.

 The motor should revolve one revolution in one direction, then
 one revolution in the other direction.


 Created 11 Mar. 2007
 Modified 30 Nov. 2009
 by Tom Igoe

 */
#include <Controllino.h>
#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper1(stepsPerRevolution, 0, 1, 2, 3);
Stepper myStepper2(stepsPerRevolution, 4, 5, 6, 7);
void setup() {
  // set the speed at 60 rpm:
  myStepper1.setSpeed(60);
  myStepper2.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper1.step(stepsPerRevolution);
  delay(500);

  // step one revolution in the other direction:
  Serial.println("counterclockwise");
  myStepper2.step(-stepsPerRevolution);
  delay(500);
}

Have you tried

 myStepper2.step(stepsPerRevolution);

In other words delete the - sign.
Make them both rotate in the same direction.
Tom.. :slight_smile:

Dear Tom,

i tried, it doesnt help.

you can see photo in attachment.

Isnt it like in pinnout - in arduino 2 and 3 is IN1 and IN0 on led (controllino) - it is like that for my setup!!!

What can else i do?

What is code in arduino for digital - d6+d7 on controllino???

I got it,

code i write is:

Stepper myStepper1(stepsPerRevolution, A4, A5, 8, 9);
Stepper myStepper2(stepsPerRevolution, 4, 5, 6, 7);

i neved thought that i need to write it like this!

Thanks Tom and Jacques for your time and effort!

Hi,
Good to hear.

The transition of the arduino to PLC type industrial environment is puzzling in that instance, they label the terminals on their contollino but do not set their library up to dictate those pin numbers in the software you are going to write.

You would have to do

byte D0Pin = 4;
byte D1Pin = 5;
byte D2Pin  =   etc etc

Or suitable Pin names.

Then use the variable names as you do in normal code.

It is bad show actually not to use that nomenclature in their example code.

Opps they do, look at this example from Library Examples.

#include <Controllino.h>  /* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. */

/*
  CONTROLLINO - Blinking_LEDs, Version 01.00

  Turns on and off digital outputs of CONTROLLINO, which also blinks with CONTROLLINO´s status LEDs for the outputs.

  IMPORTANT INFORMATION!
  Please, select proper target board in Tools->Board->Controllino MINI/MAXI/MEGA before Upload to your CONTROLLINO.
  (Please, refer to https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library if you do not see the CONTROLLINOs in the Arduino IDE menu Tools->Board.)

  This example sketch does not require any additional parts, equipment, wires or power supply. Just your CONTROLLINO, USB cable (type A-B) and a PC.
 
  Created 8 Dec 2016
  by Lukas

  https://controllino.biz/

  (Check https://github.com/CONTROLLINO-PLC/CONTROLLINO_Library for the latest CONTROLLINO related software stuff.)
*/

// the setup function runs once when you press reset (CONTROLLINO RST button) or connect the CONTROLLINO to the PC
void setup() {
  // initialize all used digital output pins as outputs
  pinMode(CONTROLLINO_D0, OUTPUT);
  pinMode(CONTROLLINO_D1, OUTPUT);  // note that we are using CONTROLLINO aliases for the digital outputs
  pinMode(CONTROLLINO_D2, OUTPUT);
  pinMode(CONTROLLINO_D3, OUTPUT);  // the alias is always like CONTROLLINO_
  pinMode(CONTROLLINO_D4, OUTPUT);  // and the digital output label as you can see at the CONTROLLINO device
  pinMode(CONTROLLINO_D5, OUTPUT);  // next to the digital output screw terminal
  pinMode(CONTROLLINO_D6, OUTPUT);
  pinMode(CONTROLLINO_D7, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(CONTROLLINO_D0, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);                          // wait for 100 milliseconds which is 1/10 of a second 
  digitalWrite(CONTROLLINO_D0, LOW);    // turn the LED off by making the voltage LOW
  delay(100);                          // wait for 100 milliseconds which is 1/10 of a second 
  digitalWrite(CONTROLLINO_D1, HIGH);  
  delay(100);                       
  digitalWrite(CONTROLLINO_D1, LOW);    
  delay(100);                       
  digitalWrite(CONTROLLINO_D2, HIGH);   // please, visit https://controllino.biz/downloads/   
  delay(100);                           // if you want to know more about the mapping of the CONTROLLINO
  digitalWrite(CONTROLLINO_D2, LOW);    // digital outputs to the Arduino pins
  delay(100);                      
  digitalWrite(CONTROLLINO_D3, HIGH);   
  delay(100);                      
  digitalWrite(CONTROLLINO_D3, LOW);    // by using CONTROLLINO aliases instead of Arduino pin numbers    
  delay(100);                           // you ensure sketch portability between all CONTROLLINO variants
  digitalWrite(CONTROLLINO_D4, HIGH);  
  delay(100);                       
  digitalWrite(CONTROLLINO_D4, LOW);    
  delay(100);                     
  digitalWrite(CONTROLLINO_D5, HIGH);  
  delay(100);                      
  digitalWrite(CONTROLLINO_D5, LOW);    
  delay(100);                      
  digitalWrite(CONTROLLINO_D6, HIGH);  
  delay(100);                      
  digitalWrite(CONTROLLINO_D6, LOW);   
  delay(100);                       
  digitalWrite(CONTROLLINO_D7, HIGH);  
  delay(100);                       
  digitalWrite(CONTROLLINO_D7, LOW);   
  delay(100);                      
}

/* End of the example. Visit us at https://controllino.biz/ or contact us at info@controllino.biz if you have any questions or troubles. */

/* 2016-12-13: The sketch was successfully tested with Arduino 1.6.13, Controllino Library 1.0.0 and CONTROLLINO MINI, MAXI and MEGA. */

"CONTROLLINO_D0" is a reserved variable name.

Using those pin names would have fixed your problem instantly.

Tom... :slight_smile:

Hi, I recently bought a controllino and also had to drive an stepper motor. I'm gonna post my experience here because their might be others struggling with this:

First of all I had a bipolar motor but this didn't work, I contacted the developper of controllino and he told me that you could only drive a stepper motor directly from the controllino if you are using an unipolar one.

Just connect the black and white wires to the GND and the other 4 you can connect to the outputs. Make sure that the motor you are using has a high enough resistance. For the software just import the controllino library (all the steps for setting up the controllino are on the site).

Following code let's the motor run in both directions:

#include <Stepper.h>
#include <Controllino.h>

const int stepsPerRevolution = 200;

Stepper myStepper(stepsPerRevolution, CONTROLLINO_D0, CONTROLLINO_D1, CONTROLLINO_D2, CONTROLLINO_D3);

int startDelay = 0;
int midDelay = 5000;
int endDelay = 5000;

void setup() {
// put your setup code here, to run once:
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
delay(500);

// step one revolution in the other direction:
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
delay(500);
}

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg.

Thanks.. Tom... :slight_smile: