Run GladeVCP from halrun

More
16 Aug 2012 23:18 - 17 Aug 2012 00:02 #23317 by BigJohnT
Just exploring options for wd5jwy and I'm trying to run a GladeVCP panel with halrun as all he needs is a stepgen or two...

This is the code in my start.hal file so far
loadusr -Wn gladevcp gladevcp -c gladevcp wd.glade
loadrt threads name1=fast period1=50000 fp1=0 name2=slow period2=1000000

loadrt stepgen step_type=0,0 ctrl_type=v,v

addf stepgen.update-freq slow
addf stepgen.make-pulses fast

setp stepgen.0.position-scale 10000
setp stepgen.0.enable 1

start

Ok the stepgens fire up but the spinbox in my control the up and down arrow keys are disabled. Does this have to do with the handler.py that I've not used yet?

File Attachment:

File Name: wd.glade
File Size:1 KB


John
Attachments:
Last edit: 17 Aug 2012 00:02 by BigJohnT.

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

More
16 Aug 2012 23:58 - 17 Aug 2012 00:08 #23319 by BigJohnT
wd5jwy, I think I have a skeleton for you to try... it needs more work to achieve your goals but should show you the way.

The spin button sets the velocity command for the stepgen and the start toggle enables the stepgen... read carefully the GladeVCP manual on the spin box!

The only thing I've not figured out is how to shut down hal when the window is closed but I bet someone knows how... also look at my Glade/Python tutorial 4 for the calculate code to do your scale.



File Attachment:

File Name: wd5.zip
File Size:4 KB


John
Attachments:
Last edit: 17 Aug 2012 00:08 by BigJohnT.

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

More
17 Aug 2012 01:54 #23324 by wd5jwy
Replied by wd5jwy on topic Re:Run GladeVCP from halrun
Wow! John - you didn't have to do all that, but I'm glad you did. This is a great jump start for me. I'm reading through the files to see how you did it. I see the hal commands to set up the stepgen and I see the thread creation. I haven't yet figured out how you are passing the value from the spinbutton to the stepgen - or are you? Did you leave that for me to figure out? If so, that will be a good exercise for me.

Also, I think I found a typo in the python file:

def on_start_button_toggled(self, wedget, data=None):
print "on_start_button_toggled"


I think that should be "widget" instead of "wedget". I'll change that, but it seemed to run ok as is. I'm gonna play with this tonight and tomorrow and see what I can do with it.

Thanks again for the work.

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

More
17 Aug 2012 04:04 - 17 Aug 2012 04:11 #23326 by wd5jwy
Replied by wd5jwy on topic Re:Run GladeVCP from halrun
John:

OK, I understand things much better now - I don't think there's any way I could have gotten this far without your help. This is how I interpret everything so far:

Command line:

"halrun -I -f start.hal" - this starts the Hal module (as denoted by "halcmd:" prompt in the console window). Then "-f" pulls in the start.hal file and executes those Hal commands.

start.hal file:

"loaduser" loads gladevcp, then executes the python file and loads the glade panel "wd".

Below that, you create the two threads in realtime environment, create the two stepgens (type 0) and then update the stepgens and set the scale.

Then enable the two hal_hboxes in the glade panel so the controls are visible and accessible.

Then you connect the floating-point output pin of the spinbox to the stepgen velocity input pin.

Then you connect the bit output of the Hal start_button to the stepgen enable pin which starts the stepgen.

handler.py file:

This file contains the methods for handling events

So, now I understand how you are passing the value of the spinbutton to the stepgen. I'll look at your calc tutorial to see how to do the ratio calculation. Also, it looks like the Halcmd "unload all" would unload all the currently running real-time modules, but as you said, I don't know where you would place the command so that it is executed when the window closes.

The last thing I'm not clear on - how do I connect the output of the stepgen to the parallel port to run the motors? But, I'll keep reading the docs and see if I can find out. The HAL Manual stops short in the example it has before they discuss how to tie the output of the stepgen to the parallel port.

Anyway, this is great stuff. It's amazing how much this helps me understand things. Great Job!
Last edit: 17 Aug 2012 04:11 by wd5jwy.

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

More
17 Aug 2012 05:20 #23328 by mhaberler
the spinbutton widget is a bit awkward to get right in glade, which is why there is an example in configs/gladevcp/by-widget/spinbutton .

- Michael

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

More
17 Aug 2012 10:14 #23331 by BigJohnT
wd5jwy wrote:

The last thing I'm not clear on - how do I connect the output of the stepgen to the parallel port to run the motors? But, I'll keep reading the docs and see if I can find out. The HAL Manual stops short in the example it has before they discuss how to tie the output of the stepgen to the parallel port.


If you look in the first Glade/Python tutorial at the destroy part and add the hal unload that should take care of that part.

The connections from the stepgen to the parallel port are just more net commands like the following.

net spool-step parport.0.pin-02-out <= stepgen.0.step

When you start your config in the terminal type in show pin and show param to see the pins and parameters.

John

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

More
17 Aug 2012 10:15 - 17 Aug 2012 10:19 #23332 by BigJohnT
mhaberler wrote:

the spinbutton widget is a bit awkward to get right in glade, which is why there is an example in configs/gladevcp/by-widget/spinbutton .

- Michael


I don't see that directory when I use the installed 2.5 config picker from the menu... but I see them in the git repo. There must be some kind of bug in the config picker.

John
Last edit: 17 Aug 2012 10:19 by BigJohnT.

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

More
17 Aug 2012 11:40 #23335 by mhaberler
wd5jwy wrote:

....
Also, I think I found a typo in the python file:
...
I think that should be "widget" instead of "wedget". I'll change that, but it seemed to run ok as is. I'm gonna play with this tonight and tomorrow and see what I can do with it.
...


I think BigJohnT was already focusing on lunch, so it is kindof natural potato wedges get in the way.

-m

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

More
17 Aug 2012 12:21 #23336 by mhaberler
BigJohnT wrote:

mhaberler wrote:

the spinbutton widget is a bit awkward to get right in glade, which is why there is an example in configs/gladevcp/by-widget/spinbutton .

- Michael


I don't see that directory when I use the installed 2.5 config picker from the menu... but I see them in the git repo. There must be some kind of bug in the config picker.

John


I have no good understanding what the config picker does, but at least configs/gladevcp/by-widget/spinbutton is in 2.5

probably the stuff under configs/gladevcp needs to be separated into examples and pickable configs.

Many moons ago I have proposed an example directory, but the timeout on my idea suggested the consensus opinion is "example directories are for whimps" , so that's where it wound up.

-m

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

More
17 Aug 2012 12:49 #23338 by andypugh
mhaberler wrote:

Many moons ago I have proposed an example directory, but the timeout on my idea suggested the consensus opinion is "example directories are for whimps"

Perhaps you should take the approach that any suggestion which is not actively veto-ed is accepted? :-)

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

Moderators: HansU
Time to create page: 0.445 seconds
Powered by Kunena Forum