last day (19 days later) » 

4:28 AM
Q: Motor torque control with PWM : how to measure current?

SandroFor my caving robot project, I have 8 motors for which I need torque control (they will mainly be stalled or nearly stalled.) Each motor is driven by a DRV8801PWPR H-bridge (commanded by one digital and one PWM signal from a STM32F723.) In order to get the torque, I was planning to measure the cu...

Your driver and many others have an external "current sense resistor" (some have internal sensors) , why not use them?
@tlfong01 : the DRV8801 supports external sense resistor (and I'm using one). Even beter, it has the "VPROPI" pin acting as amplifier, in order to be able to use a small resistor while getting decent voltage (specially usefull in a battery powered project like mine, where I don't want to loose 1V out of 12 in a sense resistor)
(1) My apologies for not reading your question carefully and giving you a silly answer. I read your question again and found that you presented your situation very well. (2) I am curious about your cave exploration robot project. It would be nice if your can show us the robot's user requirement or spec. (3) I guess you are using DC motors in your project. I happen to be playing with a robot car project, an 4WD/8WD with TMC2160 stepping motor (can also do DC motor) driver (big current > 10A). If I know your motor requirement better, I might suggest BLDC or stepping motors.
@tlfong01 : I have ni idea how to give a complete "description" of my robot on this site without being out of topic (If you have, it might be usefull to refer to it as most of my questions relate to this robot). Or if you are just currious, we could do a skype. For short, it's a robot to explore vertical narrow cracks, by driving blocked between the 2 opposit walls. Basicaly, the robot is made of 8 arms (2 horrizental "X") with a wheel at the end of each arm. Each wheel is pushed agains the wall (to avoid the robot slipping down) by a motor (those I'm asking about) pulling some elastic band.
The motors are very small geared DC motors (<1A, weigting less than 20g). The weight is a very important factor for this robot, as the force needed for the arms (ie motor torque) is proportionnal to the weight of the robot. The goal of torque control is to ensure constant force against the walls (ie "constant torque" changing a bit depending on the position of the arms)
(4) Are you using small DC motors such as N20 (see Ref below). Perhaps you can give me the link to your motor. (5) You following spec is good: "a robot to explore vertical narrow cracks, by driving blocked between the 2 opposite walls. (6) Is there are reason using drv8801, and not the possibly improved version drv8833/8871 (also see refs below). (7) The tmc2160/2209 has some advanced features on torque/current (using microstepping/pwm constant current) which might give you some brainstorming ideas. (8) You might also to consider BTN7971B, whose current sensing comparing with drv88xx.
Our discussion is getting TLDR, so let us do our long winded in this chat room.
References to motor drivers with different mot coil current sensing features.
(1) drv8801/8833/8871

(2) btn7970/7971B
Above references contain typos. It is too late for me to do editing. So I am sending an update.
(1) drv8801/8833/8871

(2) btn7970/7971B

(3) tmc2130/2160/2208/2209
2 hours later…
6:24 AM
Question: How narrow is your vertical narrow cracks, 18 inches, like below?




1 hour later…
7:51 AM
drv8833 driving dc motor Problem
I found the above EESE question on drv8833 with Rpi Pico. The OP does not know his motor spec. So perhaps I can use the small N20 motor and experiment with. You can, on your side, try your STM32 your motor and can do sort of pair programming/development.
@Sandro Yes, the "vpropi" pin is good because it save power. The "sleep" pin also saves power. The "fault"pin perhaps also good because it it can warn over current which might mean load/torque over limit, but not sure. I vaguely remember btn7971b has similar current/sensing/fault features, but I have not used it.
8:50 AM
(4) -> I'm indeed using N20 motors. More precisely, I bough those in 12V/60rpm version :

Usually, I'm not that fond of non specified components, but it's hard to find that light motors (I already had 2 N20 at home, which worked well), and cost is a critical aspect of the robot, because in real use, there will be a huge risk of loosing the robot due to pilot errors (maybe 10% per operation). As there are 16 motors (8 for the elastics of the arms, 8 for the wheels, it makes a significa
9:08 AM
6) I choose the DRV8801 for 3 main reason :
- it is in stock at JLCPCB
- it uses only 1 PWM input (and one direction input) : I do not have enough timer outputs (even on my 144 pin STM32F723ZE) to spend 2 PWM for each motor. I could do softPWM, or use a single PWM on a 2 PWM controler (ie doing slow decay PWM in one direction, fast decay in the other), but it makes things more complicated
- the VPROPI is a nice aditionnal feature (I can use small (SMD) sense resistors while still having a "big" signal without needing an AOP)
For the DRV8833, it would also do, but I would need softPWM or some external logic in order to use it with a single harware PWM. And it is nearly 5 times the price of the DRV8801, so even if I need 2 times less, it's also more expensive
For the DRV8871, it doesn't support external sense resistor (it does internal measurement but without outputing it). It has a I limit pin, that is made to put a fixed current limit (it should be possible to trick it by applying a voltage or current to this pin instead of using a fixed resistor).
I do not know for the DRV8871, but the DRV8870 that I used on the first prototype (at first glance, it seems the same excepted that it uses an external sense resistor) does very poor job on current control when the motor is stalled.
7) tmc2160 : far too complex (requires external mosfets, ...)
tmc2209 : only 2 control pins (step and dir) : it can only be used by steper motors
9:45 AM
For the width of the crasks, I was aiming for the 15-40cm range (above, humans can pass).
In case for some specific cave I need something a bit larger, I just have to 3D-print some longer arms (it increases a little bit the minimal width, and more significantly the max widths)
For the pins :
- VPROPI : nice for "big" analog signal without big sense resistor nor external OP-Amp
- sleep : not sure it is really usefull : when the robot is on, the motors will have to provide torque all the time. I think that bin is mainly usefull for machines always powered on but not used most of the time. I'm not planning to use it
- fault : it might be interesting (even in in case of a problem, the robot is probably already lost). I was planing to group all fault pin in between 1 to 4 GPIOs, just for the prototyping phase
Just above : the current state of the prototype
3 hours later…
1:09 PM
Ah, your cave robot looks interesting. I never thought of something like this before. Long time ago I read about window plane crawler robots for cleaning windows, but that is using a different method.
Now some random brainstorming comments:
N20 is a good choice, I learned many things from Polulu, but I bought the motors from TaoBao. Below is a reference of my learning notes.
How to use motor drivers with H-bridge and PWM input, to control direction and speed of DC motors?
Appendix C, D - (20) TaoBao GA12-N20 Gear DC Motor with Hall Effect Encoder - ¥30
My N20 has rotary encoder. My 8WD is for rough terrain. I am experimenting with different strategies, including the following. (1) All 8 wheels with speed encoder are moving at the same speed, perhaps same PWM frequency and duty cycle. If one wheel suddenly moves very fast, that means it is hanging in the air, perhaps above a hole or something, so no load no torque. But I am only thinking, no tests yet. The thing is that I don't measure motor coil current, to deduce torque.
Motor current sudden increase means stalled or jammed.
The other reason is that I am trying the driver in "chopper mode", or constant current mode. You might skimmed that following references for a rough idea of "current chopping".
(1) Misconceptions about Stepper Motors Explained - MachineDesign 2017feb18

(2) Step Motor Basics - GeckoDrive 2017nov03

(3) What is a chopper drive for a stepper motor? - Dantelle Collins, 2017aug11

(4) Optimized Current Control Chopper Modes - Trinamic
There you are - Chopper Mode (Ref 3).
Yes, tmc2160 or tmc2130 is very complicated, using SPI/UART control. But tmc2130 without the external mosfet switches is very small, not bigger than drv8833.
Ah, I never knew that drv8801 is 5 times cheaper than drv8833, because I am only doing one off prototyping, hoping to learn some new stuff. If one day I am going to make perhaps 500 robots to make some money, of course I will components as cheap as possible, so to make as big money as possible. :)
I am using Rpi Pico because it is cheap (US$4), and it has a lot of PWM pins, and also two ADC pins, so is good for testing, not to worry it falling down a cliff or a cave.
Ah, almost bed time. So see you over the weekend. Cheers.
2:24 PM
Why all those resources about stepper motors? (Excepted if you know a stepper motor the size of a N20?!?)
For the tmc2130, it has just 2 input pins in total (step + dir), so it can't be used for 2 DC-motors
For the prices of drv8801 vs drv8871, it seems I was "wrong" : it is just JLCPCB that incrased the price of the 8871 (probably because they are currently hard to come by currently). On digikey, they are about the same price, but 8871 is out of stock
As microcontrolers, I mainly used arduinos until know (the cheap clones are about 3€/$), including just the Atmega328p itself for the first prototype.
For the second prototype, I decided to use a STM32, because it's a more professional one (it's a nice addition on the CV for a robotics engineer), and because there are some very powerfull ones (the one I'm using has 144 pin, and runs at 216MHz)

  last day (19 days later) »