Parallel port stepper control and etherCAT I/O
01 Nov 2022 16:20 - 01 Nov 2022 16:21 #255675
by O.R
Replied by O.R on topic Parallel port stepper control and etherCAT I/O
I will test EL1124 and linear encoder, first i need to find how to configurate it. If it works even somehow and i can find some benefits to have encoders in my machine, then i have consider to buy couple EL5151 modules or similar.
Last edit: 01 Nov 2022 16:21 by O.R.
The following user(s) said Thank You: CORBETT
Please Log in or Create an account to join the conversation.
02 Nov 2022 04:45 #255750
by rodw
If only the lcnc ethercat driver had the correct code so we did not have to override it....
Replied by rodw on topic Parallel port stepper control and etherCAT I/O
Awesome to hear this. I have no idea about sudo update-ethercat-config so I'm glad its not required :ROD WEBSTER
Rod if you see this, since last night I have built 8 complete systems without fail. Super quick to do even compared to EC-Debianize way. I still get tripped up not doing a "sudo update-ethercat-config".
If only the lcnc ethercat driver had the correct code so we did not have to override it....
The following user(s) said Thank You: CORBETT
Please Log in or Create an account to join the conversation.
03 Nov 2022 05:17 #255819
by CORBETT
Replied by CORBETT on topic Parallel port stepper control and etherCAT I/O
Rod,
With EC-Debianize you would do a "sudo pico /etc/default/ethercat" and put your MAC address in just like this new way, but right after that you would do a "sudo update-ethercat-config". and it would start up the ethercat service. So, every time I put in the MAC address with this new way, I keep wanting to do the update-ethercat-config as that was the final step to get it working.
O.R
Yes, I would try it out just as a learning experience even. I have spent a lot of time learning what doesn't work, LOL. Even if you decide in the long run that the encoders are not beneficial, you can still use the EL1124 as it is 5V input and very common (I have several in use for proximity switches). Technically, your stepper system should be pretty accurate unless you are losing steps for some reason.
With EC-Debianize you would do a "sudo pico /etc/default/ethercat" and put your MAC address in just like this new way, but right after that you would do a "sudo update-ethercat-config". and it would start up the ethercat service. So, every time I put in the MAC address with this new way, I keep wanting to do the update-ethercat-config as that was the final step to get it working.
O.R
Yes, I would try it out just as a learning experience even. I have spent a lot of time learning what doesn't work, LOL. Even if you decide in the long run that the encoders are not beneficial, you can still use the EL1124 as it is 5V input and very common (I have several in use for proximity switches). Technically, your stepper system should be pretty accurate unless you are losing steps for some reason.
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
03 Nov 2022 12:14 #255838
by O.R
Replied by O.R on topic Parallel port stepper control and etherCAT I/O
I have some other mechanical upgrades to do with my lathe, before i can install linear scales and test it. Yesterday i searched HAL examples for stepper+linear encoder "close loop" setup, but i did find examples only for MESA systems and i think those configurations are made PnCConf Wizard and some hand made corrections. If somebody can help me with this software encoder close loop system test setup configuration, that would be nice. I'm also interested in an example of how to use etherCAT I/O for basic on/off control.
Please Log in or Create an account to join the conversation.
03 Nov 2022 20:04 #255865
by CORBETT
Replied by CORBETT on topic Parallel port stepper control and etherCAT I/O
O.R
I'm still working at the moment but will get back on late tonight and help you. I saw your XML file and will write some quick HAL code showing you how to link the EL1004 to the EL2004, so that if you do an input to the 1004 such as pushing a button or closing a switch it will enact the 2004 for an output. This will be a good primer so that you understand where to find the pins and how to write and link pins in your HAL file. It's not hard, you just need to see how it works and you will understand it completely. After that we will get the encoder comp working.
I will be back in a few hours.
I'm still working at the moment but will get back on late tonight and help you. I saw your XML file and will write some quick HAL code showing you how to link the EL1004 to the EL2004, so that if you do an input to the 1004 such as pushing a button or closing a switch it will enact the 2004 for an output. This will be a good primer so that you understand where to find the pins and how to write and link pins in your HAL file. It's not hard, you just need to see how it works and you will understand it completely. After that we will get the encoder comp working.
I will be back in a few hours.
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
04 Nov 2022 01:36 #255885
by CORBETT
Replied by CORBETT on topic Parallel port stepper control and etherCAT I/O
I may have to edit this as I am doing this on the fly and from my brain and that has been known to be very wrong LOL LOL
I will check this later and see if I have mistakes to correct, and I hope this is not convoluted.
Unhook your machine for safety and get everything working, then when you are sure it's safe you can hook up and try it out.
First we need to tweak your XML and add names to the terminals. Simply add: name="D1"; name="D2"; etc... in the XML
This is your XML re-worked
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="5">
<slave idx="0" type="EK1100" name="D1"/>
<slave idx="1" type="EL2004" name="D2"/>
<slave idx="2" type="EL1004" name="D3"/>
<slave idx="3" type="EL1124" name="D4"/>
</master>
</masters>
Go tweak your XML to the above and don't forget to save the file
Ok now you can go see your pins in LinuxCNC. Just start it up and when it is fully loaded go up to the "Machne" tab up top of the screen and go down and click on "Show Hal Configuration"
When the box appears look in the left side panel and the second listing is "Pins". Click and expand this, then go down to "lcec" and expand it (this is your EtherCAT comp). When you expand "lcec" you will see "0" below, expand that. Now you see the "D1, D2, D3, D4", now you can expand each of the D2, D3, or D4 and see the pins for each terminal. That listing for each pin is what you will link in your HAL file to whatever you want to link together. So below we will do just that.
OUR PLAN
This is taking the EL1004 and using a momentary pushbutton to start the spindle in the forward direction and getting a +24V DC output from the EL2004 to turn on the spindle contactor/starter if it has a +24V DC coil.
THE PHYSICAL WORK FOR EL1004
What we will do is take a physical momentary pushbutton, like the pushbuttons on most machine controllers and wire that to the input #1 of the EL1004 as an input, so that when you push the button the EL1004 will light up at the top left corner staying lit up while you hold the button and then turning off when you let go. This will be your input signal to LinuxCNC.
(If you don't have a momentary pushbutton, you can just take a piece of wire and touch the input 1 to the +24V leg of the EL1004 to mimic a pushbutton)
THE SOFTWARE WORK
Then in the HAL file we tie that EL1004 pin to LCNC's halui pin so that when you push the button is will send the signal to start the spindle forward in LCNC. This is using HAL code from LinuxCNC 2.7, so I need to check 2.8's code to see if it the same for this part.
ADD THE BELOW TO YOUR HAL FILE AND THEN SAVE
net spindle-manual-cw halui.spindle.forward lcec.0.D3.din-0
(Or find the line with the above spindle code and just add the " lcec.0.D3.din-0" to the end)
The lcec.0.D3.din-0 pin breaks down like this.
lcec is the component that you clicked on under the Tabs= Machine > Show Hal Configuration THEN box appears Pins > lcec > 0 > D3
D3 is the position of the EL1004 terminal. It's the 3rd device connected counting the EK1100 as the 1st device as shown in the XML.
din-0 is the input 1 pin for the EL1004 terminal. You will have a din-0 and a din-0-not pin for each input so that you can link whether on or off
Then start up LinuxCNC to see if it will startup wihtout errors. If it fails to startup, copy the error part so we can figure out the problem, but it should startup without an issue. Then with LCNC in the E-stop ready and Machine-on ready, try the momentary pushbutton to see if your spindle forward starts in LinuxCNC software. Once it is working properly and you can start the spindle with the momentary pushbutton, then you can finish with tying the EL2004 to the spindle-on pin of LinuxCNC so that you can operate a contactor or starter.
So, if your magnetic starter for the spindle motor has a +24V DC coil, then you can wire it directly to the EL2004 for it to operate when you push the momentary pushbutton (as long as it doesn't take over 1/2 amp).
ADD THE BELOW TO YOUR HAL FILE AND THEN SAVE
net spindle-on motion.spindle-on lcec.0.D2.dout-0
Now you can restart LinxuCNC and try the momentary pushbutton and it should have everything working after you hardwire the coil to the EL2004.
This should get you going for the I/O part. I will clean all of this up and make it a better read, plus add some picture examples. Once you are good on this part, we will work on the encoder component.
Hope it helps,
Robert
I will check this later and see if I have mistakes to correct, and I hope this is not convoluted.
Unhook your machine for safety and get everything working, then when you are sure it's safe you can hook up and try it out.
First we need to tweak your XML and add names to the terminals. Simply add: name="D1"; name="D2"; etc... in the XML
This is your XML re-worked
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="5">
<slave idx="0" type="EK1100" name="D1"/>
<slave idx="1" type="EL2004" name="D2"/>
<slave idx="2" type="EL1004" name="D3"/>
<slave idx="3" type="EL1124" name="D4"/>
</master>
</masters>
Go tweak your XML to the above and don't forget to save the file
Ok now you can go see your pins in LinuxCNC. Just start it up and when it is fully loaded go up to the "Machne" tab up top of the screen and go down and click on "Show Hal Configuration"
When the box appears look in the left side panel and the second listing is "Pins". Click and expand this, then go down to "lcec" and expand it (this is your EtherCAT comp). When you expand "lcec" you will see "0" below, expand that. Now you see the "D1, D2, D3, D4", now you can expand each of the D2, D3, or D4 and see the pins for each terminal. That listing for each pin is what you will link in your HAL file to whatever you want to link together. So below we will do just that.
OUR PLAN
This is taking the EL1004 and using a momentary pushbutton to start the spindle in the forward direction and getting a +24V DC output from the EL2004 to turn on the spindle contactor/starter if it has a +24V DC coil.
THE PHYSICAL WORK FOR EL1004
What we will do is take a physical momentary pushbutton, like the pushbuttons on most machine controllers and wire that to the input #1 of the EL1004 as an input, so that when you push the button the EL1004 will light up at the top left corner staying lit up while you hold the button and then turning off when you let go. This will be your input signal to LinuxCNC.
(If you don't have a momentary pushbutton, you can just take a piece of wire and touch the input 1 to the +24V leg of the EL1004 to mimic a pushbutton)
THE SOFTWARE WORK
Then in the HAL file we tie that EL1004 pin to LCNC's halui pin so that when you push the button is will send the signal to start the spindle forward in LCNC. This is using HAL code from LinuxCNC 2.7, so I need to check 2.8's code to see if it the same for this part.
ADD THE BELOW TO YOUR HAL FILE AND THEN SAVE
net spindle-manual-cw halui.spindle.forward lcec.0.D3.din-0
(Or find the line with the above spindle code and just add the " lcec.0.D3.din-0" to the end)
The lcec.0.D3.din-0 pin breaks down like this.
lcec is the component that you clicked on under the Tabs= Machine > Show Hal Configuration THEN box appears Pins > lcec > 0 > D3
D3 is the position of the EL1004 terminal. It's the 3rd device connected counting the EK1100 as the 1st device as shown in the XML.
din-0 is the input 1 pin for the EL1004 terminal. You will have a din-0 and a din-0-not pin for each input so that you can link whether on or off
Then start up LinuxCNC to see if it will startup wihtout errors. If it fails to startup, copy the error part so we can figure out the problem, but it should startup without an issue. Then with LCNC in the E-stop ready and Machine-on ready, try the momentary pushbutton to see if your spindle forward starts in LinuxCNC software. Once it is working properly and you can start the spindle with the momentary pushbutton, then you can finish with tying the EL2004 to the spindle-on pin of LinuxCNC so that you can operate a contactor or starter.
So, if your magnetic starter for the spindle motor has a +24V DC coil, then you can wire it directly to the EL2004 for it to operate when you push the momentary pushbutton (as long as it doesn't take over 1/2 amp).
ADD THE BELOW TO YOUR HAL FILE AND THEN SAVE
net spindle-on motion.spindle-on lcec.0.D2.dout-0
Now you can restart LinxuCNC and try the momentary pushbutton and it should have everything working after you hardwire the coil to the EL2004.
This should get you going for the I/O part. I will clean all of this up and make it a better read, plus add some picture examples. Once you are good on this part, we will work on the encoder component.
Hope it helps,
Robert
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
04 Nov 2022 19:31 #255947
by O.R
Replied by O.R on topic Parallel port stepper control and etherCAT I/O
Thanks CORBETT i'll try that in this weekend.
The following user(s) said Thank You: CORBETT
Please Log in or Create an account to join the conversation.
06 Nov 2022 17:46 #256085
by O.R
Replied by O.R on topic Parallel port stepper control and etherCAT I/O
Ok, i added module names to my XML file and added this "net spindle-manual-cw halui.spindle.forward lcec.0.D3.din-0" to end of my HAL file. I get error at LinuxCNC startup " ./Lathe.hal:73: Pin 'halui.spindle.forward' does not exist". Also with " net spindle-on motion.spindle-on lcec.0.D2.dout-0" i get same error.
Then i tried replace the line " net spindle-manual-cw halui.spindle.forward lcec.0.D3.din-0" with this " net spindle-cw => lcec.0.D2.dout-0". No errors, but output does not change state, if i press the spindle CW button in LinuxCNC.
Then i tried replace the line " net spindle-manual-cw halui.spindle.forward lcec.0.D3.din-0" with this " net spindle-cw => lcec.0.D2.dout-0". No errors, but output does not change state, if i press the spindle CW button in LinuxCNC.
Please Log in or Create an account to join the conversation.
06 Nov 2022 19:22 #256087
by rodw
Replied by rodw on topic Parallel port stepper control and etherCAT I/O
spindle.0.forward
Ref: linuxcnc.org/docs/devel/html/man/man9/mo....html#SPINDLE%20PINS
You are using obsolete 2.7 syntax in 2.8 or 2.9
Ref: linuxcnc.org/docs/devel/html/man/man9/mo....html#SPINDLE%20PINS
You are using obsolete 2.7 syntax in 2.8 or 2.9
Please Log in or Create an account to join the conversation.
07 Nov 2022 19:32 - 07 Nov 2022 19:40 #256159
by O.R
Replied by O.R on topic Parallel port stepper control and etherCAT I/O
Ok, this works:
I tried to trigger LinuxCNC Estop button, but did not work. Only HAL config shows that estop-ext signal changes the state.
net spindle-cw <= spindle.0.forward
net spindle-cw => lcec.0.D2.dout-0
I tried to trigger LinuxCNC Estop button, but did not work. Only HAL config shows that estop-ext signal changes the state.
net estop-ext <= lcec.0.D3.din-0
Last edit: 07 Nov 2022 19:40 by O.R.
Please Log in or Create an account to join the conversation.
Time to create page: 0.087 seconds