aenniw / ARDUINO

MIT License
357 stars 63 forks source link

Wrong direction #110

Closed radze90 closed 4 years ago

radze90 commented 4 years ago

Hi,

i have the problem that the motor moves in the wrong direction. If I look up at the shaft, it turns to the left when I press the button up and the count goes up. But the table goes down.

I checked the wiring but can't find the problem.

It seems to me that the rotary encoder (ky-040) is programmed the wrong way round.

radze90 commented 4 years ago

https://youtu.be/SLC-cCDy5Zs

my key sorting is set, 1, 2, 3, Up, Down

iLLiac4 commented 4 years ago

Revers motor position.

radze90 commented 4 years ago

Revers motor position.

Is there a configuration for this in the program code?

iLLiac4 commented 4 years ago

Hmm. I would phisically switck wires going to the motor.

radze90 commented 4 years ago

Hmm. I would phisically switck wires going to the motor.

When I do this, the motor turns in the other direction, but the display is wrong. When I press the button up, the display goes down. Same the other way round.

So the error is between key and display.

Edit: I have the handle of the table on the right side. I think it was designed for the left side?

iLLiac4 commented 4 years ago

https://github.com/aenniw/ARDUINO/issues/75

aenniw commented 4 years ago

If you have relay version just upload one of these based on your sensor...

nanoatmega328-irelays
nanoatmega328-iurelays
radze90 commented 4 years ago

If you have relay version just upload one of these based on your sensor...

nanoatmega328-irelays
nanoatmega328-iurelays

thanks, but i have the H-Bridge Version

75

i will look, thanks

radze90 commented 4 years ago

changing pin from Sensor dosnt work for me

#define SENSOR_PIN0 2
#define SENSOR_PIN1 3

default settings: The motor rotate only to the wrong direction.

aenniw commented 4 years ago

try to update

    if (state == CCW) {
        analogWrite(l_pwm, 0);
        analogWrite(r_pwm, speed);
    } else if (state == CW) {
        analogWrite(r_pwm, 0);
        analogWrite(l_pwm, speed);
    }

to

    if (state == CCW) {
        analogWrite(r_pwm, 0);
        analogWrite(l_pwm, speed);
    } else if (state == CW) {
        analogWrite(l_pwm, 0);
        analogWrite(r_pwm, speed);
    }

in MotorBridge.cpp

radze90 commented 4 years ago

@aenniw it works with changing the sensor together

#define SENSOR_PIN0 3
#define SENSOR_PIN1 2

thx for help. Perhaps you could provide an option for this in configuration.h

aenniw commented 4 years ago

updated configuration.h so that polarity can be reversed in, #111 could you check if it works? Thx

radze90 commented 4 years ago

I cant check, but thanks for add this feature. my motor is somehow too weak ...