Last msg too old to edit, this is an update: (2) l298N is good for newbies to learn DC Motor Drivers. You can search Rpi SE many of my post on this subject. (3) You can also consider using L298N as the external H-bridge for tmc2160. (4) If you use MicroPython to prototype your projects, I can mirror your experiments in my Rpi Pico MicroPython Thonny
(5) If you ask about ESP32 in this EESE forum, perhaps more users might come to help.
(6) I have 2 esp32 board in hand: (a) D1 LOLIN32 V1.0.0 ESP32 wifi and BT CP2104 – TaoBao
(b) ESP32 WIFI+BT 2 in 1 for IoT app – TaoBao
I use to play with esp8266-12, using LUA, but find it hard to use event driven programming. Now I am using Rpi Pico MicroPython. I know esp32 can also do MicroPython, so can do MicroPython programming with Pico on my side, and MicroProgramming ESP32 on your side, sort of pairing programming/development on your side.
The TaoBao shop selling me esp32 stuff 2 years ago has many up of date goodies. Perhaps I would buy some new ones to update my knowledge and skills: shop468430569.world.taobao.co…
Is your esp32 in that shops’s list of products? Perhaps I can buy that to join your esp32 projects.
I don’t understand what do you mean by “set points of the tension”. Is your project a College/Uni EE final year individual/group project, or just a hobbyist project, like mine?
I have been watching Cornell U Rpi Projects, to learn what those college guys are doing: skovira.ece.cornell.edu/…. Is your project like them?
And this Cornell U’s Robot Car project is what I am interested about: Robot Navigation ECE 5725 A Project By George and Nei-Chun
6 hours later…
Now I am testing tmc2160 another time, using NEMA17 motor (NEMA23 is too heavy, too awkard to handle!). I am using the scope to take a close look of the signal waveforms: PWM (5kHz, 50% duty cycle), motor encoder signal (speed), and motor coil current (total PSU current, using Rsense, current sensing resistor 0.5 Ohm)
The still pics below.
@kyrpav You LCD with a 40 pin connector is hard for newbies to handle. You might have read my answer to a similar question of ILI9xxx. It took me perhaps 48 hours to understand the details, and how to use the driver. If your vendor gives you the driver for ESP8266/ESP32, then it might be easy, if there are no SPI conflicts.
As mentioned in this post on ILI9341, you might like to search for the driver for esp32, but the chances of finding one is slim: raspberrypi.stackexchange.com/…
4 hours later…
Now I am reading a esp32 board review, before I make up my mind which esp32 board to order from TaoBao.
ESP32 Development Boards Review and Comparison – Sara Santos, MakerAdvisor, 2021may31
I found the following EPS32 board (ESP32 CH9102X WIFI BT) most newbie friendly. So I will place my order now.
(1) New Version ESP32 CH9102X WIFI BleuTooth Dev Board – ¥21
I also found the tmc2225 module also good. So I will also place an order.
(2) TMC2225 42 stepper motor driver module – BigTreeTech ¥16
(3) tmc2225 (2A, 36V, uart interface, internal current sense resistor, 256 microsteps) Datasheet – Trinamic
Now I am looking the tms2160 test results: pwm vs motor speed vs motor coil current. Now I think that the current hardware setup can be used to test DC motors (say, testing two DC motors, each with one coil, vs testing two coils of one stepper motor.
I am not taking any measurements (frequency, speed, current) now, because the scope displays only give a rough picture of the magnitudes of this manual testing. It is only when I use software setting (individual/separate step pulses vs continuous PWM waveform, using interrupt input functions to measure speed encoder events, (current mirror + ADC to measure motor current values).
Also the current current sense resistor of 0.5 Ohm is ugly looking and imprecise. I will wait for the tmc2225 with internal current sense resistance to more accurately measure the coil current. And if I use chopping mode operation, it is not useful to measure the realtime current using repeatedly ADC measurements and taking average etc.
5 hours later…
i am not into micropython. my projects are personal.
not school or university. my university time passed years ago.
i can propose the devkitc
for the esp
either way my decision is to buy the tmc 2225 and 2160 and play also with them but i will probably finish the program with the tb6560 until that time.
I will also check your link for the ili and i will have to read the datasheet and implement a driver i suppose
except if i buy a itead screen and your their programs
i will also try to dig more into lvgl
8 hours later…
@kyrpav So I already placed my TaoBao order with the cheapy tmc2225 and esp32 CH9102X.
@kyrpav esp32 devkitc also looks good.
ESP32-DevKitC WROOM-32D/U – TaoBao ¥21.75
I have not considered devkitc because it has something called “wroom” which I don’t know about and worry that it might make things too complicated.
@kyrpav ILI9xxx drivers are too hard and too tedious for me to follow. So I gave up for good. I forgot what is itlead screen and lvgl, but not urgent for me now. Perhaps I might comment later.
11 hours later…
The BigTree shop has already given my tmc2225 module to the SF Express. So my toy is on its way, should cross the border tomorrow, and arrive town tomorrow, or day after tomorrow. So I am now doing JIT (Just In Time) research to get ready rapid prototyping.
Now some references:
(1) TMC2225 Motor Driver Module V1.1 – Tinytronics €8.50
(2) TMC5161 Motor Driver Module V1.1 – Tinytronics €25
(3) TMC2225 Eval Board – Trinamic
And some wiring docs:
Ah, almost bed time. So see you tomorrow.
17 hours later…
At the same time, I am learning how to use MicroPython for ESP32, and perhaps try to run your program to generate PWM signals. I am starting to read the following referenes:
(1) ESP32 – Getting started with MicroPython on the ESP32
(2) ESP32 MicroPython Download (Also for RP2040, STM32 etc)
(3) espressif/esptool Public (pip install esptool)
I am using waiting for my new esp32 toys to arrive, hopefull sometime next week. In the mean time, I will try my luck on my old esp32 boards, which I bought some years ago, together with esp8266-12 boards. I only tried them to play with LUA, but found it very difficult to write the event driven LUA code. So I gave up. Below are the esp32 boards I found lying in my junk bin for 2 years, collecting dust:
1 hour later…
But then SFexpress says my new toy esp32Ch9102x has already come to town. So I changed my mind and played with my new toy first.
So now I know BigTreeTech Official Shop ShenZhen takes less than 2 working days (Sat 0900 ~ Sun 2400) to delivery my tmc2225 toy.
Now I am going to write a esp32 micropython program to do the following:
tmc2160Send16kStepsAt1Kz() # send 16,000 step pulses of PWM frequency 1 kHz, ie, each step pulse width is 0.001s or 1ms. So the 1.8 degree/step, 200 steps per revolution, motor should move 16000 steps, or 16000 / 200 = 80 revolutions. The time taken should be (16000 steps) / 1 ms/step = 16 seconds.
Note: The OP’s program creates a PWM signal frequency, eg, 1kHz, while my program creates individual steps pulses with pulse width 1ms. In other words, the OP can specify to move the motor for a period of time, say 1 second (resulting 1,000 step pulses), while I need to specify 1000 steps, (resulting 1 second).
This is a complete listing of my Rpi Pico MicroPython Program of sending 16,000 step pulses to the tmc2225 (tested on tmc2160).
I found that my new esp32 new toy is devkit tvi.
So I guess it should be compatible or newer than you devkit c. So it should be easy for us to compare and contrast our programming code.
I googled further and learned more about esp32, such as devKit C, devKit v1, Wroom, esp32 Adruino IDE etc. I have not googled much about MicroPython, my feeling is that it is not that mature. So I might goto Arduino first.
(1) esp32 Wikipedia
(2) esp32 devKitC
(3) esp32 devKitC Boards
(4) Insight Into ESP32 Features & Using It With Arduino IDE – LastMinuteEngineers
(5) esp32 devKit V1
After skimming the above googled references, I have the first impression is that esp32 is much more powerful than Rpi Pico MicroPython, though not so powerful as stm32. But for my humble IoT applications, esp32 with Arduino IED C++ is just optimum. (The OP’s choice of Espressif’s IDF is too pro for me hobbyists).
Ah, almost locking down supper time. So call it a day. Would carry on tomorrow.
(6) Carry On – youtube.com/…
(7) Day is done – youtube.com/…
3 hours later…
Ah, when I made the earlier comments, it was a gloomy Sunday afternoon, so I wrongly though thought that it was time to get to bed. Actually it was only 4pm. So after a short nap I didn’t found sleep and could play for a couple of hours more. 🙂
So I carried on my studies and made the following summary pictures.
I surprisingly found out that esp32 is strong in handling PWM stuff, and that what esp32 says “MCPWM” is actually “Motor Control PWM” and should be handy to do motor PWM.
So I think I must google in this mcpwm to be able to understand and debug the OP’s code on PWM. Now more references I googled:
(8) In-depth ESP32 PWM Tutorial | How to use PWM in ESP32? – Ravi Teja, 2021mar12
(9) ESP32 MCPWM
(10) esp32 and pico DIY PROJECTS – Electronics Hub
I skimmed Ref 9 and found it surprisingly complicated, because of its very lower level API and macros. An example is that it have macros to configure the deadtime of switching two half H-bridges, and also inputting motor speed by Hall sensors, and syncing two PWM operators for fault.
But I found two reasons that I should be use esp32’s mcpwm: (1) They are too lowlevel, so may be good one is developing DC/BLDC motor drivers using two barebone half H-bridges, or power MSOFET current switches.
(2) The whole mcpwm is designed for BLDC/DC motors, nothing is considered with stepper motor in mind. In short, esp32 is “useless” for stepper motors. (3) And if we are using stepper motor drivers such as tmc2130/2160/2208/2209/2225, all the esp32 mspcm tricks are actually handled in hardware/firmware, so should be more time/compute efficient.
Conclusion, I will forget esp32 mcpwm and go direct use tmc2225 as planned.
Though I am not using mcpwm, I still need to create some PWM signals, perhaps using a library of something. So I am skimming Ref 8 to steal or borrow some ideas.
1 hour later…
So after my disappointment to mcpwm, I went reading Ref 8 from Electronics Hub. I had a pleasant surprise: I learnt that, beside mcpwm, there is another pwm for LED control, called ledC. The tutorial summarize the following interesting points and APIs.
***A couple of interesting points about LED PWM Controller in ESP32***.
16 independent PWM Channels, divided into group of two with 8 channels per group.
Programmable resolution between 1-bit and 16-bits.
Frequency of the PWM wave depends on the resolution of PWM.
Automatically increases / decreases duty cycle without processor intervention.
***A list of all the LEDC APIs exposed by the driver. These functions are written for Arduino IDE port of ESP32***.
ledcSetup(channel, frequency, resolution_bits)
ledcWriteNote(channel, note, octave)
My quick and dirty conclusion is that this ledC is very good to create step pulses for the tmc2225 step motor controller.
Talk is cheap. Tomorrow I will try to show how to use esp32 ledC wpm controller to control tmc2225 to drive a step motor.
Bed time. See you tomorrow.
17 hours later…
So I just picked up my tmc2225 toys this morning.
4 hours later…
Now I am setting up Rpi Pico + PCF8574 IOx hardware to test tmc2225.
1 hour later…
Now the tmc2225 module pinout
2 hours later…
The setting up and testing was smooth, except one troubleshooting trick.
16 hours later…
The troubleshooting trick I referred above is how to start the motor moving, IF you find the motor started trembling, got stuck, and could not move by hand. This is stepper motor newbie FAQ. The trick I use is to manually scan/sweep the PWM frequency, using the mks testing tool or xy-lpwm. It took me a couple of seconds to find that the initial freq setting of 5kHz is not appropriate for my motor and microstepping frequency resolution. I found a good frequency to start is around 3kHz.
I guess I need also to check out if 3kHz is OK for my stepping motor, or a range of motors. So I decided to use a standard 3D printer as a bench mark or case study, so newbies can use a similar setup like mine, if their motor trembles and get stuck. My benchmarking or calibrating motor is the following:
I am thinking of also using another popular hobbyist toy stepper motor 28byj18 as an example.
1 hour later…
17HS8401 NEMA17 42 Stepper Motor 48mm 42BYGH 1.7A 4-lead for 3D printer CNC (80deg Max) – Usongshine AliExpress US$6 (26/5pcs)
Now the spec says no load start freq – 1900 pps/Hz, and Holding torque = 4k8 NM. And I should set motor current to 1.5A/phase.
Leave a Reply