509,828 active members
2,952 visitors online

# Thread: Determining the velocity of an axis near real-time

1. ## Determining the velocity of an axis near real-time

Hi,
This is Nuri from MakerStorage LLC.
I need your help on Determining the velocity of an axis near real-time with brains (or maybe with vb script) with Mach3
I want to send this information via Modbus. I know the Modbus part but need help on getting the current velocity of one axis.

Regards,
Nuri
MakerStorage

2. ## Re: Determining the velocity of an axis near real-time

Unclear what you are trying to determine, axis angular or linear velocity?
With knowledge of the radius and feedrate (to my limited knowledge I think M3 can provide real-time), velocity for both seems pretty easy to calc

3. ## Re: Determining the velocity of an axis near real-time

Maybe something like this 813 GetDRO/SetDRO Blended Velocity DRO 813

4. ## Re: Determining the velocity of an axis near real-time

Originally Posted by Mecanix
Unclear what you are trying to determine, axis angular or linear velocity?
With knowledge of the radius and feedrate (to my limited knowledge I think M3 can provide real-time), velocity for both seems pretty easy to calc
What I am trying to get is the velocity of the A axis. ( linear velocity). I have a pallet extruder with a huge motor driven by a VFD. I will connect to the VFD over Modbus and send a frequency value in accordance with the speed of the A axis.
I am trying to read the DRO of the A axis with 100ms intervals and use the difference as a velocity indicator.

I am sure you guys have better solution than this.

Regards
Nuri
www.makerstorage.com

5. ## Re: Determining the velocity of an axis near real-time

Originally Posted by nerginer
I am sure you guys have better solution than this.
Could be.
I'd just hook up an optical or magnetic encoder IC with an affordable xilinx spartan-3 or 6 to the A axis directly and send that pulse over the vfd (if that'd be me).
Just never know what this bug'gy M3 could do... hence a hardware solution.
Have a look at the AM4096 12-bit magnetic encoder. Pretty lightweight and low cost implementation, if you need precision.
I see you are in embed from your url so that proposition might be a day work or two for you.

Otherwise no idea how you could pull this data out from M3 in a stable/real-time fashion way. Not too experienced with M3, just a user

6. ## Re: Determining the velocity of an axis near real-time

Originally Posted by Mecanix
Could be.
I'd just hook up an optical or magnetic encoder IC with an affordable xilinx spartan-3 or 6 to the A axis directly and send that pulse over the vfd (if that'd be me).
Just never know what this bug'gy M3 could do... hence a hardware solution.
Have a look at the AM4096 12-bit magnetic encoder. Pretty lightweight and low cost implementation, if you need precision.
I see you are in embed from your url so that proposition might be a day work or two for you.

Otherwise no idea how you could pull this data out from M3 in a stable/real-time fashion way. Not too experienced with M3, just a user
I think it is the correct way of doing this. I really want to see your solution. The Xilinx spartan-3 or 6 has the step pulses and the encoder feedback and calculates the error and trying to compensate it with a PID algorithm?

My solution can be very cost-effective because having the velocity of the A-axis from the brain and send it directly via Modbus to VFD with a cheap USB to RS484 converter dongle.

Anyway I am open to any idea. Thanks for sharing.

Regards
Nuri
www.makerstorage.com

7. ## Re: Determining the velocity of an axis near real-time

Depending on the level of precision required, and the update rate, you could even skip the FPGA, and just use a microcontroller for this - perhaps some variant of Arduino (something SAMD21 based? Like the Arduino Zero, or an Adafruit Feather M0).

If I was going to use a FPGA, however, I think I'd probably go for an ICE40; because there is an open-source toolchain available for it, and that toolchain isn't 7 or so GB to download; and isn't dependent on obsolete versions of either Windows or Linux... but that's me - YMMV.

8. ## Re: Determining the velocity of an axis near real-time

Originally Posted by __Britt
Depending on the level of precision required, and the update rate, you could even skip the FPGA, and just use a microcontroller for this - perhaps some variant of Arduino (something SAMD21 based? Like the Arduino Zero, or an Adafruit Feather M0).

If I was going to use a FPGA, however, I think I'd probably go for an ICE40; because there is an open-source toolchain available for it, and that toolchain isn't 7 or so GB to download; and isn't dependent on obsolete versions of either Windows or Linux... but that's me - YMMV.

I do not know if samd21 can handle both the step pulse and the encoder feedback at the same time with a PID calculation. Sand21 is a great chip and runs at 48Mhz but I have some doubts about the required CPU time.

Regards
Nuri
www.makerstorage.com

9. ## Re: Determining the velocity of an axis near real-time

Originally Posted by nerginer
The Xilinx spartan-3 or 6 has the step pulses and the encoder feedback and calculates the error and trying to compensate it with a PID algorithm?
Pretty much. A 50mhz crystal to an input pin and off you go, can pulse/duty or correct what you want based on that clock really. Good project for you to bring in hdl to your existing toolbox, if you haven't done much already.
Briit could be right about an even low'er cost ARV though, was just suggesting one of those ridiculously cheap fpga for parallel (real-time?) and speed/precision.
I really can't help on the M3 part, never really bothered too much with it, partly due to its ancient and bug'ed reputation, perhaps lol. Sure someone more familiar with it can chime in.
G'luck

10. ## Re: Determining the velocity of an axis near real-time

Since, all you need is a the velocity for the A axis, you don't need an encoder, you just need the pulse rate of the step signal driving that axis. Since you know the step size, the pulse rate will give you the velocity. You can also use the direction signal for obvious reasons.

You could read the signal with an off-the-shelf Arduino. Add a Modbus shield to the Arduino, and you can send the data directly to the VFD.

Edit:

I am assuming that it is Modbus over RTU, not TCP and that your VFD has a RS485 port with published specs.

11. ## Re: Determining the velocity of an axis near real-time

Originally Posted by maxspongebob
Since, all you need is a the velocity for the A axis, you don't need an encoder, you just need the pulse rate of the step signal driving that axis. Since you know the step size, the pulse rate will give you the velocity. You can also use the direction signal for obvious reasons.

You could read the signal with an off-the-shelf Arduino. Add a Modbus shield to the Arduino, and you can send the data directly to the VFD.

Edit:

I am assuming that it is Modbus over RTU, not TCP and that your VFD has a RS485 port with published specs.

Yes, This can be the best open-loop solution. I can set an interrupt and start a timer up to the next interrupt. This calculated time must be proportional to the axis velocity. With proper scaling, I can send it to VFD via Modbus RTU.
Thanks for the response.

Regards,
Nuri
www.makerstorge.com