How to divide X by Y in HAL?

More
02 Jun 2016 21:49 - 03 Jun 2016 10:40 #75366 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.
Last edit: 03 Jun 2016 10:40 by tarasko.

Please Log in or Create an account to join the conversation.

More
03 Jun 2016 06:44 - 03 Jun 2016 06:45 #75384 by tarasko
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.

More
03 Jun 2016 10:04 #75395 by andypugh

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.

More
03 Jun 2016 10:30 - 03 Jun 2016 10:32 #75399 by tarasko

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
Powered by Kunena Forum