Motor spins further in one direction when commanded equally

Hey everyone I've got a problem either with my setup or code and could use some help.

System components:

-Arduino Uno
-L298N H Bridge
-Greartisan Gear-box motor (DC 12V / RPM 550)
-Radio Shack 4 AA battery pack

I have the battery pack powering the L298N directly and the Uno slaving power from the 5v regulator on the L298N.

The code I'm using is just barely altered from anothers project that was moving a linear actuator in and out.

Goal:

To draw a line (fishing line) onto and release off of a small reel (sewing bobbin connected to motor shaft with pin) a set distance up and a set distance down.

I am attempting to make the motor spin a set interval of time in one direction and the same interval of time downward to achieve the goal. The result however is that it always reels downward too far and stacks that error on each pass (regardless of time changes in the top of the sketch). Hopefully somewhere out there knows motors or code or both a bit better than I do and can help out.

Used code:
const int pushPin = 7;
const int pullPin = 6;

int pushState = LOW;
int pullState = LOW;

unsigned long pushTime = 0;
unsigned long pullTime = 0;
const int onTime = 7100;
unsigned long holdTime = 0;
const int flowTime = 3100;

void pushOn()
{
digitalWrite(pushPin, HIGH);
digitalWrite(pullPin, LOW);
}

void pushOff()
{
digitalWrite(pushPin, LOW);
digitalWrite(pullPin, LOW);
}

void pullOn()
{
digitalWrite(pullPin, HIGH);
digitalWrite(pushPin, LOW);
}

void pullOff()
{
digitalWrite(pullPin, LOW);
digitalWrite(pushPin, LOW);
}

void hold()
{
digitalWrite(pushPin, LOW);
digitalWrite(pullPin, LOW);
}

void setup()
{
pinMode(pushPin, OUTPUT);
pinMode(pullPin, OUTPUT);
}

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

void loop()
{
pushTime = millis();

while((millis() - pushTime) <= onTime)
{
pushOn();
}

if((millis() - pushTime) >= onTime)
{
pushOff();
}

holdTime = millis();

while((millis() - holdTime) <= flowTime)
{
hold();
}

if ((millis() - holdTime) >= flowTime)
{
pullTime = millis();

while((millis() - pullTime) <= onTime)
{
pullOn();
}

if ((millis() - pullTime) >= flowTime)
{
pullOff();
}
}
holdTime = millis();

while((millis() - holdTime) <= flowTime)
{
hold();
}

if ((millis() - holdTime) >= flowTime)
{
Serial.print("Flow Time = ");
Serial.println(millis() - holdTime);

}}

That is why motors that can be POWERED to specific conditions are used. Steppers and servos come to mind.

Brushed motors will always turn easier in one direction than the other. Bearings will always turn easier in one direction than reverse. That is the nature of the physical world.

Paul

Thanks for your input. It makes sense and I've ordered a stepper. Another fine person sent me a PM and helped me understand exactly what you said.

digs7:
Thanks for your input. It makes sense and I've ordered a stepper. Another fine person sent me a PM and helped me understand exactly what you said.

That is great! You can mark this post as closed, and start a new on when you discover the next problem. May not be so easy to figure out.
Paul

These links may help

Stepper Motor Basics
Simple Stepper Code

...R

If your "winch" is lifting something with significant weight, it will naturally go up slower than down. Try stopwatching both directions and adjusting the faster speed to match the slower.

Even without load, most DC motors have a bias and go faster in the "forward" direction, as the
brush contact points are advanced by a significant angle to counter-act the inductive lag of current
build up in the armature windings at high speed.

But yes, if you want positional control, you either need open-loop or closed loop position control,
not dead-reckoning with a DC motor.