Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1] 2
Author Topic: ULN2003_DRIVER Support
seth
Newbie
Posts: 2
Permalink
Post ULN2003_DRIVER Support
on: September 19, 2014, 02:51
Quote

Sandy,
I've just done a pull request, which adds support for cheap stepper motors with ULN2003 drivers ( less than $5 US shipped: DealExtreme ).

I've added comments that give a good start for tuning, but it's not perfect. I started with the spec sheet for the steppers, and since they are geared, they have a huge number of steps per rev. However, I haven't yet dialed in the settings yet.

I've included a wiring diagram in Polargraph_server_a1.ino to get the drivers hooked up. (The code is probably not the best place to put the diagram and instructions, but oh well)

//Connection Directions
// MotorA
//ULN2003 Arduino AcceStepper Init
//IN1 2 2
//IN2 3 4
//IN3 4 3
//IN4 5 5
// MotorB
//ULN2003 Arduino AcceStepper Init
//IN1 6 6
//IN2 7 8
//IN3 8 7
//IN4 9 9

Using pin 9 for Motor B creates a conflict with the pen lift servo, so I added in a comment to the servo pin define. I changed the servo pin to 10 on my polargraph.

I've got it set up and running nicely on my diy polargraph!

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: September 19, 2014, 22:28
Quote

Cool work, thanks! - I'll have a look over it and give it a shot later this weekend!

thanks!
sn

jsecondo
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: December 21, 2014, 01:57
Quote

Hi Seth,

I'm having a lot of trouble with the software. Using an Arduino Mega256 with Keyes L298N controllers. L298 needs 4 inputs to work and can't figure out what to modify in the software since all the examples I've seen work with 2 inputs for the controllers (steps, direction).

Do you mind sharing the config you used for the sofware (which is driving me crazy with comiling errors by the way).

Thanks

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: December 21, 2014, 11:07
Quote

I know Seth hasn't replied here yet, but I'll weigh in. I forgot to update this thread to say that I eventually did merge the changes into polargraph_server_a1, albeit in a slightly different form.

You need to change the first set of #defines in polargraph_server_a1.ino to make sure that UNL2003_DRIVER is the only line that is not commented out:

//#define ADAFRUIT_MOTORSHIELD_V1
//#define ADAFRUIT_MOTORSHIELD_V2

// Using discrete stepper drivers? (eg EasyDriver, stepstick, Pololu gear),
// choose SERIAL_STEPPER_DRIVERS and define your pins at the bottom of 'configuration.ino'.
//#define SERIAL_STEPPER_DRIVERS 

// Using a signal amplifier like a UNL2003? 
#define UNL2003_DRIVER

Then you need to comment out all of the #include lines at the top of in configuration.ino that would usually load the adafruit libraries.

The bit you're interested in is the motor declarations:

AccelStepper motorA(8, 6,8,7,9);
AccelStepper motorB(8, 2,4,3,5);

configuration.ino

Those numbers (6,8,7,9 and 2,4,3,5) are the arduino pins that Seth used to wire up the UNL2003s.

jsecondo
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: December 21, 2014, 18:37
Quote

I'll jump on coding right away. Thanks for the prompt answer Sandy.

By the way what does the 8 mean in: AccelStepper motorA(8, 6,8,7,9);
I mean the first 8.

Hope to share pics of the machine soon.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: December 21, 2014, 20:48
Quote

That's a good question. http://www.airspayce.com/mikem/arduino/AccelStepper/classAccelStepper.html#a73bdecf1273d98d8c5fbcb764cabeea5 has the answer.

But I think this means: "(8) means a 4 wire half stepper (4 pins required)". That page linked to above has a better description of the different AccelStepper settings.

It's better to use AccelStepper::HALF4WIRE instead of 8, because it actually means something. AccelStepper::FULL4WIRE might be a good one to use too.

sn

jsecondo
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: December 21, 2014, 21:53
Quote

Sandy,

The link was very clear. Thanks.

Now with the problems.

In the serial monitor in the Arduino IDE I can see:
POLARGRAPH ON!
Loaded width:650
Loaded height:650
Loaded mmPerRev:nan
Loaded steps per rev:800
Loaded step multiplier:255
Loaded down pos:90
Loaded up pos:180
Recalc mmPerStep (nan), stepsPerMM (nan)
Recalc pageWidth in steps (-2147483648)
Recalc pageHeight in steps (-2147483648)
READY
READY

So I suspect that everything's ok in the Arduino board. TX lights up every 5 seconds or so. Problem starts with Controller. Doesn't find serial port.

Any Ideas?

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: December 21, 2014, 22:02
Quote

Cool, you're into the realms of serial port debugging here, so basically lots of plugging, unplugging, resetting, waiting, combinations thereof.

Essentially, if you've managed to upload the code, then you've got it working. At least, you know it can work. Close Arduino, open the Polargraph Controller and choose the serial port from the subwindow that opens when you go to setup -> serial port.

sn

jsecondo
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: December 21, 2014, 23:48
Quote

ok. Found the answer in another post: sudo ln -s /dev/ttyACM0 /dev/ttyS42

Finally I got controller to read the machine.

Now with the settings.

All measures are in steps? except of course those where mm is specified.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: December 22, 2014, 00:21
Quote

Aha, good spot. Off the top of my head, it's only the speed settings (and stepsPerRev) that are in steps, everything else should be mm.

Set the mmPerRev, stepsPerRev and stepMultiplier first, then start setting the size of the machine.

jsecondo
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: December 22, 2014, 00:35
Quote

Thanks Sandy. I feel I'm right on track now.

I'll send pictures as soon as I get the first drafts.

Uesrname
Newbie
Posts: 3
Permalink
Post Re: ULN2003_DRIVER Support
on: December 25, 2014, 08:03
Quote

Hello!

I am currently trying to get this set up myself (ULN2003A) and I'm fairly certain that everything is wired up correctly. I have uploaded a sketch to the Arduino and from there I can attempt to move the pen to a point in Polargraphcontroller but as i click to confirm the point it starts up and will only run clockwise on both motors despite what area of the controller I click on.

I may be totally off base here but what I gathered was that I was as well supposed to switch pins 7,8 and 4,3?

Hopefully y'all have some idea what may be happening but if not, I hope ya'll having a good night.

jsecondo
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: December 26, 2014, 03:51
Quote

NO, do not switch pins.
The original code was switched and didn't work for me.
I tried this and worked fine.

AccelStepper motorA(8, 6,7,8,9);
AccelStepper motorB(8, 2,3,4,5);

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: December 26, 2014, 13:03
Quote

The pins that are specified in the accelstepper declaration are important, but only insomuch as the map directly to the motor wires. The original code was switched and worked fine for the original writer, so lets agree that there are many ways of wiring these modules up, many kinds of motors, and in fact many different ULN2003 driver modules, some of which might well map input pins to motor wires in a weird way.

At the first problem, you should load up one of the accelstepper example sketches, and make sure you can get things running WITHOUT all the extra baggage of the polargraph stuff around it, that also all needs to be got right to work.

The examples are listed at http://www.airspayce.com/mikem/arduino/AccelStepper/examples.html, but you can load them in Arduino through file->examples->accelstepper.

jsecondo
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: September 16, 2015, 19:38
Quote

Back to the project.....still trying to set the parameters for the configuration.

The steppers I'm using are from 2 scanners and both are same brand and model. The diff with all the machines I've seen is the steppers have reduction gears (3 of them). I'm having trouble to determine the MMPERREV and STEPSPERREV since the reduction gears are in place. Thought the reduction might give the machine more precision.

Ideas on how to determine the parameters?

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: September 20, 2015, 21:09
Quote

Not a straightforward way of doing it using the standard polargraph firmware, but you can easily knock up a little arduino sketch that will run for a couple of thousand steps, reporting it's position, and you just make a note at which step number the motor has made one full turn.

http://forum.arduino.cc/index.php?topic=91243.0

sn

seth
Newbie
Posts: 2
Permalink
Post Re: ULN2003_DRIVER Support
on: November 30, 2015, 05:30
Quote

I just noticed there are replies on this thread...I'm glad someone found use in my addition.

@jsecondo: I'm not sure steps/rev actually matters, unless you find it in a spec sheet for your steppers.
I suggest just setting it to something reasonable, and making your adjustments in mm/rev, based on your actual measurements.
Fyi, I have my steps/rev set at 4076, but I'm not sure of the source.

falldeaf
Newbie
Posts: 1
Permalink
Post Re: ULN2003_DRIVER Support
on: January 4, 2016, 21:53
Quote

Hey! Sorry for jumping into an old post, but I'm attemping to use this very bit of code. I've got some 28YBJ-48 steppers with the ULN2003 drivers hooked up to an arduino. Everything compiles correctly but I'm not getting any motion on the steppers. However, I also noticed this line:

//for a 28YBJ-48 Stepper, change these parameters above
//Step angle (8-step) 5.625deg, 64 steps per rev
//Step angle (4-step) 11.25deg, 32 steps per rev
//gear reduction ratio 1/63.68395

But I'm not understanding it, could someone explain what is meant here?

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003_DRIVER Support
on: January 5, 2016, 22:02
Quote

This section is to help you work out what motorStepsPerRev should be with geared motors.

//for a 28YBJ-48 Stepper, change these parameters above
//Step angle (8-step) 5.625deg, 64 steps per rev
//Step angle (4-step) 11.25deg, 32 steps per rev
//gear reduction ratio 1/63.68395

// motorStepsPerRev = 32 * 63.68395 = 2038; //for 4 step sequence
// motorStepsPerRev = 64 * 63.68395 = 4076; //for 8 step sequence

// motorStepsPerRev = 4076;
// mmPerRev = 63;
// DEFAULT_STEPS_PER_REV = 4076;
// DEFAULT_MM_PER_REV = 63;

motorStepsPerRev is usually set in the Polargraph Controller app, and sent to the machine as part of the machine spec, rather than being hard-coded in the firmware.

sn

sanja
Newbie
Posts: 9
Permalink
Post Re: ULN2003_DRIVER Support
on: April 9, 2016, 19:18
Quote

Hi. Sorry for touching this ancient thread, but there is an issue with this code:

// MotorA
//ULN2003  Arduino  AcceStepper Init
//IN1      2        2
//IN2      3        4
//IN3      4        3
//IN4      5        5
// MotorB
//ULN2003  Arduino  AcceStepper Init
//IN1      6        6
//IN2      7        8
//IN3      8        7
//IN4      9        9

.......

AccelStepper motorA(8, 6,8,7,9);
AccelStepper motorB(8, 2,4,3,5);

It looks like motorA and motorB are swapped in wiring diagram (actual code appears to be OK).

MotorB is moving in the wrong direction, and changing first argument in motorB.setPinsInverted(true doesn't help. Any ideas?

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