Uncategorized

tmc2225 driver stepper motor encoder output signal waveform

Q: Stepper motor has own encoder, can I connect encoder pins to microcontroller and see feedback?

TryingtogetsomeI am using closed loop stepper motor with motor driver. Here is my driver CS-D808. I am using this with microcontroller. I want to stop this motor always certain location after 5 to 10 turns. I wrote a code, I am using (circuitpython). for z in range (y): for x in range (1600): print(…

stepper-motor stepper-driver python

tlfong01

tlfong01

6952

(1) A short answer to you question is “Yes”. (2) Your stepper driver is very advanced, usually for heavy duty, mission critical industrial applications. (3) Ref: (a) CS-D808&CS-D1008 Closed Loop [8A peak, NEMA34] bipolar stepper Drive User Manual – LeadShine leadshineusa.com/UploadFile/Down/… (b) ES-D808w – ES-M23440w Closed Loop Hybrid Stepper Motor Driver – LeadShine US$150 fr.aliexpress.com/item/1901023675.html?gatewayAdapt=glo2fra. I can give you a longer answer if you confirm that you have skmmed the user manual.

Tryingtogetsome

Tryingtogetsome

119

@Antonio I am using first 5 switch on (default mode 1600 steps ). Thanks to you. I tried my code with 800 steps, It went 2 turn. Thank you i solved my code problem thanks to you.

tlfong01 , I read this. It says No loss of step , No torque reservation etc. So is this motor and driver do it without need anything ? If they do themself, should I use auto tuning switch on ? One more question , pend+ pend- pins 5-24 V output signal. So can I use them for information with my microcontroller ?

tlfong01

tlfong01

6952

@Tryingtogetsome, (1) Let me entertain your first question: “So is this motor and driver do it without need anything?” , (2) I assume the “it” you mentioned refers to (a) “no loss of step, (b) no torque reservation, (c), (d) … etc”, and the list can be long. (3) To make our discussion not too TLDR, let us confine to the first thing “no loss of steps”, which is often concerned. (4) In other words, let us shorten your question to the short from below: Can the LeadShine closed loop stepper motor driver prevent step loss by itself, without mcu? . Pls feel free to make counter suggestions.

Tryingtogetsome

Tryingtogetsome

Yes, I’m wondering about this. And also I want to ask can Pend+ Pend- (5-24V might damage mcu ) pins supply feedback to mcu ?

tlfong01

tlfong01

6952

(5) Quick reply to “Pend+/Pend- (5~24V)” _ Pend+ is open collector (to suit external MCU etc), so you can connect Vcc to 5V, and output should be 5V logic level. If you are using 3V3 mcu, you might need to shift down the 5V signal to 3V3. (6) are you using any 1000-line incremental encoders, or simple low resolution, for speed/direction checking quadrature encoders? (7) Are you using ProTuner to do the setup/calibration/verification for “in position” business?

(5) continued, … A quick and dirty stepping down trick is just use 2 serial small signal diode such as 1N4148 in series with the 5V logical level output to drop/step down to 5V – (0.8V x 2) ~= 3V3.

Tryingtogetsome

Tryingtogetsome

119

Thu 15:43

data sheet says it is 1000-line incremental encoders. I am trying to google it because I don’t know these means. I was doing school project and I need stepper for it. One of my dad’s friend give me this stepper and driver. I will give them back when I show my project. They used this motor with PLC and they don’t know much about it .

I am not using proTuner

My mcu is Arduino so I can use 5V logic level.

tlfong01

tlfong01

6952

(7) OK. 5V Arduino is good enough for your school project. (8) However, your US$150 LeadShine closed loop motor driver is too advanced for a school project. I would suggest to start you project with a cheap. cheap < US$5 hobbyist type stepper motor controller (of course no closed loop stuff).

(9) You might like to google/browse for cheapy stepper motor drivers such as A4988 or DRV8833 in Arduino forums to get a rough idea of how other Arduino guys are playing with simple stepper motor drivers.

tlfong01

tlfong01

6952

Thu 16:04

Actually even A4988 or DRV8833 might be to difficult for a school project. For newbies, I usually recommend the 28byj48 stepper motor, with ULN2003 driver. Ref:
How can Rpi3B+ use the A4988 stepper motor driver to control a NEMA17 motor? Asked 9 months ago Active 3 months ago Viewed 2k times
raspberrypi.stackexchange.com/…

I highly recommend a school project to start with this:

28BYJ-48 5V DC Stepper Motor + ULN2003 stepper motor drive for Arduino – US$2
fr.aliexpress.com/item/…

Tryingtogetsome

Tryingtogetsome

thank you tlfong01 but I already had this 150$ motor and driver. I can run stepper and stop stepper at certain point. I will show to my school when I finish this project. Then I will give this stepper motor and driver to owner. He lent me this stepper and driver

tlfong01

tlfong01

6952

OK. I agree with you. If you have already made some progress on this driver and motor, you can explore further and make something to impress your teacher and classmates. On second thought, 28Byj48 and ULN2003 is too common stuff and won’t impress anybody.

Going back to your project, you might like to give us a specification (more details) about you project objective, such as pushing or lifting some heavy object to a distance or height very precisely?

Tryingtogetsome

Tryingtogetsome

119

Thu 16:25

okay my project needs to push animal feed. To do that it needs to turn 1 rotation. It is a basic animal feed station. This is a basic project for now I am thinking for identification animal and to pour different animal feed for different animal in the future. Since motor is really strong, I will probably put 10kg food in this system. Motor needs to push foods to animals (for now I am controlling it with button ).

tlfong01

tlfong01

6952

Ha, your project sounds interesting. So it is in two stages. In the first stage, the human or animal, say a crocodile, would press a button, and 10kg of food would push to the animal. In the second stage, a camera would detect which animal is pushing the button, if it was a too fatty crocodile, then only 2 kg of food will be given, to help the fat animal losing weight.

Tryingtogetsome

Tryingtogetsome

119

Thu 16:48

yes, that’s it

for now for example one crocodile came, I will push button and motor will rotate 1 turn. This turn will push to the animal like 1.5 kg ( I didn’t measure it). So in tank, there will be still 8.5 kg food for another crocodiles.

2 hours later…

tlfong01

tlfong01

6952

Thu 19:00

Ha, thanks a lot for clarifying how the food is “physically translated” from the “food storage” to the “food tray”. Actually I have seen similar projects called dog/cat food feeder. Typically the clever dog/cat, after training/briefing, would come by and say, push a button for food, another button for water.

The dog/cat food is in the form of little meat balls or biscuits, and if the stepper motor turns an opening door 45 degrees, then more meat balls would fall at a speed of 10 balls per second. BTW, I read that old dogs can be as clever as a 8 years old child, and that can learn new tricks. Cats seems not so clever. Pig can be even more clever, so I would suggest not to use crocodile (not so easy to find, anyway), and use dogs as the target user.

The real case studies actually use hobbyist grade “servos”, TowerPro MG996, …

Ah, locking down supper time. Nice chatting with you, see you tomorrow. Cheers.

Tryingtogetsome

Tryingtogetsome

Thanks for everything. Nice chatting with you too. Have a nice day.

15 hours later…

tlfong01

tlfong01

6952

Fri 10:15

Two useful sections from the user guide:

6.1 Microstep Resolution Setting (SW1-SW4)

10. Software Configuration

The CS-D808 / CS-D1008 is designed for simple setup and implementation. For most applications no software configuration or tuning is needed, … If you want to do fine tuning or custom configurations such as micro-step, current percentage change, … you can use Leadshine’s free ProTuner software to make the changes.

You might also like to skim this chat:

Electrical Engineering Discussion between tlfong01 and kyrpav

Imported from a comment discussion on electronics.stackexchang…

tlfong01

tlfong01

6952

Fri 11:03

And you can download the free ProTuner software from this site:

LeadShine Stepper motor driver software ProTuner For stepper drivers:
mecheltron.com/en/…

download files ProTuner_All_Setup_V1.0.zip
download files ProTuner_DM_Setup_2013-04-10.zip
download files ProTuner_DM_All_Setup130604.zip
download files ProTuner_DM_Setup_2013-11-06.zip
download files DM_Serials_English_setup 2015-08-27.rar
download files DM_Serials_English_setup 2015-08-31.rar

For stepper drivers: AM882
download files ProTuner_AM882_Setup_V2.5.zip
download files AM882_Setup_2012-05-31.zip
download files ProTuner_AM882_Setup_2012-06-05.zip
download files ProTuner_AM882_Setup_2012-08-17.zip

For stepper drivers Closed Loop HBS:
HBS57, HBS86, HBS86H
download files ProTuner_HBS_Setup_2012_05_28.zip
download files ProTuner_HBS_Setup_2012-12-14.zip
download files HBS_English_setup 2013-03-22.rar

For stepper drivers Closed Loop ES-D and ES-DH:
ES-D508, ES-D808, ES-D1008, ES-DH1208 und ES-DH2306

(see full text)

1 day later…

tlfong01

tlfong01

6952

yst 13:30

And you get incremental encoders from US$1 to US$200+:

(1) Incremental encoder – AliExpress US$0.7
fr.aliexpress.com/item/…

(2) 5V Smart Car Code Wheel Photoelectric Speed ​​Sensor – AliExpress US$3
fr.aliexpress.com/item/…

(see full text)

3 hours later…

tlfong01

tlfong01

6952

yst 16:37

Now let me comment on the code you listed in you question, as a partial answer of of your question of first of two things you don’t understand, ie, why your motor makes less turns (Note 1) than you expected/calculated.

Note 1 – What you don”t understand, in other words, is this:

You count the number of steps moved and found no problem, but the number of turns or distance/degrees traveled is smaller.

The cause or crux of the matter of discrepancy between steps make and degrees traveled is this:

MicroStepping

If you skim my code you might notice that I have more GPIO pins than yours. You have the basic GPIO pins for (1) Enable, (2) Direction, (3) Step pulse, But I have two more GPIOs pin m1, m2 to set microstepping resolution, from 1/8 to 1//32, or higher. Actually your advanced driver has four pins to set microstepping, m1, m2, m3, m4, and the resolution is much much higher, so for very high precision needed in medical and industrial applications (laser cutting a 1 cm tumor or IC wafer.

You might like to compare and contrast my code and yours:

# ========= ========= ========= ========= ========= ========= ========= =========
# *** TMC2130/2160/2208/2209/2225 Testing Functions ***

# ========= ========= ========= ========= ========= ========= ========= =========
# 5. TMC2225 Config/Functions

enblPinNum   = 20
dirPinNum    = 21
stepPinNum   = 22
ms1PinNum    = 26
ms2PinNum    = 27

# *** tmc2225 Functions ***

def testToggleTmc2225ControlPins():
    print('  Begin testToggleTmc2225ControlPins(), ...')
    toggleGpOutPinNumList([enblPinNum, dirPinNum, stepPinNum, ms1PinNum, ms2PinNum], \

(see full text)

Below is a complete listing of the code, showing how to do microStepping:

tmc2225 programming, test99: penzu.com/p/0bf511af

tlfong01

tlfong01

6952

yst 17:13

The following code snippet shows the three (pink) statements commanding the motor to make three separate movement, by 2,000, 3000, and 3000 (1ms pulse width) step pulses. Before commanding the last move, the microstepping resolution is set higher to 1/8 (the green statement), resulting the driver/motor moving same number of steps, but less degrees/distance.

user image

tlfong01

tlfong01

yst 17:34

And the Youtube video: youtu.be/lj0xFBAkzeI

1 day later…

tlfong01

tlfong01

6952

20:17

Now I am coming to your second question: I connected motor drivers encoder pins to motors. Do I need a microcontroller to get information about the step losses or precision of the motor? or motor and driver will handle by themself ?

It is a bit confusing, perhaps you got the direction of the encoder signals wrong. The user manual says the following:

User guide Section 3.2 Connector P3 says the following:

The P3 connector in Figure 2 is for encoder signal connection. Refer to the following table for details, …

It appears that the motor’s encoder signal is an output signal, inputting to the encoder input connector of the driver. In other words, the stepper motor driver reads/inputs the output signal from the motor encoder and then calculates the speed (from step pulses per unit time (per second) and/or the distance moved.

Now I am using my stepper motor with encoder (20 signals per revolution, or 360 degrees / 20 = 18 degrees every signal) to prove my concept.

Now I have written a new function to do the testing/calibration:

def testTmc2225V02(): # 1/4 microstepping, CCW, 2,000,000 1m2 step pulses
    printProgramName() # Print program name, author name, data
    tmcSetOneFourthStep(ms1PinNum, ms2PinNum) # Set microstepping resolution 1/4
    tmcSetDirCcw(dirPinNum = 21) # Set direction CCW
    tmcSendOneMilliSecondStepPulses(stepPinNum = 22, pulsesTotal = 2000000) # Send 2000000 1ms width step pulses
    return

I run the function testTmx2225V01() and use my scope to display (1) the step pulse, and (2) the encoder output signal:

user image
tlfong01

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 )

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.