Settings from G code file
- islander261
- Offline
- Platinum Member
Less
More
- Posts: 757
- Thank you received: 216
24 Apr 2017 20:17 #92007
by islander261
Replied by islander261 on topic Settings from G code file
Rod
I just came in from the shop for a lunch break and found your post.
How you touch off in when using Sheetcam all depends on if you ever think you might need to hand edit code or if you are concerned about file size. I personally like to have the touch off as a subroutine or embedded control so I don't get an extra 5 to 10 lines of gcode for every pierce, just the call to the subroutine. My pierces are a bit complex because the ohmic sensing requires a test before starting and a float switch or actuator stall in case failure to make contact, dross pile etc. Also I actually probe twice, once going down to get the rough location and then while slowly raising so so I don't over shoot the state change. I only cut full sheets at a time so my nested files usually run 400KB to over 1MB. This usually isn't a big deal for people doing engineering or fab shop work. A typical piece of mine will have any where from 10 to 100 pierces with 10 to 48 pieces on a sheet.
We don't live in a high bandwidth connection part of the world, actually cellphones don't even work in the house here. We have medium good ADSL (about 3mbs down) as we are near maximum range from the switch.
I was wed to the MS Windoze world before the the last oil price crash and my forced retirement. All work and tools was Windoze based, even all the corporate and engineering back end used MS cloud services and products. This was odd because our products used embedded Red Hat Linux with some real time extension as the os. The software and EE work was in another building so I had little contact with that side.
Well lunch is on and back to work.
John
I just came in from the shop for a lunch break and found your post.
How you touch off in when using Sheetcam all depends on if you ever think you might need to hand edit code or if you are concerned about file size. I personally like to have the touch off as a subroutine or embedded control so I don't get an extra 5 to 10 lines of gcode for every pierce, just the call to the subroutine. My pierces are a bit complex because the ohmic sensing requires a test before starting and a float switch or actuator stall in case failure to make contact, dross pile etc. Also I actually probe twice, once going down to get the rough location and then while slowly raising so so I don't over shoot the state change. I only cut full sheets at a time so my nested files usually run 400KB to over 1MB. This usually isn't a big deal for people doing engineering or fab shop work. A typical piece of mine will have any where from 10 to 100 pierces with 10 to 48 pieces on a sheet.
We don't live in a high bandwidth connection part of the world, actually cellphones don't even work in the house here. We have medium good ADSL (about 3mbs down) as we are near maximum range from the switch.
I was wed to the MS Windoze world before the the last oil price crash and my forced retirement. All work and tools was Windoze based, even all the corporate and engineering back end used MS cloud services and products. This was odd because our products used embedded Red Hat Linux with some real time extension as the os. The software and EE work was in another building so I had little contact with that side.
Well lunch is on and back to work.
John
The following user(s) said Thank You: rodw
Please Log in or Create an account to join the conversation.
24 Apr 2017 22:01 #92009
by rodw
Replied by rodw on topic Settings from G code file
John,
This is very nice. I moved your code back into the default Gmoccapy plasma.py file which required one minor change to your hal code
And then I spent some time learning how to set values in Python. Finally I worked it out.The screen label is a string and volts sent in the gcode that ends up in the variable command is a float so it needs to be converted to a formatted string. In C I would have used sprintf() but python allows you to use the sprinif() formatting features directly Like this:
So tying this altogether, I added 2 lines of code to the end of the get arc voltage section in your example.
The first line sets the value to the pin and the second updates the screen variable
So now I can set the target plasma voltage either from the GUI or from gcode using something like:which sets the voltage to 61 volts (a random number I picked which has no significance to plasma cutting).
Its easy to test this using the MDI window.
Very cool. Thanks for showing the way.
This is very nice. I moved your code back into the default Gmoccapy plasma.py file which required one minor change to your hal code
# hook up command from Gcode
net gcode-command <= motion.analog-out-00
net gcode-command => plasma.Command-From-File
And then I spent some time learning how to set values in Python. Finally I worked it out.The screen label is a string and volts sent in the gcode that ends up in the variable command is a float so it needs to be converted to a formatted string. In C I would have used sprintf() but python allows you to use the sprinif() formatting features directly Like this:
self.lbl_prog_volt.set_label("%d" % command)
So tying this altogether, I added 2 lines of code to the end of the get arc voltage section in your example.
The first line sets the value to the pin and the second updates the screen variable
#get arc voltage
elif 360 <= command < 400 or 3060 <= command < 3201:
if command >= 3060:
command = command - 3000
else:
command = command - 300
self.halcomp["Target-Voltage"] = command
self.lbl_prog_volt.set_label("%d" % command)
So now I can set the target plasma voltage either from the GUI or from gcode using something like:
m68 E0 Q361
Its easy to test this using the MDI window.
Very cool. Thanks for showing the way.
Please Log in or Create an account to join the conversation.
- islander261
- Offline
- Platinum Member
Less
More
- Posts: 757
- Thank you received: 216
24 Apr 2017 23:23 #92016
by islander261
Replied by islander261 on topic Settings from G code file
Rod
You can also set the formatting in the Glade widget in your Glade file.
John
You can also set the formatting in the Glade widget in your Glade file.
John
Please Log in or Create an account to join the conversation.
24 Apr 2017 23:55 #92017
by rodw
Thanks, the one I'm having trouble with now is moving this into the default gmoccapy plasma.hal file
This is the button to enable THC globally
The corresponding pin is hal-btn-THC but it is defined in a different way and there is no button defined in the glade file. Any ideas on the correct syntax?
Replied by rodw on topic Settings from G code file
Rod
You can also set the formatting in the Glade widget in your Glade file.
John
Thanks, the one I'm having trouble with now is moving this into the default gmoccapy plasma.hal file
self.enable_THC_tab.set_active(True)
This is the button to enable THC globally
The corresponding pin is hal-btn-THC but it is defined in a different way and there is no button defined in the glade file. Any ideas on the correct syntax?
Please Log in or Create an account to join the conversation.
25 Apr 2017 00:42 #92023
by rodw
Replied by rodw on topic Settings from G code file
I've found the button now. Glade has to be opened from the command line so it must be a rip-environment thing. BUt I am still stuck
The pin I want is defined like this as all the ini variables are read:
So I am unable to set its value. None of these work
And I can't find any relevant docs.
The pin I want is defined like this as all the ini variables are read:
IniFile.widgets: widget_defaults(select_widgets([self.builder.get_object("hal-btn-THC"),], hal_only = False, output_only = False)),
So I am unable to set its value. None of these work
elif 999 == command:
#self.hal-btn-THC.set_active(False)
self.hal_btn_THC.set_active(False)
#self.halcomp["hal-btn-THC"].set_active(False)
And I can't find any relevant docs.
Please Log in or Create an account to join the conversation.
- islander261
- Offline
- Platinum Member
Less
More
- Posts: 757
- Thank you received: 216
25 Apr 2017 00:44 #92024
by islander261
Replied by islander261 on topic Settings from G code file
Rod
Ok, you are running into changes I made so I can have the same control in two different tabs. I think you just need to use the name of your HAL btn. This was one of things I change so I could have the same control from two different tabs. I went and looked in the Gmoccapy plasma sim glade file for the plasma tab and this is what I think you need:
First you need to connect the button in your Glade file to your Python file, some thing like this:
self.enable_THC_btn = self.builder.get_object("hal-btn-THC")
Then in the decoding logic part of your Python file:
self.enable_THC_btn.set_active(True)
I am pretty sure that the set_active method will work on a hal button. I know it took me a lot of fussing around to get the two tabs linked through the HAL and hooked to the outside world. I hope this works for you. Post your plasma python and glade files and I can look at them if this doesn't work. I really wish I could have found a clean way to have the same control in two tabs.
John
Ok, you are running into changes I made so I can have the same control in two different tabs. I think you just need to use the name of your HAL btn. This was one of things I change so I could have the same control from two different tabs. I went and looked in the Gmoccapy plasma sim glade file for the plasma tab and this is what I think you need:
First you need to connect the button in your Glade file to your Python file, some thing like this:
self.enable_THC_btn = self.builder.get_object("hal-btn-THC")
Then in the decoding logic part of your Python file:
self.enable_THC_btn.set_active(True)
I am pretty sure that the set_active method will work on a hal button. I know it took me a lot of fussing around to get the two tabs linked through the HAL and hooked to the outside world. I hope this works for you. Post your plasma python and glade files and I can look at them if this doesn't work. I really wish I could have found a clean way to have the same control in two tabs.
John
Please Log in or Create an account to join the conversation.
- islander261
- Offline
- Platinum Member
Less
More
- Posts: 757
- Thank you received: 216
25 Apr 2017 00:49 #92025
by islander261
Replied by islander261 on topic Settings from G code file
Rod
Now you why it took me weeks to get the whole two tab thing worked out! Also be careful to only use the correct GTK2 docs and Python 2.6 docs, the newer stuff will not work.
John
Now you why it took me weeks to get the whole two tab thing worked out! Also be careful to only use the correct GTK2 docs and Python 2.6 docs, the newer stuff will not work.
John
Please Log in or Create an account to join the conversation.
25 Apr 2017 03:49 #92027
by rodw
Replied by rodw on topic Settings from G code file
John, thanks, The problem is that self.builder.get_object has already been called when the .ini file was opened and its therefore not set up the same way and as it already exists, your suggestion generates a run time error. I'l ask in the gmoccapy section.
Anyway, I moved on a and wrote a stand alone gcode hold function. You might like to review your logic in your kerf crossing comp. From what I can see, you have it around the wrong way.
in Sheetcam the dynthcOnCode = "M67 E0 Q20"
That should disable THC hold, you are enabling it. Confusing. To disable THC height holding you need to enable eoffsetpid.0.hold-request.
Anyway, I moved on a and wrote a stand alone gcode hold function. You might like to review your logic in your kerf crossing comp. From what I can see, you have it around the wrong way.
in Sheetcam the dynthcOnCode = "M67 E0 Q20"
That should disable THC hold, you are enabling it. Confusing. To disable THC height holding you need to enable eoffsetpid.0.hold-request.
Please Log in or Create an account to join the conversation.
25 Apr 2017 07:21 #92036
by rodw
Replied by rodw on topic Settings from G code file
Well, it took a while but I finally solved it.
There is no need for a handler as we only want to change this, not act on it.
Remember to use underscores....
self.hal_btn_THC = self.builder.get_object("hal-btn-THC")
There is no need for a handler as we only want to change this, not act on it.
#global THC on
elif 900 == command:
self.hal_btn_THC.set_active(True)
print "900 Turn Off THC: ", command
# global THC off
elif 999 == command:
self.hal_btn_THC.set_active(False)
print "999 Turn On THC: ", command
Remember to use underscores....
Please Log in or Create an account to join the conversation.
Moderators: snowgoer540
Time to create page: 0.085 seconds