Using a STM32F4 Discovery board to send PWM signal to industrial AC servo motor drive.

Thread Starter

truongkimson

Joined Oct 14, 2019
11
Hi All,


I'm trying to interface the STM32F4 Discovery board with an AC Servo drive (Hiwin D2 Drive + Mige 130ST-M10010 AC servo motor).
Here is the link to the servo drive manual https://www.hiwin.com/pdf/d2_drive_user_manual.pdf

So basically, I have this hex file of a closed source firmware, whose function is to, on one side, interface with PC through USB port, and on the other side, send PWM + DIR signal to control a servo motor drive, operating in torque control mode. PC communicate with STM32F4 the torque level it wants, STM32F4 send PWM + DIR signal to drive as a reference signal, servo drive driving the motor to generate torque accordingly.

Here's how the whole system looks like. Note that i'm not using the Drive named Argon, but using Hiwin D2 instead.
3.png



Following diagrams are all I have from the author of this firmware.


There are different control mode that STM32F4 can output, I decide to go with PWM + DIR (bottom left)

So output signal pin for PWM is PE9 and DIR is PE11.


Now, i've dug through the servo drive manual, and below is the closest thing in terms of wiring I can find from the manual


My concern is, as you can see here, the manual mentions 5V TTL type controller as a sample. However, if I'm not wrong, output from PE9 and PE11 are 3.3V CMOS signals, therefore, I do not know whether I can follow this wiring instruction to link up the STM32F4 to the servo drive.

So my question is

What is the logical signal that comes out of PE9 and PE11 pin? (what logic level type)

Is there a difference in wiring for a 5V TTL PWM signal and 3.3V CMOS PWM signal?

Can someone also please explain to me the wiring configuration above (why is a 5VDC source needed to connect to + terminals? STM output connected to - terminal?) and what is the purpose of the internal wiring of the Servo drive (before the optocoupler)?
I asked the above question because last time when I played around with Arduino board, the connection is usually this way:

PWN pin to + terminal
GND pin to - terminal
There's not extra 5VDC needed.

Thanks in advance and if there is anything point which I did not make clear, please dont hesitate to clarify with me.
Cheers!
 
Last edited:

MaxHeadRoom

Joined Jul 18, 2013
28,617
I would guess the 5v TTL controller is open collector and the reason for 5vdc source for the sourcing type opto inputs. Also the manual shows it.
The manual also appears to indicate 10v analogue and step-direction input, not PWM? Mega Fabs D2 board for this?
See section 3.6.1.2. & 3.6.3.
Max.
 

Thread Starter

truongkimson

Joined Oct 14, 2019
11
Hi Max,

For torque control mode, this servo driver support both analog and PWM signal, as shown in this table at page 11 of the manual. And I am interested in PWM signal input, therefore I was looking at 3.6.3. Section 3.6.1.2 is for position control, which I will not use.
upload_2019-10-15_23-24-30.png

Can you explain to me what is the meaning of 5v TTL controller? is there other type of 5v TTL besides open collector type?
Is my microcontroller output considered a 5v TTL open collector type?
And also what is the difference between a 5v TTL type (as in 3.6.3.3 or .4) and NPN type (as in 3.6.3.1 or .2)? wiring looks almost similar. is it only the different supplied voltage?
Will the opto still work with 3.3V supplied?
upload_2019-10-15_23-37-11.png vs upload_2019-10-15_23-36-37.png
Thanks,
 

Attachments

MaxHeadRoom

Joined Jul 18, 2013
28,617
Due to the inputs being source type opto isolator circuit, the opto's require a source that is compatible with the controller (CWL+), if driving from a micro it is similar to the 5v TTL type.
The micro 5vdc power source is typically used.
Max.
 

djsfantasi

Joined Apr 11, 2010
9,156
As far as the question whether the opto would work on a 3.3V signal, it basically depends on the opto specifications

With a 220Ω current limiting resistor, the LED is getting about 23mA of current at 5V. With 3.3V, the LED is only receiving 15mA. This may not be sufficient current for the opto to switch.

There are simple circuits/modules called level shifters that will convert 3.3V signals to a 5V signal, like this one.
 

Thread Starter

truongkimson

Joined Oct 14, 2019
11
Hi fantasi,
Thanks for your reply.
Crossing my fingers that the opto coupler support 3.3V. If not then I will need to put a level shifter in-between.
I'm just wondering whether a level shifter will affect the fidelity/quality/latency of the signal? output signal is @~10khz.
 

Analog Ground

Joined Apr 24, 2019
460
A quick check of the Discovery board documentation and STM32F407VGT6 documentation shows some of the I/Os are 5V tolerant. In particular, timer outputs for the 50% PWM and GPIO for the Direction signals. I would look into making a direct connection from the board to the motor controller in the manner shown in the controller manual. Also, there is 5V available on a Discovery header connector. Disclaimer, this is just a quick look. However, I suggest checking it out. BTW, the max current on a pin is 25 mA which is enough.

Also, about polarity of the signal, The Direction pin is, of course, completely programmable. Often, there is an option to set the polarity of the Timer/PWM output with a control bit.

Edit: Correction, a 100% PWM signal needs Direction. 50% PWM doe not need a direction signal. I think the motor controller can accept either one.
 
Last edited:

MaxHeadRoom

Joined Jul 18, 2013
28,617
My preference has always been to use ±10vdc analogue control, no direction indication needed and can be super fast correction when using for such as CNC control etc.
Max.
 

Analog Ground

Joined Apr 24, 2019
460
More on 5V tolerant I/O of the microcontroller. Look at the pinout table, Table 7, of the data sheet. The column titled "I/O Structure" has "FT" for the pins which are 5V tolerant. BTW, PE9 is "FT".
 
Last edited:

Thread Starter

truongkimson

Joined Oct 14, 2019
11
My preference has always been to use ±10vdc analogue control, no direction indication needed and can be super fast correction when using for such as CNC control etc.
Max.
Hi Max,
Interesting to hear that. I see a lot of CNC or industrial motor driver only support +/-10v for velocity and torque control mode. Ive had a hard time trying to find a servo drive that support PWM signal.
So my question is
What are the advantages and disadvantages of using analog 10v signal compared to PWM.
Is it possible to convert 100% PWM signal to analog 10v before feeding to servo drive?
And lastly, what kind of control device do people use to generate this analog +-10v?
Thanks
 

Thread Starter

truongkimson

Joined Oct 14, 2019
11
More on 5V tolerant I/O of the microcontroller. Look at the pinout table, Table 7, of the data sheet. The column titled "I/O Structure" has "FT" for the pins which are 5V tolerant. BTW, PE9 is "FT".
Hi,
I have checked the datasheet and indeed pin pe9 and pe11 are 5v tolerant I/O. Now the problem is, I have no control over board firmware, I can only flash it and use. So I can't change output pin and I can't know output pin voltage.
Let's assume PWM output is 5v. If I follow manual wiring instruction word for word, doesn't it mean that board output pin is sink? And that means current will flow into output pin? Is it normal?

Will it be better if I connect this way
5v PWM output pin to CWL+
GND to CWL-

Thankd
 

Thread Starter

truongkimson

Joined Oct 14, 2019
11
Just out of curiosity, does the PC software recognize the downloaded firmware?
Hi,
Both pc software and board firmware are developed by the same guy. So basically he develop them in such a way that pc can communicate with board through micro usb port.
Firmware also makes pc recognise the board as a peripheral device
 

Analog Ground

Joined Apr 24, 2019
460
Is the firmware for an Argon motor controller? If so, the interface to an Argon seems to be quite a bit different than the Hiwin D2 controller. Have you determined the firmware will support a D2?
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
Hi Max,
Interesting to hear that. I see a lot of CNC or industrial motor driver only support +/-10v for velocity and torque control mode. Ive had a hard time trying to find a servo drive that support PWM signal.
So my question is
What are the advantages and disadvantages of using analog 10v signal compared to PWM.
Is it possible to convert 100% PWM signal to analog 10v before feeding to servo drive?
And lastly, what kind of control device do people use to generate this analog +-10v?
Thanks
When I built a few customized CNC or motion control servo systems, I used the Galil Motion cards, these either sat in a PC slot or came stand alone.
They used the ±10vdc analogue control and the PID encoder/loop is passed back directly to the Galil, this allows the use of simple torque mode, trans-conductance amplifiers.
i.e. No 'intelligence' used in the drive construction.
Drives were made by Advanced motion, Copley Controls, Aerotech etc.
The popular Mach3/4 DIY CNC software uses a PWM signal for spindle control which many have converted to ±10vdc, there should be quite a few circuits on the CNCzone forum.
Max.
 

Thread Starter

truongkimson

Joined Oct 14, 2019
11
Is the firmware for an Argon motor controller? If so, the interface to an Argon seems to be quite a bit different than the Hiwin D2 controller. Have you determined the firmware will support a D2?
Hi,
The firmware is not driver specific. The author of this firmware intended for it to work with any servo drive which support PWM signal input.
People have tested this firmware with Argon drive and produced great result.
I agree that the interfacing is quite different between the 2 drives.
Argon receives pwm signal through High speed input, line IO.
While Hiwin D2 receive through a low speed, optocoupler IO.
But I belive it doesn't matter as long as the drive of interest can receive setpoint signal from microcontroller board.
 

BobaMosfet

Joined Jul 1, 2009
2,110
Hi All,


I'm trying to interface the STM32F4 Discovery board with an AC Servo drive (Hiwin D2 Drive + Mige 130ST-M10010 AC servo motor).
Here is the link to the servo drive manual https://www.hiwin.com/pdf/d2_drive_user_manual.pdf

So basically, I have this hex file of a closed source firmware, whose function is to, on one side, interface with PC through USB port, and on the other side, send PWM + DIR signal to control a servo motor drive, operating in torque control mode. PC communicate with STM32F4 the torque level it wants, STM32F4 send PWM + DIR signal to drive as a reference signal, servo drive driving the motor to generate torque accordingly.

Here's how the whole system looks like. Note that i'm not using the Drive named Argon, but using Hiwin D2 instead.
View attachment 188010



Following diagrams are all I have from the author of this firmware.


There are different control mode that STM32F4 can output, I decide to go with PWM + DIR (bottom left)

So output signal pin for PWM is PE9 and DIR is PE11.


Now, i've dug through the servo drive manual, and below is the closest thing in terms of wiring I can find from the manual


My concern is, as you can see here, the manual mentions 5V TTL type controller as a sample. However, if I'm not wrong, output from PE9 and PE11 are 3.3V CMOS signals, therefore, I do not know whether I can follow this wiring instruction to link up the STM32F4 to the servo drive.

So my question is

What is the logical signal that comes out of PE9 and PE11 pin? (what logic level type)

Is there a difference in wiring for a 5V TTL PWM signal and 3.3V CMOS PWM signal?

Can someone also please explain to me the wiring configuration above (why is a 5VDC source needed to connect to + terminals? STM output connected to - terminal?) and what is the purpose of the internal wiring of the Servo drive (before the optocoupler)?
I asked the above question because last time when I played around with Arduino board, the connection is usually this way:

PWN pin to + terminal
GND pin to - terminal
There's not extra 5VDC needed.

Thanks in advance and if there is anything point which I did not make clear, please dont hesitate to clarify with me.
Cheers!
Let me get this straight- You're trying to use a DC output signal to control an AC motor.... do you not see a significant problem with that?
 
Top