Uncategorized

motor backlash problem notes

tlfong01

tlfong01

6962

Fri 10:14

So I now know how to use a stepper motor to move a flap 180 degrees. However I found the stepper motor is too bulky, and seems not strong because it has no gear. A better choice might be the geared stepper 28Byj48. However, 28Byj48 is unipolar and I need to modify it to become bopolar for my stepper driver. After some consideration, I think I might use a DC motor, as suggested by the OP, but a small version, the geared N20 DC motor. I will also use the L298N, also suggested by the OP.

(22) I am using the N20 gear encoder motor for experiments. If you would also like to try a similar one, I would recommend the following: JGY-370GB Worm Gear DC Encoder Motor 12V 5-128RPM Cover Dustproof Self-Lock Reversible For Automatic Curtain Machinery Parts US16 aliexpress.com/item/….

(23) This worm gear motor is self locking and good for auto home curtain app, but I am not sure if also good for the T shirt folder.

Justin Priede

Justin Priede

361

@tlfong01 Again, I cannot thank you enough for the time you are putting in to help me… as a novice, it is very insightful to see your troubleshooting process and understand how you debug these sort of things.

I have access to a much bigger power supply today during a class which will hopefully give me more reliable results and might be the road to take… I will keep you updated with details of said power supply and how it impacts my code and motors.

If I understand, you are saying DC motors might be able to work for this project? Are you still testing different motors to see which works best? In doing research before I started, I also came across this video which accomplishes the same but in a different way than I would like to do. youtube.com/watch?v=rhWaHSUVGco

He uses a DC motor that seems as powerful as mine… it might provide some useful insight.

tlfong01

tlfong01

Ah, your comments and references are very good. I need to watch the video again before I can give some comments. See you later.

4 hours later…

tlfong01

tlfong01

6962

Fri 14:39

I am doing some googling on shirt folder. I skimmed through them and found your youtube video is the most useful.

(24a) Automatic clothes folding machine – Sherry Huang 2019jun13, 12,191 views, 40 subscribers
youtube.com/…

(24b) How to make a T shirt folding machine – 2016mar21, 359,386 views
youtube.com/…

(24c) Clothes Folders – BoxLegend, 2020jul17, 41,670 views
youtube.com/…

(24d) T-SHIRT Folding and Packaging Machine – Speedy-T, 2016sep20 785,022 views
youtube.com/…

(24e) How to Fold a Shirt – TM Lewin, 2010apr23, 1,637,846 views

(see full text)

I have no idea on which DC motor to use. For this prototyping stage, I will start feasibility study with DC motors with gear and encoder. I am not playing with BLDC motors, because I too little experience (and already fried a couple of those a bit expensive ones).

tlfong01

tlfong01

6962

Fri 15:01

And we need to look carefully your motor spec, to get a rough idea of how powerful it is:

user image

tlfong01

tlfong01

6962

Fri 15:18

Your motor only weighs 90g and the shaft diameter is only 2.5 mm. My big motors have shaft diameters of 3mm, 4mm, 5mm, and even 6 mm. So I would classify your motor as toy motor grade. Of course it can use a gear box to drive heavy loads, but only slowly.

user image

tlfong01

tlfong01

6962

Fri 15:42

I forgot how to use the L298N. So I am reading old posts to refresh my memory.

How to use motor drivers with H-bridge and PWM input, to control direction and speed of DC motors? – EESE 2020jul16 Viewed 2k times
electronics.stackexchange.com/…

(removed)

tlfong01

tlfong01

6962

Fri 15:56

user image

user image

user image

2 hours later…

tlfong01

tlfong01

6962

Fri 18:13

Now I am assembling the N20 + L298N module.

user image

tlfong01

tlfong01

6962

Fri 18:27

And I found the Last Minutes Engineers have a very newbie friendly tutorial and pinout.

user image

2 hours later…

tlfong01

tlfong01

6962

Fri 20:39

Now I am using a scope to display the N20 quadrature encoder output signals A, B, when motor power is 12VDC. I found motor speed is about 56 rpm (3,333pps).

user image

2 hours later…

Justin Priede

Justin Priede

Fri 22:29

I also noticed we can use PWM – Pulse width modulation to control speeds and perhaps influence torque. I am not sure if it is needed

tlfong01

tlfong01

6962

Fri 22:41

Ah, (1) I am sure that for DC motor using L298N, PWM frequency does not affect speed, but duty cycle does, because more current flows each cycle. On the other hand, for stepper motor and stepper motor controller, step pulse frequency does affect speed, higher frequency means higher speed.

(2) But I have not been paying much attention to the relation between torque and frequency, because I know that if I don’t have enough torgue, I would get a stronger motor, or increase gear ratio, sacrificing speed, which is not critical in my Micky Mouse projects. Ah, bed time. See you tomorrow.

4 hours later…

Justin Priede

Justin Priede

Sat 2:22

That all makes sense… Hope you sleep well. I know I have thanked you a few times but I wanted to thank you again. I cannot believe someone would give so much time to a stranger. You are helping me out more than you know.

17 hours later…

tlfong01

tlfong01

6962

Sat 19:44

Now I have placed both the N20 motor board and L258N driver board on a bigger proto board. Next step is to do offline, manual, jumper signal/wiring test.

user image

tlfong01

tlfong01

6962

Sat 19:57

Now I have extracted the L298N’s 3 control signals for each motor (enable, in1, In2) to a control signal routing board and by hand use jumpers wires to move motor forward and backward. Next step is to use Pico micropython program to set the control signals to move the motor.

Offline moving motor by hand jumper wires: youtu.be/ODebwJUs96w

Justin Priede

Justin Priede

Sat 20:55

Looks sweet! Excited to see what results you get with your code.

1 hour later…

tlfong01

tlfong01

6962

Sat 22:12

So I have modified my pico micropython tmc2225 stepper driver functions to L298N DC motor. The tmc2225 to L298n conversion is easy, because tmc2225 has 3 control signals: Enable, Direction, StepPulse, and L298N also has three, enable, in1, in2.

But before assigning timing parameter ranges to the new L298N control functions, I usually cheat by first using my favourite cheapy XY-PLWM PWM/sig gen to scan for a rough range that the L298N and N20 would operate/move, then do the software fine tuning. Now I am by hand set the In1, In2 to High and Low, and use the XY-LPWM sig gen to send the WPM signal (1kHz, 50% duty) to see if the motor moves. The YouTube results is shown below.

L298N + N20 test results, using XY-LPWM sig gen as PWM signal to the L298N enable terminal: youtu.be/Pl0WBa975CE

18 hours later…

tlfong01

tlfong01

6962

Sun 16:06

Now I apply 5kHz, 50% duty cycle to the L298N, N20 motor turns at 34 rpm.

user image

2 hours later…

tlfong01

tlfong01

6962

Sun 17:43

I also tried 2kHz and 1kHz, and found speed ~= 42 rpm. So I concluded that 1kHz is good benchmark frequency.

user image

user image

Next step is to keep applying 1kHz, but vary duty cycle, to confirm if higher duty cycle means higher speed.

1 hour later…

tlfong01

tlfong01

6962

Sun 18:55

Now then, 1 kHz, 50%, 90%, and 20% duty cycle results. (10% duty cycle cannot start motor.)

user image

user image

user image

Results summary: 20% dc = 27.3 rpm, 50% dc = 4.16 rpm, 90% dc = 47.6 rpm

2 hours later…

tlfong01

tlfong01

6962

Sun 20:40

Test Results Summary and Excel Chart.

-------------------------------------------
L298N N20 Test Results
-------------------------------------------
DutyCycle (%)   0   10    20   50   90  100
Speed (rpm)     0    0  27.3 41.6 47.6   56
-------------------------------------------

user image

The time has come to do some Pico MicroPython dual core programming.

1 hour later…

tlfong01

tlfong01

6962

Sun 21:45

Now I have written a very basic test function to run the N20 motor for four seconds. Next step is modifying this function to run the motor at specified speed (duty cycle) for a specific time (as small as a millisecond).

# L298N Config/Functions

l298nEnblPinNum   = 20
l298nIn1PinNum    = 21
l298nIn2PinNum    = 22

def l298nDsblDriver(enblPinNum):
    enblPin = gpOutPinDict[str(enblPinNum)]
    setGpOutPinLow(enblPin)
    return

def l298nSetDirCcw(in1PinNum, in2PinNum):
    in1Pin = gpOutPinDict[str(in1PinNum)]
    in2Pin = gpOutPinDict[str(in2PinNum)]
    setGpOutPinLow(in1Pin)
    setGpOutPinHigh(in2Pin)
    return

def l298nSetDirCw(in1PinNum, in2PinNum):
    in1Pin = gpOutPinDict[str(in1PinNum)]
    in2Pin = gpOutPinDict[str(in2PinNum)]

(see full text)

Locking down bed time. Call it a day. See you tomorrow.

13 hours later…

tlfong01

tlfong01

6962

yst 10:46

Some more interesting videos:

(1) Senior Design Clothes Folding Machine – WashU 2017dec17
youtube.com/…

(2) Automatic clothes folding machine – 2018jun22
youtube.com/…

(3) ZS AF818 CNC Full Automatic edge folding machine for leather – 2019feb22
youtube.com/…

tlfong01

tlfong01

6962

yst 11:00

Yet one more video, doing one step further, 7.5 million views.

How to Fold T-Shirts – Home Organizing by Alejandra.tv, 2021aug14, 1.07M subscribers, 7,520,224 views
youtube.com/…

tlfong01

tlfong01

6962

yst 11:30

Pico MicroPython L298N DC motor driver and N20 DC gear encoder motor programming design notes, Part 1.

Now I am writing a micropython function to do PWM speed/movement control of the N20 motor movement. The function spec/user requirement is described below.

Tshirt Folder Functional Spec v0.1.

Move the L298N controlled N20 DC gear encoder motor 180 degrees, in a couple of seconds, with a couple of degrees accuracy.

tlfong01

tlfong01

6962

yst 12:13

I first move the abstraction level from L298N driver to N20 motor. So from now on I will work at the motor level, rather than driver level. Below is the function to move motor forward and backward at full speed.

def testN20V01(): # *** Move N20 motor at full speed for 2 seconds forward, 2 seconds backward ***
    printProgramName()
    print('Begin testN20V01(), ...')
    n20StopMotor(l298nEnblPinNum) # Setup/Config motor
    n20SetDirForward(l298nIn1PinNum, l298nIn2PinNum)

    n20MoveFullSpeed(l298nEnblPinNum) # move motor full speed, 4 seconds
    pause(fourSeconds)
    n20StopMotor(l298nEnblPinNum)

    n20SetDirBackward(l298nIn1PinNum, l298nIn2PinNum) # move motor backward, full speed, 4 seconds
    n20MoveFullSpeed(l298nEnblPinNum)

(see full text)

And the complete program listing: penzu.com/p/3aff5b07

2 hours later…

tlfong01

tlfong01

6962

yst 14:09

Suggestion to use a stronger motor. As I said earlier, we need a stronger motor to flip the flap. Yous with no reduction gear is too weak, mine even with gear is also too weak. So I searched my junk box to find a strong guy. I used it for my other Micky Mouse toy project, a cat food feeder. The motor is used to open a flap, so the cat food biscuits would fall to the bowl, …

The product sheet is list below. You might like to follow my experiments to see if I have any luck.

ChiHai Motor CHW4632-370 permanent magnetic worm reducer motor power off self-locking 6/12/24V (6mm shaft dia) – AliExpress US$7 ~ 11
aliexpress.com/item/…

And I upload the spec for reference.

user image

I noticed that the no load current is 200mA, rated current is 2A, and the stall current is 5.5A

This reminds me one of the ways to “sense” that the T-shirt folder flap has reached either of the two limiting positions, motor current suddenly jumping from 2A to over 5A. At these two positions the program would stop moving the motor. Another way is to use position sensors such as a Hall effect sensor.

So this guy is using a Hall effect sensor:

***Always stop the motor at the same spot*** – Asked 19 days ago Active 19 days ago Viewed 343 times
electronics.stackexchange.com/…

1 hour later…

tlfong01

tlfong01

6962

yst 15:42

Now I have mounted the ChiHai motor to my testing gear. The ChiHai motor also has an encoder and the 6 pin connector is identical to the N20 motor. So all my software for N20 can readily moved to ChiHai 4632-370.

user image

5 hours later…

tlfong01

tlfong01

6962

yst 20:25

Another closed loop feedback control signal is from the switching regulation PSU, eg LM2596 2A max PSU. For the T-shirt folder machine, if the flap is at either limiting position, the motor can no longer move, so will stall at this point, now the current will suddenly jump from about 2A to the stall current 5A. however, the short circuit current protection circuit of the LM2596 would take off, prevent damaging the PSU and motor.

I watched Ty’s video a second time, and found many more things inspiring.

I made an Automatic Shirt Folding Machine DIY Builds – Ty Palowski, 2020jul20, 3.05K subscribe, 31,154 views
youtube.com/…

user image

And Texgraff is fully automatic!

Automatic T-Shirt Folding Machine – Texgraff, 2015jul05, 129,364 views, 31.7K subscribers
youtube.com/…

13 hours later…

tlfong01

tlfong01

6962

9:56

For simple feedback signals at both ends of the motor 180 degrees journey, you might also like to consider Hall sensor and Reed switches.

(removed)

(1) Magnetic hall sensor – AliExpress
aliexpress.com/w/…

(2) Magnetic Reed Switch – AliExpress
aliexpress.com/…

tlfong01

tlfong01

6962

10:39

This one is practical, with a drawer below for storing the folded shirts.

Semi-auto cloth folding machine using Arduino Uno, servo motor and flip fold- Polimas, 18,617 views
youtube.com/…

This one is academic, with a published paper
Cloth Folding Machine – WashU Project
openscholarship.wustl.edu/cgi/…

tlfong01

tlfong01

6962

11:04

And Thermotron is impressive.

Automatic folding & bagging & sealing for casual clothes (STP950/PV38/KL55) – Thermotron 2010jun17, 159,350 views
youtube.com/…

4 hours later…

tlfong01

tlfong01

6962

15:13

Now I have written a program to move the motor 180 degrees 10 times.

After 10 half turns of 180 degrees each, the motor moves to its original position, with an offset of a couple of degrees.

The complete program list is as below.

Program moving motor 180 degrees 10 times: penzu.com/p/f783fc62

tlfong01

tlfong01

6962

15:28

Now the video. youtu.be/OsKmU_t5BiY

I read the OP”s program and found that he seems to forget to “fast stop” the motor. This is the fast stop function I am using:

def l298nFastStopMotor(enblPinNum, in1PinNum, in2PinNum):
    enblPin = gpOutPinDict[str(enblPinNum)]
    in1Pin = gpOutPinDict[str(in1PinNum)]
    in2Pin = gpOutPinDict[str(in2PinNum)]
    setGpOutPinHigh(enblPin)
    setGpOutPinHigh(in1Pin)
    setGpOutPinHigh(in2Pin)
    return

4 hours later…

tlfong01

tlfong01

6962

19:25

The previous function moves 180 degrees x 2 = 360 degrees, but always in the same direction, and makes an offset of a couple of degrees from the home position.

Now if moving forward and backward, as specified by the OP, then the offset from home position is more than a couple of degrees (for ten repetitions). The reason is “black lash“, as explained below.

user image

The OP’s motor has no gear, therefore no backlash problem. If he uses gear, then he has the back lash problem. As explained by the Oriental Motor, one way to prevent backalsh is to use stepper motor. Another workaround is to advance “a little bit first” when reversing the direction, so to compensate the backlash slack. However, the backlash magnitude might depend on the gear assembly, therefore not a good solution.

If not using stepper motor, a better solution is to use position/rotary sensors such as Hall or optical sensor. This would be explored/experimented next.

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.