Ethernet for CNC motor control

More
05 Dec 2016 20:07 #83701 by ReneRobotics
I'm new to LinuxCNC.
Is there a way to control my motors over ethernet.
I have this motors bit.ly/HDrive17. And I could control them with a XML message.
Now I want to do something like that -
for a CNC machine.
Thanks
Rene

Please Log in or Create an account to join the conversation.

More
05 Dec 2016 20:29 #83702 by andypugh
Well...
LinuxCNC can control machines through Ethernet, so it clearly is possible in principle.

If they can connect to EtherCAT then there may already be existing drivers (I have not looked at EtherCAT for LinuxCNC).

They might need a custom HAL driver writing, but that might not be horribly difficult.
The following user(s) said Thank You: ReneRobotics

Please Log in or Create an account to join the conversation.

More
06 Dec 2016 06:58 #83710 by ReneRobotics
Thanks Andy. Do you have an advice were to start for this in the software?

Please Log in or Create an account to join the conversation.

More
06 Dec 2016 09:32 - 06 Dec 2016 09:33 #83711 by andypugh

Thanks Andy. Do you have an advice were to start for this in the software?


The LinuxCNC driver that currently controls Mesa Ethernet devices does its sending of data here:
github.com/LinuxCNC/linuxcnc/blob/master...tmot2/hm2_eth.c#L624

But bear in mind that that has the job of integrating with all the rest of the Mesa drivers, including sharing the driver with potentially many other boards, possibly connnected through PCI and EPP and even SPI.

You could start with a very simple driver written in .comp.
Here is an example of such a driver, this is one for an old ISA card, just as an example of a relatively simple hardware driver for HAL.
github.com/LinuxCNC/linuxcnc/blob/master.../drivers/pcl720.comp
it defines a bunch of HAL pins (for that motor it would be pins to send position commands and possibly velocity commands, and others to read back the current position and other data for LinuxCNC to use) and then has a "read" function and a "write" function that assembles the HAL data into packets to send to the hardware.

The Kickstarter page has sample C code, but when writing drivers for HAL you have to be aware that the driver is called every 1mS and it _really_ has to always guarantee running to completion in much less than that time every single time it is called. It can never wait for anything. You see a lot of code in HAL drivers along the lines of

check for new data
if (new_data){
process data
} else {
quit and check next servo-cycle
}
Last edit: 06 Dec 2016 09:33 by andypugh.

Please Log in or Create an account to join the conversation.

Time to create page: 0.070 seconds
Powered by Kunena Forum