Hello HAL...er, world!
09 Sep 2018 19:59 #117254
by pferrick
Hello HAL...er, world! was created by pferrick
Hi all-
I'm trying to get a Linuxcnc-style, extended-Hello World! setup working, where an LED goes on when a checkbutton is ticked. [I figure that once I can do that, a lot of what I would really like do will be possible!) Here's what I am trying to do in a nutshell:
gmoccapy -> user tab -> HAL Checkbutton -> (hm2_5i25.0.7i76.0.0.output-07) -> 5i25 -> 7i76 -> LED on output 07
So far I have pretty much everything but the middle part working. (that's where the A in HAL is kinda kicking my butt!)
I have managed to:
1. use Glade to create an interface on a user tab
2. verify with Halmeter that the state of the checkbutton changes as expected
3. light the LED by using halrun like this:
halcmd: loadrt threads name1=th period1=1000000
halcmd: loadrt hostmot2
halcmd: loadrt hm2_pci
halcmd: addf hm2_5i25.0.read th
halcmd: addf hm2_5i25.0.write th
halcmd: start
halcmd: setp hm2_5i25.0.7i76.0.0.output-07 true
What I'm quite confused about is exactly how to connect the state of the checkbox to the HAL pin in question. I suspect that a net command will be necessary (probably in the postgui.hal file) to connect the HAL pin in question to a signal (generated somehow from HAL widgets on the user tab).
I assure you that I have read and re-read the docs for gmoccapy, GladeVCP programming and the Mesa board. That has gotten me to the point that I am confident I can understand the solution, if someone would be kind enough to outline it for me!
Thank you very much in advance.
regards,
Pat
ps - anyone else have to take your best shot at spelling gmoccapy when Googling it, and hope for the best?!?? Is it an acronym or a portmanteau of non-English words...?! Just curious...
I'm trying to get a Linuxcnc-style, extended-Hello World! setup working, where an LED goes on when a checkbutton is ticked. [I figure that once I can do that, a lot of what I would really like do will be possible!) Here's what I am trying to do in a nutshell:
gmoccapy -> user tab -> HAL Checkbutton -> (hm2_5i25.0.7i76.0.0.output-07) -> 5i25 -> 7i76 -> LED on output 07
So far I have pretty much everything but the middle part working. (that's where the A in HAL is kinda kicking my butt!)
I have managed to:
1. use Glade to create an interface on a user tab
2. verify with Halmeter that the state of the checkbutton changes as expected
3. light the LED by using halrun like this:
halcmd: loadrt threads name1=th period1=1000000
halcmd: loadrt hostmot2
halcmd: loadrt hm2_pci
halcmd: addf hm2_5i25.0.read th
halcmd: addf hm2_5i25.0.write th
halcmd: start
halcmd: setp hm2_5i25.0.7i76.0.0.output-07 true
What I'm quite confused about is exactly how to connect the state of the checkbox to the HAL pin in question. I suspect that a net command will be necessary (probably in the postgui.hal file) to connect the HAL pin in question to a signal (generated somehow from HAL widgets on the user tab).
I assure you that I have read and re-read the docs for gmoccapy, GladeVCP programming and the Mesa board. That has gotten me to the point that I am confident I can understand the solution, if someone would be kind enough to outline it for me!
Thank you very much in advance.
regards,
Pat
ps - anyone else have to take your best shot at spelling gmoccapy when Googling it, and hope for the best?!?? Is it an acronym or a portmanteau of non-English words...?! Just curious...
Please Log in or Create an account to join the conversation.
09 Sep 2018 20:02 #117255
by pferrick
Replied by pferrick on topic Hello HAL...er, world!
I forgot to mention that the next steps would be:
1. getting the LED to go on only when a button is being pressed
2. having it stay on for a set amount of time after the button is released (say, 2 seconds) and then go off
PKF
1. getting the LED to go on only when a button is being pressed
2. having it stay on for a set amount of time after the button is released (say, 2 seconds) and then go off
PKF
Please Log in or Create an account to join the conversation.
09 Sep 2018 20:17 - 09 Sep 2018 20:27 #117258
by Grotius
Replied by Grotius on topic Hello HAL...er, world!
Hi Patrick Ferrick,
Checkbox end's different in hal.
Sometimes you have a signal like "Patrick".
Then for example.. checkbox in hal, you can read in the hal signal list : "Patrick-fs".
So signal name with checkbox is a little different. I hope this example will help you.
Checkboxes are really good to use.
Led's are nice object's to use. A delay time of 2 second's is not included in glade.
In python it's also not my wish. The time component can solve your wishes. You can make a hal connection to make
the led be on for 2 second's. If you want more. Write your own hal component. Copy a simple component and modify it,
compile it, and test it. You would be amazed.
Checkbox end's different in hal.
Sometimes you have a signal like "Patrick".
Then for example.. checkbox in hal, you can read in the hal signal list : "Patrick-fs".
So signal name with checkbox is a little different. I hope this example will help you.
Checkboxes are really good to use.
Led's are nice object's to use. A delay time of 2 second's is not included in glade.
In python it's also not my wish. The time component can solve your wishes. You can make a hal connection to make
the led be on for 2 second's. If you want more. Write your own hal component. Copy a simple component and modify it,
compile it, and test it. You would be amazed.
Last edit: 09 Sep 2018 20:27 by Grotius.
Please Log in or Create an account to join the conversation.
09 Sep 2018 23:50 #117265
by pferrick
Replied by pferrick on topic Hello HAL...er, world!
OK, on further experimentation I now have a very specific (hopefully easier-to-answer) question:
I have a checkbutton called hal_checkbutton1 on my gmocappy. Ultimately I want it to control the state of a 7i76 output.
So I created a custom_postgui.hal file with this line in it (and made reference to this in my ini file):
net hal_checkbutton1 => hm2_5i25.0.7i76.0.0.output-07
This didn't have any effect on the LED. So I thought I'd keep an eye on things via halmeter. It was then that I noticed a signal called, amazingly enough,
hal_checkbutton1
However, clicking on the checkbutton also does NOT change the state of this signal. So that seems to be the issue: why? What do I have to do to make it so that changing the checkbutton state causes a change in this signal, which when connected to the output halpin should control the LED?
Feel like I'm getting closer to understanding HAL all the time. (as long as I don't get a dialog box that says "I'm sorry, Pat. I'm afraid I can't do that." then I'm probably OK..!!!!!)
Thanks again!
Pat
I have a checkbutton called hal_checkbutton1 on my gmocappy. Ultimately I want it to control the state of a 7i76 output.
So I created a custom_postgui.hal file with this line in it (and made reference to this in my ini file):
net hal_checkbutton1 => hm2_5i25.0.7i76.0.0.output-07
This didn't have any effect on the LED. So I thought I'd keep an eye on things via halmeter. It was then that I noticed a signal called, amazingly enough,
hal_checkbutton1
However, clicking on the checkbutton also does NOT change the state of this signal. So that seems to be the issue: why? What do I have to do to make it so that changing the checkbutton state causes a change in this signal, which when connected to the output halpin should control the LED?
Feel like I'm getting closer to understanding HAL all the time. (as long as I don't get a dialog box that says "I'm sorry, Pat. I'm afraid I can't do that." then I'm probably OK..!!!!!)
Thanks again!
Pat
Please Log in or Create an account to join the conversation.
10 Sep 2018 00:32 - 10 Sep 2018 00:45 #117267
by PCW
Replied by PCW on topic Hello HAL...er, world!
net hal_checkbutton1 => hm2_5i25.0.7i76.0.0.output-07
connects a signal ( hal_checkbutton1 ) to a pin ( hm2_5i25.0.7i76.0.0.output-07 )
unless you have a pin that drives the signal hal_checkbutton1 that line will do nothing by itself
Think of signals as wires with names, and in addition signal names are
arbitrary so:
net blue_tuba => hm2_5i25.0.7i76.0.0.output-07
is equivalent to
net hal_checkbutton1 => hm2_5i25.0.7i76.0.0.output-07
Whats missing here is the pin name from the GUI so a statement like
net hal_checkbutton1 whatever_the_gui_checkbutton_pin_name_is => hm2_5i25.0.7i76.0.0.output-07
would be complete as would the equivalent set of statements
net blue_tuba <= whatever_the_gui_checkbutton_pin_name_is
net blue_tuba => hm2_5i25.0.7i76.0.0.output-07
To get a list of all pin names, you can run this command:
halcmd show pin
connects a signal ( hal_checkbutton1 ) to a pin ( hm2_5i25.0.7i76.0.0.output-07 )
unless you have a pin that drives the signal hal_checkbutton1 that line will do nothing by itself
Think of signals as wires with names, and in addition signal names are
arbitrary so:
net blue_tuba => hm2_5i25.0.7i76.0.0.output-07
is equivalent to
net hal_checkbutton1 => hm2_5i25.0.7i76.0.0.output-07
Whats missing here is the pin name from the GUI so a statement like
net hal_checkbutton1 whatever_the_gui_checkbutton_pin_name_is => hm2_5i25.0.7i76.0.0.output-07
would be complete as would the equivalent set of statements
net blue_tuba <= whatever_the_gui_checkbutton_pin_name_is
net blue_tuba => hm2_5i25.0.7i76.0.0.output-07
To get a list of all pin names, you can run this command:
halcmd show pin
Last edit: 10 Sep 2018 00:45 by PCW.
Please Log in or Create an account to join the conversation.
10 Sep 2018 01:46 #117271
by pferrick
Replied by pferrick on topic Hello HAL...er, world!
Thanks for the quick and well-explained answer. So I basically left a (virtual) wire dangling...! I looked up the name of the pin associated with the widget and added it to the net command and...voila...I see the (dim, red, LED) light!!!!
I am a happy camper right now.
[Now to start doing battle with timedelay !!!!! We are gluttons for punishment, aren't we?!]
regards,
Pat
I am a happy camper right now.
[Now to start doing battle with timedelay !!!!! We are gluttons for punishment, aren't we?!]
regards,
Pat
Please Log in or Create an account to join the conversation.
10 Sep 2018 04:29 #117274
by cmorley
G Mocca Py
G for GTK - the GUI toolkit it uses
Mocca for the screen it was roughly patterned from (an obscure out of tree screen built with a weird language choice - pascal IIRC)
Py for python
pronounced Gee Moca Pie
Chris M
Replied by cmorley on topic Hello HAL...er, world!
Hi all-
ps - anyone else have to take your best shot at spelling gmoccapy when Googling it, and hope for the best?!?? Is it an acronym or a portmanteau of non-English words...?! Just curious...
G Mocca Py
G for GTK - the GUI toolkit it uses
Mocca for the screen it was roughly patterned from (an obscure out of tree screen built with a weird language choice - pascal IIRC)
Py for python
pronounced Gee Moca Pie
Chris M
Please Log in or Create an account to join the conversation.
11 Sep 2018 14:29 #117334
by andypugh
Replied by andypugh on topic Hello HAL...er, world!
Please Log in or Create an account to join the conversation.
Moderators: HansU
Time to create page: 0.085 seconds