Stepper UNO v1.0: Difference between revisions

From lechacal
Jump to navigation Jump to search
(42 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[File:IMG_0682_small.png | right | 300px]]
=StepperUNO  - Stepper Motor Manual Control=
=StepperUNO  - Stepper Motor Manual Control=
[[File:IMG_0682_small.png | right | 300px]]


The StepperUNO is a stepper motor manual control board for standalone system.  
The StepperUNO is a stepper motor manual control board for standalone system.  
Line 9: Line 8:
Based on the pattern of the Arduino UNO it is designed to host a LCD keypad shield. This combination makes the stepperUNO an excellent board for application control.
Based on the pattern of the Arduino UNO it is designed to host a LCD keypad shield. This combination makes the stepperUNO an excellent board for application control.


The software works exactly as an Arduino UNO.  
This is programmed using Arduino IDE. Sketch can be uploaded directly from USB port.
 
[http://lechacalshop.com/gb/cnc/17-stepperuno-arduino-stepper-motor-control-lcd-keypad-shield.html Get it online]


[http://lechacalshop.com/gb/cnc/17-stepperuno-arduino-stepper-motor-control-lcd-keypad-shield.html Link to the shop]


==Specifications==
==Specifications==
Line 32: Line 30:
The product offers two variants. A embedded A4988 driver option and a generic screw terminal connector for interfacing with an external driver. This option is chosen at purchase time.
The product offers two variants. A embedded A4988 driver option and a generic screw terminal connector for interfacing with an external driver. This option is chosen at purchase time.


[[File:IMG_1478_small.png| 200px]] [[File:IMG_1479_small.png| 200px]]


===Generic connector===
[[File:IMG_1479_small.png| 200px | Generic Driver]]


===Generic connector===
With this configuration it is possible to connect any external driver to the stepperUNO. The connector is a screw terminal block for V+ Ground Step Direction and Enable.
With this configuration it is possible to connect any external driver to the stepperUNO. The connector is a screw terminal block for V+ Ground Step Direction and Enable.
For example units that can be interfaced this way might be Geckodrive / Sanyo Denki 3 / TB6600 / TB6560 etc...
For example units that can be interfaced this way might be Geckodrive / Sanyo Denki 3 / TB6600 / TB6560 etc.
 
The connections are as follow
{| class="wikitable"
|+
|-
| Gnd
| V+
| Gnd
| EN 2
| Step 2
| Dir 2
| Gnd
| V+
| Gnd
| EN 1
| Step 1
| Dir 1
|}
 
Note Gnd's are connected together. So as the V+'s.
V+ can serve as input to power up the StepperUNO from an external PSU.


===A4988 driver===
===A4988 driver===
[[File:IMG_1478_small.png| 200px | A4988 driver]]
The A4988 driver can be fitted on the StepperUNO itself. The motor is then connected directly to the StepperUNO using the 4 pin connector.
The A4988 driver can be fitted on the StepperUNO itself. The motor is then connected directly to the StepperUNO using the 4 pin connector.
'''Microstepping.''' The A4988 can be microstepped by soldering together the jumper pads at the back of the circuit board.
[[File:stepperUNO_microstep.jpg| 200px | A4988 driver]]


==Motor Control==
==Motor Control==
Line 61: Line 87:


All digital and analog ports are available with screw terminal connectors. On each port there are three pins. Data/Ground and +5V. Ground and +5v are here for powering the sensor.
All digital and analog ports are available with screw terminal connectors. On each port there are three pins. Data/Ground and +5V. Ground and +5v are here for powering the sensor.
The Digital Input/Outputs available are:<br>
D10<br>
D11<br>
D12<br>
D13<br>
The analog Inputs available are <br>
A1<br>
A2<br>
The analog input can be used a s Digital I/O. Making 6 DIO available. These would be<br>
D15<br>
D16<br>
===Microswitch===
To connect a microswitch to one of the DIO the pin out should be as such<br>
Vcc -> NO<br>
Gnd -> NC<br>
In  -> Common<br>
==Power supply==
The stepper UNO can be powered using a conventional 12V PSU with 2.1mm jack connector.
With A4988 driver the power to the motor is provided directly by the 12V power supply.
With the generic driver is it recommended to use a separate power supply for the motor. This later must be connected directly to the external driver.
Using the power from the stepperUNO (Gnd and V+) to feed the motors can used for small motors only.


==Enclosure==
==Enclosure==
Line 73: Line 127:
The stepperUNO library is available in the section Files below.
The stepperUNO library is available in the section Files below.


The library is described in more details in [[StepperUNO Library 1.1]]
The library is described in more details in [[StepperUNO Library 1.4]]
 
For older version (1.3 and below) see [[StepperUNO Library 1.1]].


A simple usage example is shown below.
A simple usage example is shown below.
<syntaxhighlight lang=c style="border:1px dashed blue">
// simpledrive v1.3
// lechacal.com
// Example usage of stepperUNO library
// drive a single motor with left/right button
// library: stepperUNO_v1.4
#define Pot 3 // Potentiometer is on pin 3
#include <LiquidCrystal.h>
#include <stepperUNO.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
keypad Keypad;
stepMOTOR motor1;
const int Nstep = 200; // Enter here the number of step/rev for your motor
void setup() {
  motor1.begin(0x4, Nstep); // Motor 1 is at address 0x5. Motor 2 on 0x4
  motor1.enable();
  lcd.begin(16, 2); // LCD initialisation
}
void loop() {


// simpledrive v1.0
// lechacal.com
// Example usage of stepperUNO library
// drive a single motor with left right button
#define Pot 3
#include <LiquidCrystal.h>
#include <Wire.h>
#include <stepperUNO.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
keypad Keypad;
stepMOTOR motor1, motor2;
void setup(){
  motor1.begin(0x4);
  motor2.begin(0x5);
  motor1.enable();
 
  lcd.begin(16,2); //LCD INITIALISATION
}
void loop(){
 
   int POTval = analogRead(Pot);
   int POTval = analogRead(Pot);
   float step_delay = 102400/(POTval+1);
   int rpm = map(POTval, 0, 1023, 5, 500); // Speed range from 5 to 500rpm
 
 
   byte button = Keypad.ReadKey();
   Keypad.ReadKey();
 
 
   if( Keypad.buttonJustPressed ) {
   if (Keypad.state == PRESSED_RIGHT) {
    motor1.set_direction(true);
        switch (button){             
    motor1.set_speed_rpm(rpm);
    motor1.start();
            case BUTTON_RIGHT:{ 
    lcd.setCursor(0, 0);
                  motor1.setDirection(true);
    lcd.print("RIGHT");
                  motor1.speed(step_delay);
    Keypad.closeEvent(); // Must be here to indicate we are done with the event
                  lcd.setCursor(0,0);
  }
                  lcd.print("RIGHT");
  else if (Keypad.state == PRESSED_LEFT) {
                  break;
     motor1.set_direction(false);
            }
    motor1.set_speed_rpm(rpm);
            case BUTTON_LEFT:{     
    motor1.start();
                  motor1.setDirection(false);
    lcd.setCursor(0, 0);
                  motor1.speed(step_delay);
    lcd.print("LEFT ");
                  lcd.setCursor(0,0);
    Keypad.closeEvent();
                  lcd.print("LEFT ");
   }
                  break;
 
            }
   else if ( Keypad.state == RELEASED_RIGHT ) {
        }//end switch
    motor1.stop();
   }// end if
    lcd.setCursor(0, 0);
 
    lcd.print("READY");
   if( Keypad.buttonJustPressed ) Keypad.buttonJustPressed = false; //We have now done all we wanted once the button pressed. Closing it.
    Keypad.closeEvent();
    
   }
   if( Keypad.buttonJustReleased ) { 
   else if ( Keypad.state == RELEASED_LEFT ) {
    if (button==BUTTON_NONE){
    motor1.stop();
      motor1.stop();
    lcd.setCursor(0, 0);
      lcd.setCursor(0,0);
    lcd.print("READY");
      lcd.print("     ");
     Keypad.closeEvent();
     }
   }
   }
  if( Keypad.buttonJustReleased ) Keypad.buttonJustReleased = false;
 
   
}//end loop
 
</syntaxhighlight>
}//end loop


==Files==
==Files==
[http://lechacal.com/stepperUNO/stepperUNO.v1.0.zip StepperUNO Library v1.0]<br>
 
[http://lechacal.com/stepperUNO/stepperUNO_v1_1.zip StepperUNO Library v1.1]
[http://lechacal.com/stepperUNO/stepperUNO_v1_2.zip StepperUNO Library v1.2]<br>
[https://github.com/lechacal/stepperUNO StepperUNO Library v1.3]<br>
[http://lechacal.com/stepperUNO/stepperUNO_v1_4.zip StepperUNO Library v1.4]<br>
 
Version 1.4 -> If you have acquired the stepperUNO before 1st March 2021 you will need to reflash the 2 attiny85 to use this version.
 
To install the library download the above zip file. In Arduino IDE go to '''Sketch''' | '''Include Library''' | '''Add .ZIP Library'''.
Then select the downloaded zip file.


==Application Examples==
==Application Examples==
Line 154: Line 218:
* Default sketch - Sketch out of manufacture.
* Default sketch - Sketch out of manufacture.
* [[albawinder | Albawinder - Coil winder project]]
* [[albawinder | Albawinder - Coil winder project]]
* Position Control
* [[Position Control with StepperUNO]]
** [[http://lechacal.com/stepperUNO/MVI_0839-181029-25042016.mp4 Video]]
** [[http://lechacal.com/stepperUNO/StepperUNO_position_v1_0.ino Sketch]]
* attiny_stepperUNO - Sketch for both attiny85 mcu that individually control the drivers.
* attiny_stepperUNO - Sketch for both attiny85 mcu that individually control the drivers.
* test_lcd - dummy sketch to test the lcd keypad
* test_lcd - dummy sketch to test the lcd keypad

Revision as of 20:47, 3 March 2021

StepperUNO - Stepper Motor Manual Control

The StepperUNO is a stepper motor manual control board for standalone system.

It can control up to two stepper motors and read sensors at the same time. It is suitable for small application requiring manual control and automation.

Based on the pattern of the Arduino UNO it is designed to host a LCD keypad shield. This combination makes the stepperUNO an excellent board for application control.

This is programmed using Arduino IDE. Sketch can be uploaded directly from USB port.

Link to the shop

Specifications

- 2 Motor control output (Generic or embedded A4988 drivers)
- 4 Digital Input/Output
- 2 Analog Input (can be used as digital I/O)
- 1 USB port
- 1 Power port (2.1mm Jack)
- 1 Potentiometer control
- 6 push buttons.
- 16x2 LCD screen

Motor Driver options

The stepperUNO was designed to communicate with any stepper driver.

The product offers two variants. A embedded A4988 driver option and a generic screw terminal connector for interfacing with an external driver. This option is chosen at purchase time.


Generic connector

Generic Driver

With this configuration it is possible to connect any external driver to the stepperUNO. The connector is a screw terminal block for V+ Ground Step Direction and Enable. For example units that can be interfaced this way might be Geckodrive / Sanyo Denki 3 / TB6600 / TB6560 etc.

The connections are as follow

Gnd V+ Gnd EN 2 Step 2 Dir 2 Gnd V+ Gnd EN 1 Step 1 Dir 1

Note Gnd's are connected together. So as the V+'s. V+ can serve as input to power up the StepperUNO from an external PSU.

A4988 driver

A4988 driver

The A4988 driver can be fitted on the StepperUNO itself. The motor is then connected directly to the StepperUNO using the 4 pin connector.

Microstepping. The A4988 can be microstepped by soldering together the jumper pads at the back of the circuit board. A4988 driver

Motor Control

The step forward with the StepperUNO is the addition of dedicated Attiny85 microcontroller for each motor. Thus allowing the main microcontroller (arduino UNO) to perform other tasks. Motor control operation will not interfere with other programmed task (e.g. LCD / sensor reading / compuation/ etc...). This also allows for smooth operation of the motors (e.g. preventing the motor rattle while the mcu is sending data to print on the screen).

The ATtiny85 communicates with the main Atmega328 MCU via i2c. All controls can be easily used using the StepperUNO library.

User Control / Manual Control

The well known LCD keypad shield is used. It uses the usual LiquidCrystal library to display informations.

From the LCD keypad six push buttons are available. We have rerouted the reset button as a normal function button. The StepperUNO library contains functions to program them easily.

The potentiometer is available for linear controls such as speed.

Inputs/Outputs

All digital and analog ports are available with screw terminal connectors. On each port there are three pins. Data/Ground and +5V. Ground and +5v are here for powering the sensor.

The Digital Input/Outputs available are:
D10
D11
D12
D13

The analog Inputs available are
A1
A2
The analog input can be used a s Digital I/O. Making 6 DIO available. These would be
D15
D16

Microswitch

To connect a microswitch to one of the DIO the pin out should be as such
Vcc -> NO
Gnd -> NC
In -> Common

Power supply

The stepper UNO can be powered using a conventional 12V PSU with 2.1mm jack connector.

With A4988 driver the power to the motor is provided directly by the 12V power supply.

With the generic driver is it recommended to use a separate power supply for the motor. This later must be connected directly to the external driver. Using the power from the stepperUNO (Gnd and V+) to feed the motors can used for small motors only.

Enclosure

The full combo StepperUNO/keypad shield can sit in a basket enclosure. This can be mounted on aluminium profile or other support.


Library

The stepperUNO library is available in the section Files below.

The library is described in more details in StepperUNO Library 1.4

For older version (1.3 and below) see StepperUNO Library 1.1.

A simple usage example is shown below.

// simpledrive v1.3
// lechacal.com
// Example usage of stepperUNO library
// drive a single motor with left/right button

// library: stepperUNO_v1.4

#define Pot 3 // Potentiometer is on pin 3

#include <LiquidCrystal.h>
#include <stepperUNO.h>

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
keypad Keypad;
stepMOTOR motor1;

const int Nstep = 200; // Enter here the number of step/rev for your motor

void setup() {

  motor1.begin(0x4, Nstep); // Motor 1 is at address 0x5. Motor 2 on 0x4
  motor1.enable();

  lcd.begin(16, 2); // LCD initialisation

}

void loop() {

  int POTval = analogRead(Pot);
  int rpm = map(POTval, 0, 1023, 5, 500); // Speed range from 5 to 500rpm

  Keypad.ReadKey();

  if (Keypad.state == PRESSED_RIGHT) {
    motor1.set_direction(true);
    motor1.set_speed_rpm(rpm);
    motor1.start();
    lcd.setCursor(0, 0);
    lcd.print("RIGHT");
    Keypad.closeEvent(); // Must be here to indicate we are done with the event 
  }
  else if (Keypad.state == PRESSED_LEFT) {
    motor1.set_direction(false);
    motor1.set_speed_rpm(rpm);
    motor1.start();
    lcd.setCursor(0, 0);
    lcd.print("LEFT ");
    Keypad.closeEvent();
  }

  else if ( Keypad.state == RELEASED_RIGHT ) {
    motor1.stop();
    lcd.setCursor(0, 0);
    lcd.print("READY");
    Keypad.closeEvent();
  }
  else if ( Keypad.state == RELEASED_LEFT ) {
    motor1.stop();
    lcd.setCursor(0, 0);
    lcd.print("READY");
    Keypad.closeEvent();
  }

}//end loop

Files

StepperUNO Library v1.2
StepperUNO Library v1.3
StepperUNO Library v1.4

Version 1.4 -> If you have acquired the stepperUNO before 1st March 2021 you will need to reflash the 2 attiny85 to use this version.

To install the library download the above zip file. In Arduino IDE go to Sketch | Include Library | Add .ZIP Library. Then select the downloaded zip file.

Application Examples

The library is provided with several examples in the Example directory.