Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: Modify Arduino Polorgraph Code to use EasyDriver library?
MiniMark33
Newbie
Posts: 1
Permalink
Post Modify Arduino Polorgraph Code to use EasyDriver library?
on: July 24, 2014, 15:02
Quote

Hello all!

I'm working on a sketcher, and want to use Polargraph for the drawing aspect of it. Only problem is, I do not have the PolarShield motor controller, I only have 2 EasyDrivers (as seen here: https://www.sparkfun.com/products/10267 ) I was wondering if it is possible to modify the Arduino code to use this http://forum.arduino.cc/index.php/topic,38084.0.html stepper library instead of the default AFStepper library. Also, if this is possible, how would I go about doing this?

Thanks in advance for any answers!

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Modify Arduino Polorgraph Code to use EasyDriver library?
on: July 24, 2014, 20:54
Quote

Hello, the good news is that a polarshield is controlled in exactly the same way as easydrivers. During the start, you specify three pins for each driver:
- enable
- direction
- step

Polargraph uses Accelstepper. In the version for the UNO, then it is designed to be used in conjunction with Adafruit's motorshield, and so it uses AFMotor. In the version for the arduino MEGA, then it is designed to use _any_ serial stepper driver that has the three pins listed above. You would need to wire your steppers to the same pins as it expects, and voila, it'll work.

sandy noble

dchas
Newbie
Posts: 8
Permalink
dchas
Post Re: Modify Arduino Polorgraph Code to use EasyDriver library?
on: August 25, 2014, 08:30
Quote

Using the Schmalhaus EasyDriver with a combination of the polarshield and a1 sketch. Works perfect. You don't need any extra stepper drivers. Just set the enalbe, direction and step pins

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Modify Arduino Polorgraph Code to use EasyDriver library?
on: August 27, 2014, 22:29
Quote

yep, just replace the AFMotor stuff, and the existing AccelStepper declarations with the versions from the _polarshield variant:

AccelStepper motorA(1,MOTOR_A_STEP_PIN, MOTOR_A_DIR_PIN); 
AccelStepper motorB(1,MOTOR_B_STEP_PIN, MOTOR_B_DIR_PIN); 

https://github.com/euphy/polargraph_server_polarshield/blob/master/configuration.ino#L99-L100

and

  pinMode(MOTOR_A_ENABLE_PIN, OUTPUT);
  digitalWrite(MOTOR_A_ENABLE_PIN, HIGH);
  pinMode(MOTOR_B_ENABLE_PIN, OUTPUT);
  digitalWrite(MOTOR_B_ENABLE_PIN, HIGH);
  motorA.setEnablePin(MOTOR_A_ENABLE_PIN);
  motorA.setPinsInverted(false, false, true);
  motorB.setEnablePin(MOTOR_B_ENABLE_PIN);
  motorB.setPinsInverted(true, false, true);

https://github.com/euphy/polargraph_server_polarshield/blob/master/configuration.ino#L122-L129

Taruuk
Newbie
Posts: 3
Permalink
Post Re: Modify Arduino Polorgraph Code to use EasyDriver library?
on: September 29, 2014, 03:36
Quote

Hey guys. Im in the same situation as MiniMark however I'm a little lost while trying to implement the many files that come along with this sketch. In which files would I replace the stepper shield code with the AccelStepper code?

Im still very new to this so small words and diagrams go a long way. lol

polargraph_server_a1
1x Adruino Uno
2x easydriver 4.4
2x 4 lead stepper (bipolar)

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: Modify Arduino Polorgraph Code to use EasyDriver library?
on: September 29, 2014, 09:30
Quote

Oh hi, I noticed the links embedded in the previous post were broken - so I've fixed them. They point to the file that needs to be updated.

So the motors are configured in configuration.ino. I don't _think_ you'll need to change code in other files. You can actually remove the whole section https://github.com/euphy/polargraph_server_a1/blob/master/configuration.ino#L21-L73 and replace it with the section https://github.com/euphy/polargraph_server_polarshield/blob/master/configuration.ino/#L99-L138.

You will need to define which pins you have used to wire it up by putting

  #define MOTOR_A_ENABLE_PIN 3
  #define MOTOR_A_STEP_PIN 4
  #define MOTOR_A_DIR_PIN 5
  
  #define MOTOR_B_ENABLE_PIN 6
  #define MOTOR_B_STEP_PIN 7
  #define MOTOR_B_DIR_PIN 8

just above it.

Avoid using pin 9 - it's the pen lift servo pin. (Unless you want to redefine that too - https://github.com/euphy/polargraph_server_a1/blob/master/polargraph_server_a1.ino#L88)

good luck!
sn

Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.019 seconds.