Switching from UNO to Nano Every for stepper motor

Hello. Basic question but puzzling.

I have a stepper running from a TB660 no problem, all wired to a Uno in the most basic and elementary way.
Something like this.
Ground from the power supply of the TB6600 is connected to the Aduino ground.

Now i switched to a Nano every, same wiring etc, but no response from the motor. I also checked the voltage, tired to get the ENA, PUL and DIR up at the same time but the motor does not move, some faint noises tho coming from the motor.

I measured the voltage and it's just slightly less in the Every than in the UNO, shouldn't be a problem. Is there something i am missing here anout the Nano Every architecture? Some current calculation? Powering the TB6600 from 12V 8A or also from a 12V 4,8A, same results. Thank you.

Yes the timers are totally different in the Nano Every, so a lot of libraries that use timers fine on the Uno will not work with the Nano Every

It would help if you posted your code, that is not working.

Thanks, yes I remember the frequencies could be different.
I don't use any library tho.
This super simple code I made for testing for example is not working:

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
}
void loop() {
  digitalWrite(2, HIGH);  
digitalWrite(3, HIGH); 
  digitalWrite(4, HIGH);  
  delay(2000);                      // wait
  digitalWrite(2, LOW); 
   digitalWrite(3, LOW);   
   digitalWrite(4, LOW);   
   delay(1000);                   // wait for a second
}

where 2, 3 and 4 are connected to ena+, dir+ and pul+.

Then the voltmeter shows that the states (on 2, 3,4) are changing (H/L)?

And this is your 'board path' ? --

You know that we can only know what you tell us and you are drip feeding us with information.

So this implies you have a stepping motor driver. That code will not work with a stepping motor driver. The enable pin must be held permanently high and the direction should be fixed to either High or Low depending on what direction you want the motor to go. Then the pulse pin should be sent high, followed by a delay of about 1 mS, and then set low.

So your loop function needs to be totally rewritten.

Also what about the ena-, dir- and pul- on your stepping motor driver, how are they wired? You can't leave them unconnected, they should probably be connected to ground.

Are you really saying that this worked on a Uno?

Robin2's simple stepper program tutorial may be of interest.

Sorry for the mistake, this code was obviously only for testing if the Pins were delivering 5v.

I used a more complex sketch that receives commands from a software (Max) to test the motor themself.

// www.alessandroperini.com

// DIR = HIGH ----> HEADING RIGHT
// DIR = LOW  ----> HEADING LEFT

const byte numChars = 72;
char receivedChars[numChars];
byte m1on;
byte m1sp;
byte m2on;
byte m2sp;
byte m3on;
byte m3sp;
byte globalSpeed;
boolean newData = false;

const int step1 =6;   // PINs DA CAMBIARE PER PASSAGGIO A NANO
const int dir1 = 7;

const int step2 = 2;
const int dir2 = 3;

const int step3 = 5;
const int dir3 = 4;

const int en1 = 2; // Enable  
const int en2 = 8; // Enable  
const int en3 = 11; // Enable  

const int lowestMd = 3; // minimum microdelay



void setup() {


  pinMode(step1, OUTPUT);
  pinMode(dir1, OUTPUT);
  pinMode(step2, OUTPUT);
  pinMode(dir2, OUTPUT);
  pinMode(step3, OUTPUT);
  pinMode(dir3, OUTPUT);
  pinMode(en1, OUTPUT);
  pinMode(en2, OUTPUT);
  pinMode(en3, OUTPUT);


  digitalWrite(step1, LOW);
  digitalWrite(step2, LOW);
  digitalWrite(step3, LOW);

  digitalWrite(en1, LOW);
  digitalWrite(en2, LOW);
  digitalWrite(en3, LOW);

  Serial.begin(38400);

}
void loop() {
  recvWithStartEndMarkers();
  writeToMotors();
  showNewData();

}


////////////////////////////////////////////////////////////////////////////////////////////


void recvWithStartEndMarkers() {        // RECEIVE THE BYTES, USING START AND END MARKERS
  static boolean recvInProgress = false;
  static byte ndx = 0;
  byte startMarker = 255;
  byte endMarker = 250;
  byte rc;

  //
  while (Serial.available() > 0 && newData == false) {
    rc = Serial.read();

    if (recvInProgress == true) {
      if (rc != endMarker) {
        receivedChars[ndx] = rc;
        ndx++;
        if (ndx >= numChars) {
          ndx = numChars - 1;
        }
      }
      else {
        receivedChars[ndx] = '\0'; // terminate the string
        recvInProgress = false;
        ndx = 0;
        newData = true;
      }
    }
    else if (rc == startMarker) {
      recvInProgress = true;
    }
  }
}

void showNewData() {
  if (newData == true) {
    m1on = (byte)receivedChars[0];
    m1sp = (byte)receivedChars[1];
    m2on = (byte)receivedChars[2];
    m2sp = (byte)receivedChars[3];
    m3on = (byte)receivedChars[4];
    m3sp = (byte)receivedChars[5];
    globalSpeed = (byte)receivedChars[6];

    Serial.print(" m1on ");
    Serial.print(m1on);
    Serial.print("\t");
    Serial.print(" m1sp ");
    Serial.print(m1sp);
    Serial.print("\t");
    Serial.print(" m2on ");
    Serial.print(m2on);
    Serial.print("\t");
    Serial.print(" m2sp ");
    Serial.print(m2sp);
    Serial.print("\t");
    Serial.print(" m3on ");
    Serial.print(m3on);
    Serial.print("\t");
    Serial.print(" m3sp ");
    Serial.print(m3sp);
    Serial.print("\t");
    Serial.print(" globalSpeed ");
    Serial.println(globalSpeed);

    newData = false;
  }
}


void writeToMotors() {

  /// CHECK IF STEPPING ///

  if (m1on == 0) {
    digitalWrite(step1, LOW);
   digitalWrite(en1, HIGH);
  }  else  {
    digitalWrite(step1, HIGH);
   digitalWrite(en1, LOW);
  }
  if (m2on == 0) {
    digitalWrite(step2, LOW);
    digitalWrite(en2, HIGH);
  }  else  {
    digitalWrite(step2, HIGH);
    digitalWrite(en2, LOW);
  }
  if (m3on == 0) {
    digitalWrite(step3, LOW);
    digitalWrite(en3, HIGH);
  }  else  {
    digitalWrite(step3, HIGH);
    digitalWrite(en3, LOW);
  }


  /// DIR ///

  if (m1sp >= 64) {
    digitalWrite(dir1, HIGH);
    
  }
  else {
    digitalWrite(dir1, LOW);
  }

  if (m2sp >= 64) {
    digitalWrite(dir2, HIGH);
  }
  else {
    digitalWrite(dir2, LOW);
  }

  if (m3sp >= 64) {
    digitalWrite(dir3, HIGH);
  }
  else {
    digitalWrite(dir3, LOW);
  }


  int scaledSpeed = (lowestMd + 127 * 25) - globalSpeed * 25;
  delayMicroseconds(scaledSpeed);

  digitalWrite(step1, LOW);
  digitalWrite(step2, LOW);
  digitalWrite(step3, LOW);

  delayMicroseconds(scaledSpeed);
}



/*

CONTROLS 3 TB660

*/

It's derived from this older project of mine.

Sorry for the confusion. This code up here works on the UNO and not on the Nano Every.

Check my reply to mike and see the actual code I was using, I agree it seemed from my last sketch that I have no idea of what I am doing. :smiley:

Regarding this, yes, all the - are connected to ground, and the power ground is made common to those and the arduino's ground.

Yes and yes.

This is wrong, it is likely that after the first read the serial data buffer will be empty and the while loop will terminate.

It could be that the Nano Every runs the serial buffer quicker than the old Uno so you could be why it is failing on the Nano Every. Try adding a delay of 3mS after the Serial Read to slow things down a bit and allow time for the characters to arrive.

I now switched back to the uno and de-soldered everything from the nano due to deadline constraints, but if I will have the chance I will try it out, thanks for your insights.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.