Closed loop servo control with custom driver board
- HerrNamenlos123
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 2
15 Feb 2021 19:02 - 15 Feb 2021 19:07 #198959
by HerrNamenlos123
Hi,
sorry for the long text in advance, but i want to explain in detail what my goal is...
I want to build a CNC mill/router/whatever with homemade dc servo motors and homemade encoders. I am currently using ordinary dc motors, controlled by an Arduino, which controls them with a PID controller according to the encoder input. That's all working well, but my arduino is a replacement for GRBL, which means i am doing all G-Code parsing and trajectory planning myself, which i clearly shouldn't be doing.
It's time to take it to the next level. I started writing a program, which acts like a PoKeys Ethernet device and talks to Mach3, but that is also not a permanent solution. In the best case i would want LinuxCNC to do all the work, realtime motion control and servo tuning and my homemade board would only forward signals to the dc motor drivers and count the encoder pulses.
Specifically, i want to make an STM32 based board, which LinuxCNC talks to in the following way:
"Hey, set motor X to 50% power and tell me where axis Y is right now. BTW, is the emergency button pressed?"...
If that's not possible because ethernet is too slow or something similar, i'm fine with PID controlling the servos myself, but i still want LinuxCNC to tell me the current positions and ask for the actual positions.
I do NOT want LinuxCNC or Mach3 or any other software to generate Step/Dir pulses, as the STM32 would need to count those, which is ridiculously unnecessary.
Is there a way i can let LinuxCNC talk like this to my homemade board, maybe over ethernet or Beckhoff EtherCAT or the parallel port?
Do i need to write a custom HAL driver for that or is there something available?
Is there something like an ethernet mesa card driver i can imitate, so LinuxCNC thinks it's talking to a mesa card, but is really talking to my own board?
And last, but not least, can all of this be done without buying extra hardware, so it only uses ethernet or the parallel port?
Sorry for the long text, any help or ideas appreciated...
Regards,
Florian
sorry for the long text in advance, but i want to explain in detail what my goal is...
I want to build a CNC mill/router/whatever with homemade dc servo motors and homemade encoders. I am currently using ordinary dc motors, controlled by an Arduino, which controls them with a PID controller according to the encoder input. That's all working well, but my arduino is a replacement for GRBL, which means i am doing all G-Code parsing and trajectory planning myself, which i clearly shouldn't be doing.
It's time to take it to the next level. I started writing a program, which acts like a PoKeys Ethernet device and talks to Mach3, but that is also not a permanent solution. In the best case i would want LinuxCNC to do all the work, realtime motion control and servo tuning and my homemade board would only forward signals to the dc motor drivers and count the encoder pulses.
Specifically, i want to make an STM32 based board, which LinuxCNC talks to in the following way:
"Hey, set motor X to 50% power and tell me where axis Y is right now. BTW, is the emergency button pressed?"...
If that's not possible because ethernet is too slow or something similar, i'm fine with PID controlling the servos myself, but i still want LinuxCNC to tell me the current positions and ask for the actual positions.
I do NOT want LinuxCNC or Mach3 or any other software to generate Step/Dir pulses, as the STM32 would need to count those, which is ridiculously unnecessary.
Is there a way i can let LinuxCNC talk like this to my homemade board, maybe over ethernet or Beckhoff EtherCAT or the parallel port?
Do i need to write a custom HAL driver for that or is there something available?
Is there something like an ethernet mesa card driver i can imitate, so LinuxCNC thinks it's talking to a mesa card, but is really talking to my own board?
And last, but not least, can all of this be done without buying extra hardware, so it only uses ethernet or the parallel port?
Sorry for the long text, any help or ideas appreciated...
Regards,
Florian
Last edit: 15 Feb 2021 19:07 by HerrNamenlos123.
Please Log in or Create an account to join the conversation.
15 Feb 2021 19:36 #198965
by jmelson
Replied by jmelson on topic Closed loop servo control with custom driver board
The Pico Systems universal PWM controller works pretty much like this. It reads encoder position and generates a PWM pulse train as commanded by LinuxCNC.
So, the trajectory planner sends out a bunch of positions, and the PID component adjusts the PWM output to get the most accurate following of that commanded position.
Pico Systems makes some servo amps (brush type and brushless) that take in the PWM and output power to the motor.
Pico Systems also makes the PPMC which does this with an analog velocity command to an analog verlocity servo amp.
Jon
So, the trajectory planner sends out a bunch of positions, and the PID component adjusts the PWM output to get the most accurate following of that commanded position.
Pico Systems makes some servo amps (brush type and brushless) that take in the PWM and output power to the motor.
Pico Systems also makes the PPMC which does this with an analog velocity command to an analog verlocity servo amp.
Jon
Please Log in or Create an account to join the conversation.
- HerrNamenlos123
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 2
15 Feb 2021 22:00 #198991
by HerrNamenlos123
Replied by HerrNamenlos123 on topic Closed loop servo control with custom driver board
I have already looked at the PPMC board and the others, but couldn't find anything helpful. Is there any information on how to interface with them or is there a driver for LinuxCNC that needs to be installed?
Also, is it connected to the parallel port or ethernet port? I only found PCi versions, which i can't manufacture easily...
Florian
Also, is it connected to the parallel port or ethernet port? I only found PCi versions, which i can't manufacture easily...
Florian
Please Log in or Create an account to join the conversation.
15 Feb 2021 23:00 #198998
by jmelson
Replied by jmelson on topic Closed loop servo control with custom driver board
The driver for all 3 of our products is included in the LinuxCNC distribution. In the source, it is under hal/drivers/by_interface/pico/hal_ppmc.c
The driver is "installed" with the hal command loadrt, which loads a pre-compiled kernel-level real time driver and makes it available to hal via the addf command.
The driver scans the parallel port for devices and exports pins and functions to hal based on what boards it can enumerate.
It is interfaced via a parallel port. Using the EPP protocol, there are registers in the device that are accessed by selecting the address and then reading or writing a contiguous block of registers.
Our boards are not PCI, but could be interfaced through a PCI or PCIe parallel port card, or an on-motherboard parallel port.
The driver is "installed" with the hal command loadrt, which loads a pre-compiled kernel-level real time driver and makes it available to hal via the addf command.
The driver scans the parallel port for devices and exports pins and functions to hal based on what boards it can enumerate.
It is interfaced via a parallel port. Using the EPP protocol, there are registers in the device that are accessed by selecting the address and then reading or writing a contiguous block of registers.
Our boards are not PCI, but could be interfaced through a PCI or PCIe parallel port card, or an on-motherboard parallel port.
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19196
- Thank you received: 6434
15 Feb 2021 23:18 #198999
by tommylight
Replied by tommylight on topic Closed loop servo control with custom driver board
Read this twice today and for the life of me i can figure out what you are trying to do, the only thing i got from all that post is that you want to use a human to move the machine and check the e-stop !!!
Everything that you want and mention is already in LinuxCNC, be it through parallel port or Mesa or Pico boards, or Ethercat or some other boards/controllers/hardware.
The only difference is none of that will go check the e-stop, they would know the moment they are turned on and running what the e-stop is up to.
Maybe this is all due to getting used to how Mach does things, this is not it, LinuxCNC is a motion controller, it can generate step/dir pulses, PWM, read encoders, generate 3 phase 6 output PWM for BLDC motor drives, it can generate quadrature outputs for 2 or 3 or 5 phase stepper motor drives, it can use hal sensors for the aforementioned BLDC, and a lot of other stuff, ALL of that with no other software or hardware, just using a parallel port.
Since you are willing to make the boards yourself, have a look at Mesa and Pico, all the drivers are included and are open source, very useful info there.
Everything that you want and mention is already in LinuxCNC, be it through parallel port or Mesa or Pico boards, or Ethercat or some other boards/controllers/hardware.
The only difference is none of that will go check the e-stop, they would know the moment they are turned on and running what the e-stop is up to.
Maybe this is all due to getting used to how Mach does things, this is not it, LinuxCNC is a motion controller, it can generate step/dir pulses, PWM, read encoders, generate 3 phase 6 output PWM for BLDC motor drives, it can generate quadrature outputs for 2 or 3 or 5 phase stepper motor drives, it can use hal sensors for the aforementioned BLDC, and a lot of other stuff, ALL of that with no other software or hardware, just using a parallel port.
Since you are willing to make the boards yourself, have a look at Mesa and Pico, all the drivers are included and are open source, very useful info there.
Please Log in or Create an account to join the conversation.
16 Feb 2021 02:25 #199014
by rodw
Replied by rodw on topic Closed loop servo control with custom driver board
I think Tommy is right. Linuxcnc is the motion controller so it knows if the estop is set
and it also knows the axis position at any time.
You summed up your scope nicely.
Take the time to understand how the mesa cards work with the hm2_eth component
and it also knows the axis position at any time.
You summed up your scope nicely.
my homemade board would only forward signals to the dc motor drivers and count the encoder pulses.
Take the time to understand how the mesa cards work with the hm2_eth component
Please Log in or Create an account to join the conversation.
- HerrNamenlos123
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 2
16 Feb 2021 17:46 - 16 Feb 2021 17:48 #199092
by HerrNamenlos123
Replied by HerrNamenlos123 on topic Closed loop servo control with custom driver board
Thank you for your answers!
The thing with the emergency stop was just an example for an input, i was thinking of a physical button like a limit switch. Forget about that.
I have now installed LinuxCNC and i am trying around with different mesa card configurations and decided i want to emulate the Mesa 7i80HD ethernet card. I would use a laptop with software to emulate it and when it's finished, i would port the code to the microcontroller, just like i did with the PoKeys device.
I can set the ip address of the card and when LinuxCNC is started, it stops right away and says it can't find the card.
Does anyone know some kind of specification for the ethernet interface, which exact packets need to be sent? Is it even open source? I can't really find anything helpful...
The thing with the emergency stop was just an example for an input, i was thinking of a physical button like a limit switch. Forget about that.
I have now installed LinuxCNC and i am trying around with different mesa card configurations and decided i want to emulate the Mesa 7i80HD ethernet card. I would use a laptop with software to emulate it and when it's finished, i would port the code to the microcontroller, just like i did with the PoKeys device.
I can set the ip address of the card and when LinuxCNC is started, it stops right away and says it can't find the card.
Does anyone know some kind of specification for the ethernet interface, which exact packets need to be sent? Is it even open source? I can't really find anything helpful...
Last edit: 16 Feb 2021 17:48 by HerrNamenlos123. Reason: Added information
Please Log in or Create an account to join the conversation.
16 Feb 2021 19:05 #199098
by PCW
Replied by PCW on topic Closed loop servo control with custom driver board
Did you look at the 7I80 manual?
It describes the interface protocol
It describes the interface protocol
Please Log in or Create an account to join the conversation.
- HerrNamenlos123
- Topic Author
- Offline
- New Member
Less
More
- Posts: 17
- Thank you received: 2
16 Feb 2021 20:05 #199103
by HerrNamenlos123
Replied by HerrNamenlos123 on topic Closed loop servo control with custom driver board
I am reading through it and it does give some good hints, but sadly it doesn't give me the information i need...
Like it for example specifies all eeprom addresses and what specific bits it the message mean and the UDP port, but it mostly doesn't specify what should come back from the board: If it's the same socket, what packet length, ...
Like it for example specifies all eeprom addresses and what specific bits it the message mean and the UDP port, but it mostly doesn't specify what should come back from the board: If it's the same socket, what packet length, ...
Please Log in or Create an account to join the conversation.
16 Feb 2021 20:19 #199104
by PCW
Replied by PCW on topic Closed loop servo control with custom driver board
It returns data to the requesting socket
And the returned packet size depends on how much
read data has been requested in the request packet
(this can also be determined by looking at the hm2_eth driver source)
And the returned packet size depends on how much
read data has been requested in the request packet
(this can also be determined by looking at the hm2_eth driver source)
Please Log in or Create an account to join the conversation.
Time to create page: 0.091 seconds