- Posts: 57
- Thank you received: 0
How to divide X by Y in HAL?
10 years 4 months ago #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 :silly: "
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 :silly: "
I didn't find any hal component which can divide. Any suggestions? Thanks.
Please Log in to join the conversation.
10 years 4 months ago #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?
tarasko wrote: 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
Code:
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.
Please Log in to join the conversation.
10 years 4 months ago #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
Code: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:
Code:
loadrt generic_arithmetic cfg="x y / z * q +"
Please Log in to join the conversation.
Time to create page: 0.081 seconds
