Introduce myself and a queston for Setting OUTPUT 17

More
28 Jun 2017 19:40 - 28 Jun 2017 20:07 #95146 by Grotius
Hi

I am a lonely sheep in mid life crisis at this moment and i am learning programming Linux for about 3 weeks now.
I have a good wife. She make's me happy.

I have build several CNC machines with Mach3. It's a nice program, but if you take a cup of coffee you need to restart the program because it's not responding anymore. That's why i think of Linux. So i want to give it a try.

My goal is to make a custom Linux cnc program by using the glade program.

But first. It's very difficult to start up with the first (simple) online tutorials with the Glade program. For me some programming
text in the Python file looks like abra cadabra... :blink:

After a few horrible evenings trying to program something I figured out that the Glade program and the Pyton file is a good way to make the entire program layout by yourself !!! This sheep was running like hell....

But at this moment the most simple things, look very difficult.

An example....

The Goal : Set output pin 17 high to start a plasma torch with a button.
The next Goal when first goal is finished : Led must be on when output 17 is on.

So i was searching topics and tutorials, but it's hard to find a complete example how to do this....

What must i do?

1. I was looking for a HAL file line text to connect output 17.
2. In glade i can make a button and handle the button pressed activate signal
3. The Pyton code is difficult. I can do it with Macro code like M64. But how is the HAL connected to the Pyton code?

Thank you...

This is how far i am at the moment. All you see is working exept the output 1 aan button for activate output 17.

Attachments:
Last edit: 28 Jun 2017 20:07 by Grotius.

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

More
28 Jun 2017 20:05 - 28 Jun 2017 20:06 #95149 by Todd Zuercher
To do those two simple things, I don't think you "need" to use any python code.

Make your button in the glade VCP using a "HAL Button" (rather than an ordinary button). The HAL Button widget will create a hal pin that will go true when ever the button is pressed (important note it will not stay true.)
Similarly use a Hal LED for the indicator (and configure it to create a hal pin).

Then in hal connect the glade button hal pin to a toggle component input.
linuxcnc.org/docs/html/man/man9/toggle.9.html
and the toggle output to your parallel port pin and the glade LED hal pin.
Last edit: 28 Jun 2017 20:06 by Todd Zuercher.

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

More
28 Jun 2017 21:42 - 28 Jun 2017 21:47 #95152 by Grotius
Okey i added the button and the led in the glade program.
This was easy to do.


In the Python code i added the button handler "on pressed" and programmed the "print" statement in the Python code to see what is happening
in the terminal window during start up Linuxcnc. So that is nice to see. You can trigger your own written errors hihi.

In the Hal file i add a text :

net hal_button1.motion.digital-out-01 => partport.0.pin-17-out

So "hal_button1" is the exact name of the glade hal button. Next i see "01" this can be digital output 1 ??? What is this
value exactly? First i thought it must be the value of output pin 17.

Your reply to me was clear in the Glade piece.
The link is abra cadabra language for newbie sheeps. So maybe better a line of text to test some things.

In my program methode in Python is nicer to have a text like this :
c.set_digital_output(1, 1) ## comments for newbies : ( (1,1)= output 1 on) ( (1,0)= output 1 off)

So it would be nice to have a clear example of the hal text line. Maybe then i understand how to do it and test it.
Last edit: 28 Jun 2017 21:47 by Grotius.

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

More
29 Jun 2017 12:00 #95165 by Todd Zuercher
That "01" is just part of the pin name. (Why it is there just has something to do with how you configured the hal pin in python.) I don't claim to understand the first thing about python, I've only been able to bumble out a couple of rudimentary .py files that were just barely good enough to make my own gladevcps work.

In Hal though whether a Boolean pin is true or false,will have a value of 1 or 0, but the value will not be seen in the hal file. (Unless you use a setp line to explicitly set the pins value.)

To check at the value of a hal pin you can use Halmeter.
linuxcnc.org/docs/html/hal/tools.html#_halmeter

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

More
29 Jun 2017 17:03 - 29 Jun 2017 17:12 #95183 by Grotius
Dear Todd,

The hallmeter command is not starting up because i already start up Linux cnc with a therminal window.
So it will not be able to do 2 terminal windows in same time. No problem. It's okey like this.

When i type "show pin" in terminal window, nothing is happening....
But okey i can connect a cnc interface to hear output 17 relais clicking.

For me it's important to use standart output code's not like spindle-on or flood-on commands in the hal file.
I prefer something like "output-1 on" So then you have a standard code that you can use for different types of machinery.
The only thing is to change the text of the buttong name in "Plasma start" or something. That is structural much better to do.
*** comment for forum readers : You only change the visual screen text, not the button programming name, this is unchanged like "output-1 on" or something like that. Otherwise the new standard do not work properly.. HIHI

It looks like Linux has to do some work in set up some thing's easyer for sheeps like me HIHI.

Maybe i write a beginner tutorial when i know how to do some things.
Last edit: 29 Jun 2017 17:12 by Grotius.

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

More
29 Jun 2017 22:03 #95192 by Todd Zuercher
You can open Halmeter from another terminal window. In a terminal window issue the command halcmd -kf
that should open a halrun prompt. Then type halmeter.

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

More
30 Jun 2017 22:18 - 30 Jun 2017 22:21 #95255 by Grotius
Dear Tod,

Thank you for this. typing "halcmd -kf" is working in second terminal window.
Then typing "halmeter" did not work on my pc. But typing "show pin" is working on my pc.

So now the output pin's are working correctly. Just what I want.
I added a example of one output pin setting.

The glade part :
Button name : hal_button1
Signals/Gtkbutton/Pressed : on_hal_button1_pressed

The Hal part :
net hal_button1 <= motion.digital-out-01 => parport.0.pin-17-out

The Python part :
#DIGITAL OUTPUT 1 Activated , (1, 1) = activated of (1, 0) = deactivated
def on_hal_button1_pressed(self, widget, data=None):
print 'Digital ouput 1 activated'
c.mode(linuxcnc.MODE_MDI)
c.set_digital_output(1, 1)
#c.mdi("M3 S1000")


So you can also use several MDI commands. That is great !!

The second problem stay's the led. I don't get it how to do some simple action in glade.

When Digital output 1 is on, the led must go on. But i find nothing i understand on the internet.
I prefer a solution in the Python code. So then i don't have to connect the led in the hal file.
Ik think it's already connected to output 17 with a button.
Last edit: 30 Jun 2017 22:21 by Grotius.

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

More
30 Jun 2017 23:10 #95256 by rodw
For a good example of using Glade and python together, try installing the Gmoccappy plasma sim that is bundled with a standard LinuxCNC installation. Then study plasma.py, plasma.glade, signals.py and signals.glade that will be copied to your config folder.

However as Todd has said, for simple buttons, and LED indicators, you don't need to use Python. You have to also use a HAL file to do anything useful because that is the LinuxCNC way.

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

More
01 Jul 2017 02:18 #95260 by Todd Zuercher
Sorry, I don't normally run Halmeter from the command line. (It is a menu item in most Linuxcnc guis.)
All you need to do is open a terminal window and type halmeter from the ordinary terminal prompt. (You don't need to use the halrun prompt.)

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

More
03 Jul 2017 23:32 - 03 Jul 2017 23:50 #95338 by Grotius
Dear Rodw and Todd,

Thank you bot'h for your help.

Short preview about past week :
I was studying the internet like a bird. And found out that Linux CNC is difficult to program. So i was slowly turning over into a sheep. To go in the core you have to do some C. And some people don't like to learn Python language I read in disqussions.
-For me i study things i want to know, but sometimes is too difficult i think. You have one life. And the information for programming looks endless to me. I have studied about 20 hours last week on Linuxcnc.
-But i have hope.

Next week to do :
I did look to the Gmoccapy plasma and also the Gmoccapy 4 axis. I see they are using the same main screen.
So the two plasma "add on screen's" from Gmoccapy plasma is loaded into the main 4 axis screen. This looks interesting.
Also they did something to eliminate one axis. Just the one i need for tube a tube cutter and also for tangential plasma cutting.

I copied the 4 axis screen to my desktop and do it change a little bit in text, to see if something happens. And Yes.
I did that copy because i don't know how i can be administrator level in that directory.

So I copied the standard 4 axis glade screen from directory : gmoccapy.glade /usr/share/gmoccapy to my desktop.
( Linux has a bad standard file explorer to handle with, i think, i'm searching without a good side panel :P )
Then i did on the desktop in a terminal : sudo cp gmoccapy.glade /usr/share/gmoccapy
( for forum readers : This copy i do several times an hour to control if my stand alone program is working. I learned this from the glade tutorial. I also copy the Pyton file also, see the Glade tutorial. Johnny Thornton is the master hihi )

So this week i can hopely find out more from how to get started with Linux cnc.

Attachments:
Last edit: 03 Jul 2017 23:50 by Grotius.

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

Time to create page: 0.201 seconds
Powered by Kunena Forum