- Posts: 75
- Thank you received: 9
ASD-A2 EtherCAT on LinuxCNC
3 years 10 months ago #258698
by jirkam
Replied by jirkam on topic ASD-A2 EtherCAT on LinuxCNC
Hello.
So I tried it and the servo motors behave exactly the same.
I'm tracking the servos in the Hal Scope.
Thanks Jirka
So I tried it and the servo motors behave exactly the same.
I'm tracking the servos in the Hal Scope.
Thanks Jirka
Please Log in or Create an account to join the conversation.
3 years 10 months ago #258794
by fupeama
Martin
Replied by fupeama on topic ASD-A2 EtherCAT on LinuxCNC
Hi I think you are wrong,hal file is not a program, but only a "description". It doesn't matter what order the lines are in, because it only runs at the end when linuxcnc starts. Just like when I enter HAL lines into halcmd, I have to enter start at the end, nothing happens until then.Hello Jirka,
i have noticed an "~big" error in your hal file.
you adding lcec.real-all and write-all at the beginning of the hal file.
caused that liunxcnc builds its execution order of task functions in the order they are placed in the hal file, your servo-thread calls ec-read and then immediatly writes out lcec-write. So nothing is done with the Data in the meantime. Lcec.write-all uses "old"data from the last cycle . Which causes timing issues and leads to an bad servo tuning.
the right order would be:
addf lcec.read-all (gets data from hardware)
addf motion, value-converts, pids, classicladder etc.. (works with the data)
last addf lcec.write-all (send new data to hardware).
In your case lcec.write-all is called in front of motion and pids. So it sends "old" data from the last cylce to the drives without the new calculations. You got an 1
cycle offset between input and output data.
(you can search for "execution order" in the forum, i have descripted this in detail somewhere)
Martin
Please Log in or Create an account to join the conversation.
3 years 10 months ago #258796
by db1981
Replied by db1981 on topic ASD-A2 EtherCAT on LinuxCNC
Hi,
i am shure im absolutly right.....
Yes, hal is an description / script file. The order from net descriptions doesn't matter, but by parsing the hal also the running-order of the "realtime threads" are created.
lcnc places the running order per cycle from the functions you declare in the same order the addf commands in the hal file are placed.
This is very important for every realtime or plc system.
In every cycle every function is called 1 time, so its important to have the right order to get the expected behaviour of the realtime system.
The top description of an plc system should look like this :
-read Inputs (from Hardware)
-work with Data
-write Outpus (to Hardware)
in case of linuxcnc:
-read from hardware
-Motion Task (controll values)
-PIDs (compare actual hardware date with actual controll data)
-PLC functions
-write to hardware
i am shure im absolutly right.....
Yes, hal is an description / script file. The order from net descriptions doesn't matter, but by parsing the hal also the running-order of the "realtime threads" are created.
lcnc places the running order per cycle from the functions you declare in the same order the addf commands in the hal file are placed.
This is very important for every realtime or plc system.
In every cycle every function is called 1 time, so its important to have the right order to get the expected behaviour of the realtime system.
The top description of an plc system should look like this :
-read Inputs (from Hardware)
-work with Data
-write Outpus (to Hardware)
in case of linuxcnc:
-read from hardware
-Motion Task (controll values)
-PIDs (compare actual hardware date with actual controll data)
-PLC functions
-write to hardware
Please Log in or Create an account to join the conversation.
3 years 10 months ago #258797
by db1981
Replied by db1981 on topic ASD-A2 EtherCAT on LinuxCNC
Please Log in or Create an account to join the conversation.
3 years 10 months ago #258883
by rodw
Sorry in this case the order of lcec read and write calls is absolutley critical. What you want to do is read from the ethercat bus, let Linuxcnc modify things, then write changes back to the bus.
We ar not talking about pins here, we are calling functions so the order is critical.
Replied by rodw on topic ASD-A2 EtherCAT on LinuxCNC
Hi I think you are wrong,hal file is not a program, but only a "description". It doesn't matter what order the lines are in, because it only runs at the end when linuxcnc starts. Just like when I enter HAL lines into halcmd, I have to enter start at the end, nothing happens until then.
Martin
Sorry in this case the order of lcec read and write calls is absolutley critical. What you want to do is read from the ethercat bus, let Linuxcnc modify things, then write changes back to the bus.
We ar not talking about pins here, we are calling functions so the order is critical.
Please Log in or Create an account to join the conversation.
3 years 10 months ago - 3 years 10 months ago #258941
by db1981
Replied by db1981 on topic ASD-A2 EtherCAT on LinuxCNC
this is also very important for converter or mux functions (conv_to_float etc.)
They have to be in the right order too.
example:
If you convert an incoming encoder value, this function has to be placed between encoder readout (lcec / mesa read) and the motion / pid part. If you need to convert the motion/pid output again for the drive_cmd , this function has to be placed after motion/pid in front of the hardware output (lcec/mesa) write .
For plc/ladder this is the same.
I have read tons of bad hal / inis , when the config is growing many people start to add things at the end of their hal file or more worse in the postgui halfile. You can get very unexpected behaviour . And the issue finding could take years....
They have to be in the right order too.
example:
If you convert an incoming encoder value, this function has to be placed between encoder readout (lcec / mesa read) and the motion / pid part. If you need to convert the motion/pid output again for the drive_cmd , this function has to be placed after motion/pid in front of the hardware output (lcec/mesa) write .
For plc/ladder this is the same.
I have read tons of bad hal / inis , when the config is growing many people start to add things at the end of their hal file or more worse in the postgui halfile. You can get very unexpected behaviour . And the issue finding could take years....
Last edit: 3 years 10 months ago by db1981.
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
Time to create page: 0.187 seconds