How to divide X by Y in HAL?
02 Jun 2016 21:49 - 03 Jun 2016 10:40 #75366
by tarasko
How to divide X by Y in HAL? was created by tarasko
I have two gmoccapy pins.
gmoccapy.program.length is an out pin (S32) showing the total number of lines of the program
gmoccapy.program.current-line is an out pin (S32) indicating the current working line of the program
I learned to count duration of a program execution using this useful article.
So we can calculate "speed" of program execution measured in lines per minute.
Why do I need this?
Well, then I can estimate program execution remaining time, e.g. "how long do I need to wait till this machine will stop producing noise "
I didn't find any hal component which can divide. Any suggestions? Thanks.
gmoccapy.program.length is an out pin (S32) showing the total number of lines of the program
gmoccapy.program.current-line is an out pin (S32) indicating the current working line of the program
I learned to count duration of a program execution using this useful article.
So we can calculate "speed" of program execution measured in lines per minute.
Why do I need this?
Well, then I can estimate program execution remaining time, e.g. "how long do I need to wait till this machine will stop producing noise "
I didn't find any hal component which can divide. Any suggestions? Thanks.
Last edit: 03 Jun 2016 10:40 by tarasko.
Please Log in or Create an account to join the conversation.
03 Jun 2016 06:44 - 03 Jun 2016 06:45 #75384
by tarasko
Replied by tarasko on topic How to divide X by Y in HAL?
By reading the
manual
I see that we can implement our own components. So I'll try to implement my arithmetic operation
Last edit: 03 Jun 2016 06:45 by tarasko.
Please Log in or Create an account to join the conversation.
03 Jun 2016 10:04 #75395
by andypugh
You can use linuxcnc.org/docs/2.7/html/man/man9/invert.9.html and linuxcnc.org/docs/2.7/html/man/man9/mult2.9.html
It would be nice to have a generic arithmetic component
But such a component would need quite a complex parser to be useful, there's no "eval" function in C.
Replied by andypugh on topic How to divide X by Y in HAL?
I didn't find any hal component which can divide. Any suggestions? Thanks.
You can use linuxcnc.org/docs/2.7/html/man/man9/invert.9.html and linuxcnc.org/docs/2.7/html/man/man9/mult2.9.html
It would be nice to have a generic arithmetic component
loadrt generic_arithmetic cfg="(x/y)*z+q"
But such a component would need quite a complex parser to be useful, there's no "eval" function in C.
The following user(s) said Thank You: tarasko
Please Log in or Create an account to join the conversation.
03 Jun 2016 10:30 - 03 Jun 2016 10:32 #75399
by tarasko
Well, as an example we can take an implementation of a Reverse polish notation parser from this cute book on page 74. This notation is a bit unusual, but the program implementation is very simple.
So the final configuration string will look like next:
Replied by tarasko on topic How to divide X by Y in HAL?
It would be nice to have a generic arithmetic component
loadrt generic_arithmetic cfg="(x/y)*z+q"
But such a component would need quite a complex parser to be useful, there's no "eval" function in C.
Well, as an example we can take an implementation of a Reverse polish notation parser from this cute book on page 74. This notation is a bit unusual, but the program implementation is very simple.
So the final configuration string will look like next:
loadrt generic_arithmetic cfg="x y / z * q +"
Last edit: 03 Jun 2016 10:32 by tarasko.
Please Log in or Create an account to join the conversation.
Time to create page: 0.189 seconds