Hal Logic Question

More
03 Feb 2019 20:12 #125604 by Todd Zuercher
I have a general hal logic question. What might be the easiest way to detect and display the order that 3 (or more) inputs were activated and display which was 1st, 2nd, 3rd...?

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

More
03 Feb 2019 21:00 - 03 Feb 2019 21:00 #125609 by PCW
Replied by PCW on topic Hal Logic Question
I dont see any obvious way to do this with existing components
but a component with a reset input and some number of boolean
inputs could count thread cycles and rank inputs as to order and perhaps
time relative to the first event (with some scheme to deal with ties)
Last edit: 03 Feb 2019 21:00 by PCW.

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

More
03 Feb 2019 21:38 - 03 Feb 2019 21:48 #125611 by Grotius
Replied by Grotius on topic Hal Logic Question
Todd,

I have made a short component for you.
You can compile it by typing : halcompile --compile Todd.comp

Warning: Spoiler!


You can test it. But you have to know how you want to implement value's to your further gui.
If i know that, i can release a full code for you.

Bitwise is kind of to simple to make a array. So i want to know how you can read in multiple value's or how you want to do that in your way. Keep in mind. It must be done in your way. Then i can do maybe some trick's for you. :laugh: B)

You can install the component directly by typing : sudo halcompile --install Todd.comp
I don't know your current installation type. Usually the --compile function is used by develloppers. --install will copy it to

This message contains confidential information

File Attachment:

File Name: Todd.comp
File Size:2 KB
Attachments:
Last edit: 03 Feb 2019 21:48 by Grotius.

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

More
04 Feb 2019 22:43 #125699 by Todd Zuercher
Replied by Todd Zuercher on topic Hal Logic Question
I ended up just doing it with Classicladder. It was relatively simple for me there. But trying only with Hal logic was a very confusing pain and I gave up. After setting it up in ladder, I can see that it would have taken at least 9 flipflops, 9 or2 and 3 and2 to sort the order of finish for 3 inputs. All that is quite hard to follow and assemble in a hal file, but it only took 4 rungs of ladder logic.

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

More
05 Feb 2019 19:58 #125759 by Mike_Eitel
Replied by Mike_Eitel on topic Hal Logic Question
I'm totally agree. My only concern is that I have no glue how much overhead is need for CL.

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

More
05 Feb 2019 20:57 - 05 Feb 2019 20:57 #125762 by rodw
Replied by rodw on topic Hal Logic Question
If you are a carpenter problems can only be solved with a hammer (or Hal or Classic ladder).
If you take the time to learn C, suddenly you have a whole toolshop at your disposal via the rich halcompile environment.

I think PCW and Grotius are on the right track to use a component and I know a few months ago Grotius had no clue about C. This is a great problem to start with and I'd recommend you take the time to learn just enough about C to write a component that solves your problem and a whole Linuxcnc new world will open. Just by reading the component code on git hub will teach you so much!
github.com/LinuxCNC/linuxcnc/tree/master/src/hal/components

Most of us who can program read a lot of other people's code as we learnt how to do it. Start by reading up on data types, then learn how it/then/else works. You probably do that in G code now so its just translating one language to another.
Last edit: 05 Feb 2019 20:57 by rodw.

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

More
05 Feb 2019 21:06 #125763 by Todd Zuercher
Replied by Todd Zuercher on topic Hal Logic Question
The overhead of CL is minimal, and doesn't effect how this old dumpster dived Celeron D PC I'm running it on runs. Maybe CL's overhead might be a problem on a RPi.

Learning C might be nice, but I need this to be working by tonight, and I had it working yesterday with CL.

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

More
06 Feb 2019 17:35 #125833 by Mike_Eitel
Replied by Mike_Eitel on topic Hal Logic Question
Hi Rod
I disagree.
In my pro life i did a lot of plc. I do not like cl much, the real thing for such work is iec61131. ( Used it already when it was still 1131)
I love and use the compile feature, but for doing pure logic a plc languague is better.
m5c

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

More
06 Feb 2019 18:50 #125845 by Todd Zuercher
Replied by Todd Zuercher on topic Hal Logic Question
If you know an open source alternative to CL that can be integrated with Linuxcnc. I'm sure the developers would welcome it inclusion as a replacement for CL. CL in Linuxcnc has been sort of an unloved orphan for some time, but soldiers on for lack of a suitable replacement.

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

More
06 Feb 2019 20:42 - 06 Feb 2019 21:39 #125866 by Mike_Eitel
Replied by Mike_Eitel on topic Hal Logic Question
For sure not any iec61131.
That ist heavy stuff. It's probably bigger than lcnc. Also you can buy it cheapo for rpi.
You can get an idea by watching coresys in YouTube. And you can see that it has powerfull ladder included as one of the standard 5-6 languagues.
I myself use either ST (structured text) or FB (funktion block) or SFC (structured funktion chart), depending the functionality i have to solve.

But, i have no proposal to. replace CL by ???.

Just make it a bit more user frindly. Commenting and alias etc. is all a bit tricky. Und why only 6 ranks, not more?
Quite some adjustments, to get it better looking, I had to do by modifying the file with an normal editor. Brrrrr.

Mike
Last edit: 06 Feb 2019 21:39 by Mike_Eitel. Reason: Some more text ;-()

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

Time to create page: 0.113 seconds
Powered by Kunena Forum