Forum

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
sanja
Newbie
Posts: 9
Permalink
Post ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 9, 2016, 19:43
Quote

Hi. I have an issue with ULN2003 and will appreciate help troubleshooting it.

I've built polargraph from acrylic parts, mechanically it works nicely. Here is the photo of my setup:

Image

Arduino UNO has separate 9V 1A power supply.

The code looks like this:

in polargraph_server_a1:

#define UNL2003_DRIVER

const int DEFAULT_MM_PER_REV = 108; // Measured myself
const int DEFAULT_STEPS_PER_REV = 4075.7728; // For 8-step  control signal sequence
const int DEFAULT_STEP_MULTIPLIER = 1;

static float currentMaxSpeed = 1000.0;

in configuration.ino:

AccelStepper motorA(8, 2, 4, 3, 5); // Left stepper. 8-step
AccelStepper motorB(8, 6, 8, 7, 9); //Right stepper. 

  motorA.setPinsInverted(false, false, true);
  motorB.setPinsInverted(true, false, true); // This is from original package
//  motorB.setPinsInverted(false, false, true); // Changing first argument to False didn't help

Any ideas? Thanks in advance.

sanja
Newbie
Posts: 9
Permalink
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 9, 2016, 19:45
Quote

I tried to upload it using IDE 1.6.5, 1.6.6 and with latest stable - didn't help.

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 9, 2016, 21:05
Quote

What happened when you changed the initialisation line and swapped the pairs of wires?

AccelStepper motorB(AccelStepper::FULL4WIRE, 7, 9, 6, 8);

Not sure if you'd need to reverse the whole sequence, or just swap the pairs.

sn

sandy
Administrator
Posts: 1317
Permalink
sandy
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 9, 2016, 21:08
Quote

ps great looking machine 🙂

sanja
Newbie
Posts: 9
Permalink
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 10, 2016, 12:46
Quote

Surprisingly, nothing changed. Not quite sure - either there is something weird with the library or that's me not getting something right. Swapping pairs in all possible combinations didn't work either.

Anyway I gave up - I discarded ULN2003 and am hooking up the steppers directly to MotorShieldV1 (fortunately I have one). I bought the B5B-XH-A connectors to plug 28BYJ-48 into.

As for machine: I didn't have easy access to 3D-printer, so I went for laser cutting. Used 2mm acrylic sheet for sprockets (made of 3 layers, central is slightly smaller, which allows to hold the chain tightly and prevent it from falling on the side). The frame was meant to have holes exactly the size of office clips - they hold the frame very reliably. The drawing surface is the cheapest picture frame from IKEA. Call this "poor man's polargraph" if you'd like 😉

I'll share the AutoCAD drawing of my acrylic parts after I'll make this thing work.

sanja
Newbie
Posts: 9
Permalink
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 10, 2016, 19:54
Quote

OK, here is wiring "diagram" for bare 28BYJ-48 steppers without ULN2003 using Chinese clone of Adafruit Motor Shield v1 (labelled "DK electronics"). Note that 28BYJ-48 is a unipolar stepper, so it has 5 wires, not 4. Red wires of both steppers need to be connected to GND (located between M1 and M2 connectors).

Pin 9 of Arduino corresponds to the bottom connector labeled "Servo_2" on my Chinese shield. Upper connector (Ser_1 = pin 10) doesn't work with polargraph code, looks like there is a conflict of some sort. I tested them with basic "sweep" example shipped with stepper library, both are indeed functioning.

Image

I didn't need to hook external power to motor shield, I supplied extra 9V/1A power to Arduino UNO itself, everything works.

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 10, 2016, 23:25
Quote

When I use 28BYJ-48 motors, I don't connect the red wires to anything and I drive them as bipolar.
There are quite a few posts about this online, many of which that say you must cut a trace where the red cores connect in the motor, but I've never done that and I've never had a problem, apart from supplying a current that's just right for the motors.

sanja
Newbie
Posts: 9
Permalink
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 11, 2016, 08:51
Quote

Cutting is needed to increase torque: http://www.jangeox.be/2013/10/change-unipolar-28byj-48-to-bipolar.html It is not an issue here, I think.

sanja
Newbie
Posts: 9
Permalink
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 11, 2016, 08:54
Quote

Quote from kongorilla on April 10, 2016, 23:25
When I use 28BYJ-48 motors

Could you please share your configuration? You could use pastebin.com or similar resource to host these. Thank you in advance.

kongorilla
Pro
Posts: 362
Permalink
kongorilla
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: April 11, 2016, 19:45
Quote

I think it's driving as bipolar that increases the torque. The comments on the page you linked to include discussions regarding when cutting the trace is necessary (and the theory isn't verified).

I've used 28BYJ-48 motors on 'toy' plotters that use the cheap CNC shields you can buy from China (knock-offs of the Protoneer CNC shield) and are designed to work with GRBL. I did make a polargraph with them using an adafruit motor shield v1 a few years ago, but didn't do anything special to make them work (other than using the correct firmware, hooking up as bipolar, getting the steps per rev right, and supplying separate power that didn't overheat them).

Be sure to use full-step or half-step with them, and don't try to go too fast.

BumblebeeT-
oad
Newbie
Posts: 1
Permalink
BumblebeeToad
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: May 5, 2016, 20:44
Quote

I solved the mystery of motorB going in the wrong direction.
You have to swap the wire pairs.
motorB.setPinsInverted(true) does not really work, it produces dropouts.

This is working for me:
AccelStepper motorA(8, 6,8,7,9);
AccelStepper motorB(8, 5,3,4,2);

mskogly
Beginner
Posts: 26
Permalink
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: August 15, 2016, 12:05
Quote

How / where do you assign the pins for the motor. I tried this, does it look correct?

#ifdef UNL2003_DRIVER

#define motorPin1 22 // Blue - 28BYJ48 pin 1
#define motorPin2 24 // Pink - 28BYJ48 pin 2
#define motorPin3 26 // Yellow - 28BYJ48 pin 3
#define motorPin4 28 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)

#define motorPin5 30 // Blue - 28BYJ48 pin 1
#define motorPin6 32 // Pink - 28BYJ48 pin 2
#define motorPin7 34 // Yellow - 28BYJ48 pin 3
#define motorPin8 36 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)

// NOTE: The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper motorA(8, motorPin5, motorPin7, motorPin6, motorPin8);
AccelStepper motorB(8, motorPin1, motorPin3, motorPin2, motorPin4);

#endif

mskogly
Beginner
Posts: 26
Permalink
Post Re: ULN2003 & 28YBJ-48: MotorB rotates in wrong direction
on: August 15, 2016, 12:58
Quote

I am also unsure about stepsPerRev, I've tried 4096 and multiplier 1

I finally got the gondola to move in the right direction. These are my settings

#ifdef UNL2003_DRIVER

#define motorPin1 22 // Blue - 28BYJ48 pin 1
#define motorPin2 24 // Pink - 28BYJ48 pin 2
#define motorPin3 26 // Yellow - 28BYJ48 pin 3
#define motorPin4 28 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)

#define motorPin5 30 // Blue - 28BYJ48 pin 1
#define motorPin6 32 // Pink - 28BYJ48 pin 2
#define motorPin7 34 // Yellow - 28BYJ48 pin 3
#define motorPin8 36 // Orange - 28BYJ48 pin 4
// Red - 28BYJ48 pin 5 (VCC)

AccelStepper motorA(8, motorPin5, motorPin7, motorPin6, motorPin8);
AccelStepper motorB(8, motorPin4, motorPin2, motorPin3, motorPin1);
//AccelStepper motorB(8, motorPin1, motorPin3, motorPin2, motorPin4);

#endif

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