I am struggling to get my motors to perform the same on each run. The first time I run the program, they will perform the same movement about 8/10 times. The second time I start the program, the movement does not perform the same as the last. It is significantly different. How can I get my motors…
(1) It is not clear what do you mean by “the same exact movement“. You need to be more precise. For example, can you tolerate a couple of degrees for a 180 degree movement, (2) It is not clear what do you mean by “decent speed and high torque“? (3) You need to specify more precisely. For example move 180 degrees in one second, or 0.1 second. (4) About the torques, you need to give a spec. Example, is a toy servo Towerpro MG996’s of 10kgf.cm good enough for you? Ref: html.alldatasheet.com/html-pdf/1131873/ETC2/MG996R/110/1/…
@tlfong01 I can spare a couple degrees but not much room for that… I need the action to be done in about a second and as for torque I am lifting about 50 grams. I am new to this so adding proper detail is harder for me.
(5) Ah, your updated spec is good enough to start doing experiments. So, let us say, for positioning, the tolerance is 5 degrees for a 180 degree movement, (6) Your updated spec of 50grams is also good, but you need to specify the diameter of the wheel or pulley lefting up the 50g load. For example, if the wheel is 10cm, then radius is 5cm, and the torque is 50gf.5cm, which can be handled by a toy servo or DC motor. (7) The speed of 1 second to do the movement is also OK for toy motors.
(8) Your motor seems to be for high speed applications, such as drilling or racing cards. If you don’t need high speed, you can consider a gear motor, which decreases speed, but increases torque.
You might like to skim my answers to motor questions below, to see how I am playing with DC, BLDC, and stepper motors. (9) DC Motor Speed Control using PWM electronics.stackexchange.com/questions/510755/… (10) BLDC Motor Control electronics.stackexchange.com/questions/590373/… (11) DC Motor with encoder electronics.stackexchange.com/questions/566586/…
(12) You might also like to let us know more details of your application, a sketch or a photo would be helpful. Then I can start compiling an answer and upload here.
@Justin Priede: (13) Some more references you might find useful: Always stop the motor at the same position (a) electronics.stackexchange.com/questions/608578/… Always stop the motor at the same position (b) electronics.stackexchange.com/questions/610405/… ESP32 Motor Control Pulse Width Modulator (MCPWM) docs.espressif.com/projects/esp-idf/en/latest/esp32/…
@CoderMike: (14) Yes, so I tried it with a step motor: youtu.be/sJkf4uP4J6c. (15) More details at the end of this chat about using tmc2225 stepping motor driver: chat.stackexchange.com/rooms/134387/….
Now I am using a toy spring balance, and a bag of nuts as load/force to calibrate the stalled torque of the stepper motor I have been testing. My testing plan is summarized below: (a) write a program to move the motor forward and backward between 90 degrees and 45 degrees. Gradually increase the loading, ie, bag of nuts, until the motor can no longer move to the 90 degrees limit. Then do the calculation to get the stalled torque. Below is the video illustrating my plan.: youtu.be/mryE3ayH27o
And by trial and error, I found that the loading of about 88 gram is the loading that the motor can just be able to move to the 90 degrees point. For the weight bigger than that the motor cannot move to the 90 degrees, perhaps 80 or 70 degrees. The radius of the wheel is about 4.5cm. So the stalled torque is 80gf.4.5cm ~= 360gf.cm. I will compile an answer after the OP makes comments or suggestions.
Wow@tlfong01 I cannot thank you enough for the time you are putting into this! I appreciate it more than you know. 50 grams might be causing some misdirection here. That was a guess but it could be fine in terms of experimenting. I have a attachment to my motor that connects to a rectangle of posterboard/cardboard. I am trying to move that flap a tad more than 90 degrees, does not have to be a full 180 degrees to fold a shirt. I am automating this process here: amazon.com/BoxLegend-folding-Clothes-Laundry-flipfold/dp/…
@Milliways the code I have provided works, it is connected to my two motors and interacts with them however I tell them.
I did realize these motors are meant for high speed rather than slow specific movements but I would like to use these if possible rather than buying separate more motors.
@Justin Priede, I agree with you of using the high speed motors in hand. I do have those kind of motor in my workshop. Perhaps I can test them later.
@NomadMaker: Yes, I very much with you that those 9V batteries are no good for testing motors, which might have a big starting current, causing the battery running out very soon.
@Justin Priede: (15) Now I am doing a feasibility study of your DC12V 12000rpm motor, checking out if it can do what my stepper motor can do – moving 180 degrees forward and backward, with a precision of a couple of degrees, using L298N DC motor driver, if possible. (16) My first impression of your AutoToolHome 12V motor, is (a) It is a popular model, (b) well designed, and (c) well documented, / to continue, …
(17) Some references: (17a) AutoToolHome 6-12V Mini DC Motor High Torque Gear for Traxxas R/C and Power Wheels PCB DIY Electric Drill amazon.com/dp/B01M58POHF (17b) Best Permanent Magnet Motors Buying Guide – GistGear Last Updated: 03/02/2022 gistgear.com/homeimprovement/electrical/permanent-magnet-motors
(18) GistGear’s long list of motors actually include cheapy stepper motors 28BYJ48 (#13 on the list) which we might also use as a benchmark to compare and contrast with your DC motor.
Your shirt folder project is interesting. So I am googling for a spec: (19) How to Make a T Shirt Folder (Video) – WikiHow 2020sep23 youtube.com/watch?v=7opPALiCqLs&t=3s (20) How to Make a T Shirt Folder (Tutorial) – WikiHow 2021 oct21 wikihow.com/Make-a-T-Shirt-Folder. (21) Ah, locking down lunch time. See you later.
@Justin Priede: “I am trying to move that flap a tad more than 90 degrees,”.Actually it is easy to move the flap any degrees: youtu.be/Agk5eDSzpIE.
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.
@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.
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…
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
(24b) How to make a T shirt folding machine – 2016mar21, 359,386 views
(24c) Clothes Folders – BoxLegend, 2020jul17, 41,670 views
(24d) T-SHIRT Folding and Packaging Machine – Speedy-T, 2016sep20 785,022 views
(24e) How to Fold a Shirt – TM Lewin, 2010apr23, 1,637,846 views
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).
And we need to look carefully your motor spec, to get a rough idea of how powerful it is:
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.
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
2 hours later…
Now I am assembling the N20 + L298N module.
And I found the Last Minutes Engineers have a very newbie friendly tutorial and pinout.
2 hours later…
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).
2 hours later…
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
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…
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…
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.
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
Looks sweet! Excited to see what results you get with your code.
1 hour later…
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…
Now I apply 5kHz, 50% duty cycle to the L298N, N20 motor turns at 34 rpm.
2 hours later…
I also tried 2kHz and 1kHz, and found speed ~= 42 rpm. So I concluded that 1kHz is good benchmark frequency.
Next step is to keep applying 1kHz, but vary duty cycle, to confirm if higher duty cycle means higher speed.
1 hour later…
Now then, 1 kHz, 50%, 90%, and 20% duty cycle results. (10% duty cycle cannot start motor.)
Results summary: 20% dc = 27.3 rpm, 50% dc = 4.16 rpm, 90% dc = 47.6 rpm
2 hours later…
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 -------------------------------------------
The time has come to do some Pico MicroPython dual core programming.
1 hour later…
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)]
Locking down bed time. Call it a day. See you tomorrow.
13 hours later…
Some more interesting videos:
(1) Senior Design Clothes Folding Machine – WashU 2017dec17
(2) Automatic clothes folding machine – 2018jun22
(3) ZS AF818 CNC Full Automatic edge folding machine for leather – 2019feb22
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
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.
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)
And the complete program listing: penzu.com/p/3aff5b07
2 hours later…
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
And I upload the spec for reference.
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
1 hour later…
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.