Test with Nema 17 and DRV8825.

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Post Reply
Message
Author
Fermin
Posts: 7
Joined: Fri Feb 12, 2021 4:44 pm

Test with Nema 17 and DRV8825.

#1 Post by Fermin »

Hello.
I’m building a 172 Cesnna cab, with a 17" monitor. And I need to build a compass with a Stepper.
I’m running a test run on the Nema 17 and the DRV8825 driver (equivalent to A4988).
I’ve been looking at all the threads on the forum, and I’ve used the VID66-06 option. But I haven’t got the engine moving.

With this simple code in Arduino, I can make the stepper turn clockwise or counterclockwise, depending on an optocoupler:

const int dirPin = 2;
const int stepPin = 3;
const int optoini = 4;
int optoinivalue = HIGH;
const int stepsPerRevolution = 200;
void setup()
{
// Declare pins
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
pinMode(optoini, INPUT);
}
void loop()
{
// Set motor direction
optoinivalue = digitalRead(optoini);
if (optoinivalue == HIGH) {
digitalWrite(dirPin, LOW); //Set motor direction clockwise
}
else {
digitalWrite(dirPin, HIGH); //Set motor direction anticlockwise
}

// Spin motor
for(int x = 0; x < stepsPerRevolution; x++)
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(300);
digitalWrite(stepPin, LOW);
delayMicroseconds(700);
}
}

Does anyone have a test LUA script that they can use in Airmanager?

I’m expecting to receive a 28BYJ-48/ULN2003, but in the meantime, I want to test the Nema17.

Thanks.

User avatar
jph
Posts: 2853
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Test with Nema 17 and DRV8825.

#2 Post by jph »

Where and why are you using an optocoupler ???
Joe. CISSP, MSc.

User avatar
jph
Posts: 2853
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Test with Nema 17 and DRV8825.

#3 Post by jph »

checkout - https://www.makerguides.com/drv8825-ste ... -tutorial/

the basic wiring and info for the 8255
then look at the vid 066 example - https://siminnovations.com/wiki/index.p ... VID66-06_2

That is all you should need. Just set the appropriate pins on the 8255 (RES, SLEEP, EN, M1, MX, MY etc ( microstep)) before applying the vid 066 code and you only need step and direction.
Joe
Joe. CISSP, MSc.

Fermin
Posts: 7
Joined: Fri Feb 12, 2021 4:44 pm

Re: Test with Nema 17 and DRV8825.

#4 Post by Fermin »

Thanks jph.

I have no problem using the stepper with Arduino. As I explained earlier, with that Arduino script I can totally control the Stepper.

I’ve already discovered where the problem is. The problem is AirManager. If you use pins 2 and 3, the Stepper doesn’t work. Now I’m using pins 5 and 6 and it already works perfectly.

This Wiki script does not work with Arduino Mega2560:

id = hw_stepper_motor_add("VID66-06", 200, 10, true, "ARDUINO_MEGA2560_A_D2", "ARDUINO_MEGA2560_A_D3")
-- Set position
hw_stepper_motor_position(id, 0.5)

Instead, this modified script, works on Arduino Mega2560:

id = hw_stepper_motor_add("VID66-06", 200, 10, true, "ARDUINO_MEGA2560_A_D5", "ARDUINO_MEGA2560_A_D6")
-- Set position
hw_stepper_motor_position(id, 0.5)

Someone should correct the Wiki example of VID66-06.

Now I can continue to build my cabin.
Thanks again.

User avatar
Ralph
Posts: 7918
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Test with Nema 17 and DRV8825.

#5 Post by Ralph »

The pins don't matter, you can choose any pin you want, except for D0 and D1.

User avatar
jph
Posts: 2853
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Test with Nema 17 and DRV8825.

#6 Post by jph »

Hi @Ralph
It seems strange that he has it working though - but not on pins D2 and D3 ?
Joe. CISSP, MSc.

User avatar
Ralph
Posts: 7918
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Test with Nema 17 and DRV8825.

#7 Post by Ralph »

There are problems with the VID control in 4.0.x anyway, so that's probably what you're seeing. It is better to use the beta, should be working in the beta.

User avatar
Ralph
Posts: 7918
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Test with Nema 17 and DRV8825.

#8 Post by Ralph »

I can't get our VID to work somehow, but the sequence does not change if I select D2 and D3, or D5 and D6, they are exactly the same.

Post Reply