Connecting VESC 4.12 to MACH4

General topics and discussions about the VESC and its development.
GunnarW
Posts: 3
Joined: 21 Apr 2017, 19:54
Location: Sweden

Connecting VESC 4.12 to MACH4

Postby GunnarW » 21 Apr 2017, 20:19

First of all: I am a mechanical engineer and I have very little knowledge in modern electronics and programming,
and I am retired from work whith the rights of age.
But I can read and I assure you that I have tried to get information by reading manuals and on forums...

In my homebuilt 4-axes milling machine I use Turnigy SK3 6374 kV192 as spindlemotor via a belttransmission.
Until recently I have used a YEP 120A HV esc and a HP ESP120 3000w 51V 57A 220V-240V input as the powersupply.
Since the ability of the YEP to maintain a constant rpm and a decent torque, especially at lower rpm, suffer a lot I finally
found the VESC, which I bought. The powersupply voltage to the VESC is adjusted down to 45V.

After having the BLDC-tool to detect motorparameters and testing the different resulting characteristics I have found
the following, since you want to keep the rpm as constant as possible with cutting tools:
1. From the control panel to the right in the BLDC-tool only the "RPM" option gives what you want, and that works good.
But this is not usable together whith the CNC MACH4 software of course.
2. Configuring the App to PPM and PID-control works ok together with a servotester but Mach4 cannot supply that signal
unfortunately.

So what can Mach4 and the ESS-smothstepper supply then? I quote from
https://www.warp9td.com/index.php/getti ... -and-mach4:
"Set your Spindle to work in Relay, Step/Dir mode, CW/CCW mode, PWM mode or Quadrature mode."
I would think/believe that Step/Dir mode OR PWM mode are the ones to chose from.

There are two output PWM-signals (on different pins of course), either a true PWM of 4,3V where you can see the dutycycle
on the oscilloscope and a simple DC 0-10V, and if I chose one of these what App in BLDC-tool should I use? I suppose ADC,
but can the input of the Vesc take that voltage? And, if so, can I supply 4.3V to either the Tx or Rx pin to mimic "Cruise control"
to keep the rpm constant and "Forward" and "Reverse". IF this is the way to go how can I control the acceleration from standstill
to the commanded rpm, I have not found a parameter for this unfortunately. Obviously I do not want 0 to 6000 rpm in 0,05seconds,
but rather in 2 seconds.

But if I could use the Step/Dir command there is a ramp-setting when configuring the motor in Mach4.
So I have checked what comes out from Mach4/ESS in this mode: You get a pulsetrain with an amplitude of 4.3V and 50% dutycycle.
The frequence varies with the commanded rpm and the "scalefactor" that you have defined, and it has ramps that you can specify
at the start and end. You also get a constant 4.3V on one or the other of two pins for "Forward" or "Reverse".
This is what I would like to use. Can this be utilized in ADC-mode or any other mode?

I do not at all mind testing but I do not want to kill the Vesc by using to high a voltage or something else because of ignorance on my part.

I thank you in advance for looking at this scenario and I will probably have a question or two more depending on if and what answers I get.

rew
Posts: 937
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Connecting VESC 4.12 to MACH4

Postby rew » 22 Apr 2017, 06:54

With a 1:3 resistor divider you can use the 0-10V analog signal.
What's wrong with the motor reaching the target speed in 0.1 seconds? If that is possible, then why not? 2 seconds is also too short to manually detect, "whoa, that's starting to wobble, lets shut it off before it starts going too fast...."

There with BLDC tools you should test setting a target RPM. Then there are settings in the advanced tab that allow you to tune the PID loop that governs that. Most people tune it to be as fast as possible, while still being stable. In your case you may want it a bit slower. On the other hand, you want the PID to react fast when the spindle goes from not hitting any metal to fully immersed to keep the RPM constant....

GunnarW
Posts: 3
Joined: 21 Apr 2017, 19:54
Location: Sweden

Re: Connecting VESC 4.12 to MACH4

Postby GunnarW » 22 Apr 2017, 17:34

Thanks for your answer!
I will do some reading about PID and try to follow your tips.
I assume that ADC is the way to test, and then the first thing will be to connect to Mach/ESS.
Do I understand correct if I use pins 3,4,5 and 6 on the 7-pin connector, that would correspond to Ground, ADC, TX and RX?
Do I have to lower the voltage on TX and RX to 3,3V or will the 4,3V from Mach/ESS be ok?
The 5V and 3,3V can be disregarded, as well as ADC2 i suppose?!

rew
Posts: 937
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Connecting VESC 4.12 to MACH4

Postby rew » 23 Apr 2017, 08:13

I don't have original VESC hardware. I don't know the original pin-numbers by heart.

Get the schematics from github, follow the traces and you end up at say PA2, PA3. Then you look for the STM32F405 DATASHEET and somewhere in the middle there is a table with the pins. For PA2 and PA3 look for the "FT" marker: Five volt tolerant.

I have the impression that ST found it difficult to make pins that also have an analog function five volt tolerant. As PA2 and PA3 are ADC pins, that would imply that they might NOT be five volt tolerant. On the other hand, newer chips have most, including the ADC pins, five volt tolerant. If the 405 is "older" or "newer" in that respect I don't know.

GunnarW
Posts: 3
Joined: 21 Apr 2017, 19:54
Location: Sweden

Re: Connecting VESC 4.12 to MACH4

Postby GunnarW » 23 Apr 2017, 17:30

Thanks again!
I have found what you suggested and some pins are FT and some are TTa so I make it easy and safe by dividing the 4,3V down to 3,3
and leave that problem.
I will now do the psysical part and then figure out how to really test out the PID settings. I guess I will have to make some kind of brake
that can be varied quick and easy to see what impact P and I changes have.
I guess there will arise more questions...


Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest