# Stepper Library not working properly in Protenta H7 breakout board

**URL:** <https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140>\
**Category:** Portenta Breakout\
**Created:** [November 18, 2022, 8:54am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140 "2022-11-18T08:54:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![chamath](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@chamath](https://forum.arduino.cc/u/chamath)\
**Post date:** [November 18, 2022, 8:54am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/1 "2022-11-18T08:54:42Z")

</div>

I have tried stepper motor controling using `[SpeedyStepper](https://github.com/Stan-Reifel/SpeedyStepper)` with Protenta H7 breakout board, but it's not working properly. can some one help me.

The issue's are so wired. if I connect to BOB to power supply (5V out) with-out the power (230V in) the example work's work's ( with the USB power ). If I just use USB the code doesn't work.

only method of working : USB + Power Supply (Without Power)

Help me out. Thank's !

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 18, 2022, 10:01am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/2 "2022-11-18T10:01:53Z")

</div>

Are the all GND's connected together? (Protenta board, motor, power supply etc?

---

<div class="post-metadata">

**Author:** ![chamath](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@chamath](https://forum.arduino.cc/u/chamath)\
**Post date:** [November 18, 2022, 10:21am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/3 "2022-11-18T10:21:14Z")

</div>

Yes all connected together !

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 18, 2022, 10:30am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/4 "2022-11-18T10:30:32Z")

</div>

> [@chamath](#):
>
> if I connect to BOB to power supply (5V out) with-out the power (230V in) the example work's work's

The only thing that comes to mind is that powerful capacitors are usually installed at the output of power supplies. At the moment the motor starts, it consumes a lot, then capacitors can help the USB to supply a high current.

---

<div class="post-metadata">

**Author:** ![chamath](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@chamath](https://forum.arduino.cc/u/chamath)\
**Post date:** [November 18, 2022, 10:32am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/5 "2022-11-18T10:32:11Z")

</div>

Motor is powered with a separate power supply ( Using Clear path Nema 17 Motor )

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 18, 2022, 10:35am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/6 "2022-11-18T10:35:17Z")

</div>

And what does it mean that the scheme does not work? Arduino freezes or restarts?

---

<div class="post-metadata">

**Author:** ![chamath](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@chamath](https://forum.arduino.cc/u/chamath)\
**Post date:** [November 18, 2022, 10:46am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/7 "2022-11-18T10:46:29Z")

</div>

> [@b707](#):
>
> scheme does not work? Ar

Some time's motor work's, but some time's not. even the stepper libraries also not working !

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 18, 2022, 10:47am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/8 "2022-11-18T10:47:31Z")

</div>

> [@chamath](#):
>
> Some time's motor work's, but some time's not. even the stepper libraries also not working !

sorry but your answer is not very informative

---

<div class="post-metadata">

**Author:** ![chamath](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@chamath](https://forum.arduino.cc/u/chamath)\
**Post date:** [November 23, 2022, 2:17am UTC](https://forum.arduino.cc/t/stepper-library-not-working-properly-in-protenta-h7-breakout-board/1055140/9 "2022-11-23T02:17:38Z")

</div>

Solved the issue, The case was with the Clear Path wiring, I just looked at the PLC wiring only. after go through all resources figure-out the issue.

Wrong Wiring for the arduino H7:  
 ![1520178813211](https://europe1.discourse-cdn.com/arduino/original/4X/a/6/f/a6f8e535b0ee62096aded949777de4240bb94400.jpeg)

Correct Wiring :

 ![Screenshot 2022-11-19 at 7.41.00 PM](https://europe1.discourse-cdn.com/arduino/original/4X/3/e/9/3e9ad505fb0e2fd947fc4a2508a3567756ebb992.jpeg)

(Resource - [How to Wire an Arduino to a ClearPath Servo Motor - YouTube](https://youtu.be/QZLwDnGSaeI) )

I used the BOB board and the code :

```cpp
// 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 <Arduino_PortentaBreakout.h>

const int Enable = PWM0; // ClearPath ~enable input; +enable = BLU wire; -enable = ORN wire
const int InputA = PWM1; // ClearPath Input A; +InputA = WHT wire; -InputA is BRN wire
const int InputB = PWM2; // ClearPath Input B; +InputB = BLK wire; -InputB = YEL wire
const int HLFB = PWM3; // ClearPath HLFB Output; +HLFB = GRN wire; -HLFB = RED wire

//AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

AccelStepper stepper(1, InputA, InputB); // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5

void setup()
{
  Serial.begin(9600);
  pinMode(Enable, OUTPUT);
  digitalWrite(Enable, HIGH);
  // Change these to suit your stepper if you want
  stepper.setMaxSpeed(800);
  stepper.setAcceleration(200000);
  stepper.moveTo(800);
}

void loop()
{
  // If at the end of travel go to the other end
  if (stepper.distanceToGo() == 0)
    stepper.moveTo(-stepper.currentPosition());
  Serial.println(stepper.currentPosition());
  stepper.run();
}

```

Now I'm looking forward to connect the motor to **Machine controller** , Tried the same code with the correct pin Configuration, but cannot figure-it out yet !

Thanks !
