Power Stepper from CW to CCW

Hi, I introduce myself.
My name is Ettore, I’m 56 years old and I’m a beginner with an Arduino project, but I know that this time I’m asking too much of myself …: D

In the past years I worked on a flight simulator that used C ++, but now it’s been several years and I should review the programming quite similar to Arduino.

Let’s move on to what I’m doing
I have to automate a press (for domestic use only!) that requires a force of about 60nm.
I’ve already bought a 8.7nm stepper motor and a 10/1 matched gearbox that takes the forces involved to what is needed.

I have to write a code that at start (with a simple button) checks first a start and a final end to know the working field in pre-established steps, so after pressing a start button it must start the cycle, check during the cycle the position of 6 microswitches on off, or maybe each one with a resistive value, so that they give information of their value on a single analogue channel to interrupt the process at any time and to warn with a relative message the lack of a component of the process.

What is fundamental considering the forces involved, both the start and the stop of each cycle must be progressive with acceleration and deceleration until the stop before the inversion of rotation.
I thought about using the AccellStepper library 1.57.1.

I see myself on the high seas … Does anyone know where I can find a draft skretch on which to work?

Use of Arduino UNO, 86HBS85 engine, HBS860H driver.

// Bounce.pde
// -*- mode: C++ -*-
//
// Make a single stepper bounce from one limit to another
//
// Copyright (C) 2012 Mike McCauley
// $Id: Random.pde,v 1.1 2011/01/05 01:51:01 mikem Exp mikem $
#include <AccelStepper.h>
#include <Bounce2.h>
// Define a stepper and the pins it will use
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

const int pinBtnStart   = 6;
const int pinBtnStop    = 7;
const int pinBtnDietro  = 8;
const int pinEnable     = 9;

void setup()
{ 
 // Change these to suit your stepper if you want
  stepper.setMaxSpeed(10000);
  stepper.setAcceleration(7000);
  stepper.moveTo(8500);
} 
void loop()
{

    // If at the end of travel go to the other end
    if (stepper.distanceToGo() == 0)
      stepper.moveTo(-stepper.currentPosition());
    stepper.run();
}/[code]

[/code]

Please provide a link to the datasheet for your stepper driver.

I suspect it is the standard type that requires step and direction inputs and, if so, you must specify that for AccelStepper using the DRIVER option. The default setting is not suitable for that type of driver.

Assuming you can do experiments without having the motor connected to anything then start with a simple program that moves it 1 revolution in each direction.

...R
Stepper Motor Basics
Simple Stepper Code

You mean Nm (newton-metres), not nm (nanometers)! That's a torque, not a force.

8.7Nm is huge for a stepper - is this a big NEMA34 ? You have a suitable stepper driver for this?

I'd suggest starting with the examples from the AccelStepper library.

A 8.7Nm motor with 10:1 reduction gearing can exert dangerous levels of torque - make sure you cannot
get involved in the mechanism during testing(!) - assume it will misbehave...

For interrupting you should have a single boolean for emergency stop, checked by everything, and
set by a function that also calls stop() on the AccelStepper instance. While the emergency stop flag
is set no calls should be possible other than run() and stop().

Pressing force is expressed in Newtons or kilograms force (kgf), 1 kgf = 9.806N, how much force is required from your press? What kind of mechanical arrangement are you using, lead screw and nut (what is the thread pitch?) or something else?

Robin2:
Please provide a link to the datasheet for your stepper driver.

I suspect it is the standard type that requires step and direction inputs and, if so, you must specify that for AccelStepper using the DRIVER option. The default setting is not suitable for that type of driver.

Assuming you can do experiments without having the motor connected to anything then start with a simple program that moves it 1 revolution in each direction.

...R
Stepper Motor Basics
Simple Stepper Code

[/quote https://www.fasttobuy.com/85nm-nema-34-dsp-closed-loop-stepper-drive-motor-system-ac60v-with-power-supply-for-xy-tables_p36074.html

outsider:
Pressing force is expressed in Newtons or kilograms force (kgf), 1 kgf = 9.806N, how much force is required from your press? What kind of mechanical arrangement are you using, lead screw and nut (what is the thread pitch?) or something else?

I use two pulley and toothed belt. the Newton final after speed reducer 10/1 is 87Newton

MarkT:
You mean Nm (newton-metres), not nm (nanometers)! That's a torque, not a force.

8.7Nm is huge for a stepper - is this a big NEMA34 ? You have a suitable stepper driver for this?

I'd suggest starting with the examples from the AccelStepper library.

A 8.7Nm motor with 10:1 reduction gearing can exert dangerous levels of torque - make sure you cannot
get involved in the mechanism during testing(!) - assume it will misbehave...

I Know well...

For interrupting you should have a single boolean for emergency stop, checked by everything, and
set by a function that also calls stop() on the AccelStepper instance. While the emergency stop flag
is set no calls should be possible other than run() and stop().

Yes I must add Emergency STOP, but must put two endpoint first!!! When I turn on machine It must go to the endpoint and assume value for first and last step before start cycle.

All test are do without BELT!!!. When all work fine for long time I connect motor!!!!!

I use two pulley and toothed belt. the Newton final after speed reducer 10/1 is 87Newton

Force or torque? Please be precise with such terms, its really confusing otherwise.

I would use a mechanical switch like a maintained, normally closed, mushroom head pushbutton for E-Stop, don't depend on solid state switches and programming. What is the diameter of the motor pulley? The pulley that moves the "platten"? Can you post a drawing or picture of your apparatus?
HowToPost

MarkT:
Force or torque? Please be precise with such terms, its really confusing otherwise.

obviously Torque…

outsider:
I would use a mechanical switch like a maintained, normally closed, mushroom head pushbutton for E-Stop, don't depend on solid state switches and programming. What is the diameter of the motor pulley? The pulley that moves the "platten"? Can you post a drawing or picture of your apparatus?
HowToPost

I had posted a photo of all components in the first post.
The pulleys are: 14 teeth on the stepper motor, and 60 teeth on the machine
I wont put mushroom head pushbutton at the mount of circuit for break and bypass any solid state component for last security.

@BuckRogers, I can't figure from your various Replies if you have had success with the links I gave in Reply #1. Your link in Reply #4 does not link to a datasheet - but it seems to confirm my guess that the driver takes normal step and direction inputs.

...R

Robin2:
@BuckRogers, I can't figure from your various Replies if you have had success with the links I gave in Reply #1. Your link in Reply #4 does not link to a datasheet - but it seems to confirm my guess that the driver takes normal step and direction inputs.

...R

Hi test your Skretch, but I must have slow start and slow stop, I think that I must use Accellstepper Library and it use for default different pin numeration for Stepper motor:
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

How can add line in the code for have slow start and slow stop of stepper?

 /*
   Pilotare un motore passo passo mediante tre pulsanti.
   I pulsanti determinano il senso di marcia e lo stop.
   Progetto realizzato su richiesta di:
   MangaAnime GiochiFilm : https://www.youtube.com/channel/UCmMfiWIApA-eHCxsMiBcpOQ
 
   Autore  : Andrea Lombardo
   Web     : http://www.lombardoandrea.com
   Post    : http://wp.me/p27dYH-Ka
*/
 
//Inclusione delle librerie
#include <Bounce2.h>
#include <AccelStepper.h>
 
//definizione dei pin
//const int motoreDir = 2;
//const int motoreStep = 3;
//AccelStepper motore; 

const int pinBtnAvanti = 7;
const int pinBtnStop = 8;
const int pinBtnDietro = 9;
const int pinEnable = 10;
 
//uso il led onboard di Arduino, per avere un riscontro visivo dello stato di marcia o di stop
const int pinLedStato = 13;
 
/*
   Velocità del motore in numero di step per secondo
   Come riportato nella descrizione di AccelStepper, massimo 4000 per un Arduino UNO.
   4000 steps per second at a clock frequency of 16 MHz on Arduino such as Uno
*/
const float velocita = 10000;
 
//Millisecondi per il debounce dei pulsanti
const int debounceMs = 10;
 
//Stato e direzione
boolean abilitato, direzione;
 
//Creazione istanza del motore
AccelStepper motore;
 
//Creazione istanze dei pulsanti
Bounce btnAvanti = Bounce();
Bounce btnStop = Bounce();
Bounce btnDietro = Bounce();
 
void setup() {
  //imposto stato e direzione iniziali (motore fermo)
  abilitato = direzione = false;
 
  //definizione della modalità dei pin
  pinMode(pinBtnAvanti, INPUT);
  pinMode(pinBtnStop, INPUT);
  pinMode(pinBtnDietro, INPUT);
  pinMode(pinEnable, OUTPUT);
  pinMode(pinLedStato, OUTPUT);
 
  //impostazione pullUp per i pin dei bottoni
  digitalWrite(pinBtnAvanti, HIGH);
  digitalWrite(pinBtnStop, HIGH);
  digitalWrite(pinBtnDietro, HIGH);
 
  //setta stato del pin enable e del led di stato
  digitalWrite(pinEnable, !abilitato);
  digitalWrite(pinLedStato, abilitato);
 
  //configurazione parametri motore
  motore.setMaxSpeed(velocita);
  motore.setAcceleration(7000);
  motore.setSpeed(velocita);
 
  //inizializzazione bottoni
  btnAvanti.attach(pinBtnAvanti);
  btnAvanti.interval(debounceMs);
 
  btnStop.attach(pinBtnStop);
  btnStop.interval(debounceMs);
 
  btnDietro.attach(pinBtnDietro);
  btnDietro.interval(debounceMs);
 
}
 
void loop() {
 
  //refresh stato dei pulsanti
  btnAvanti.update();
  btnStop.update();
  btnDietro.update();
 
  //leggi valore dei pulsanti
  int valStop = btnStop.read();
  int valAvanti = btnAvanti.read();
  int valDietro = btnDietro.read();
 
  //determina azioni
  if (valStop == LOW) {
    abilitato = false;
  }
 
  if (valAvanti == LOW) {
    abilitato = true;
    direzione = true;
  }
 
  if (valDietro == LOW) {
    abilitato = true;
    direzione = false;
  }
 
  //cambia stato ai pin ENABLE e LedStato
  digitalWrite(pinEnable, !abilitato);
  digitalWrite(pinLedStato, abilitato);
 
  //se abilitato == true
  if (abilitato) {
 
    //in base al valore di direzione
    if (direzione) {
      //imposta velocità (e senso)
      motore.setSpeed(velocita);
    } else {
      //imposta velocità negata (inversione di marcia)
      motore.setSpeed(-velocita);
    }
 
    //muovi il motore
    motore.runSpeed();   
  } else { //se abilitato == false
    //in realtà questa istruzione viene ignorata inquanto il pin ENABLE del modulo
    //è stato impostato ad HIGH e quindi le uscite dei FET sono spente
    motore.stop();
  }
 
}

BuckRogers:
Hi test your Skretch, but I must have slow start and slow stop,

I did not propose my code as a complete solution - only something to allow you to test the motor to ensure that things work at a minimum level. It is a waste of time trying complex code if the simple code won't work.

I think that I must use Accellstepper Library and it use for default different pin numeration for Stepper motor:
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

I covered this in my Reply #1

...R