Pressbrake CNC Control Setup Questions

More
5 years 6 months ago #204445 by andypugh
If you want to edit the glade gui (and, actually, I wouldn't, it would be better to start fresh with something a little less flaky) then you need the Glade editor. LinuxCNC requires a specific version, that we offer via the LinuxCNC servers.
Code:
sudo apt-get install glade-gtk2
should install it for you.

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

More
5 years 6 months ago #204450 by EW_CNC
I am using a tubing bender with a standalone glade gui. Maybe I could use it as a starting point with a custom HAL component. I would like to be able to save the return position, deceleration position, and down limit selector like plasmaC has for its material settings. What are the pros and cons of Glade vs QtVCP?
Attached my tubing bender files.

File Attachment:

File Name: tb2_2021-04-01.hal
File Size:7.61 KB

File Attachment:

File Name: post_gui_2...4-01.hal
File Size:1.53 KB

File Attachment:

File Name: handlers_2...04-01.py
File Size:907 B

File Attachment:

File Name: tb2.txt
File Size:159 B

File Attachment:

File Name: tb2_2021-04-01.py
File Size:792 B

File Attachment:

File Name: gvcp-panel...04-01.ui
File Size:81.06 KB

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

More
5 years 6 months ago #204487 by andypugh
Does that UI work? It looks like it is only partially set up, but perhaps I am missing things. (I can't easily trial-run your config without the Mesa cards, so this is based on looking at the UI And handlers)

I had actually forgotten that HAL_Spinbox (etc) create HAL pins. That would be a very easy way to get basic functionality.

I feel that this sort of thing should be table-driven, with a set of backstop positions and bend positions. To do that there needs to be a way for the handler code to either change the value in the spinbox (which is probably a good way to give a visual check for the operator) or to have separate hal pins created by the handler for its own use.
I feel that saving and loading bend tables as files should be possible too.

But, as an initial experiment, A UI with spinbuttons to provide positions and speeds should work.

For reference, it is pretty easy to add "private" HAL pins to a python handler file. This is documented here
linuxcnc.org/docs/2.8/html/hal/halmodule.html

Attached is a version of your handler.py that does this. I have linked your next/previous buttons in the second tab to them.
Code:
halrun loadusr gladevcp -u handlers.py panel.ui

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

More
5 years 6 months ago #204488 by andypugh

andypugh wrote: For reference, it is pretty easy to add "private" HAL pins to a python handler file. This is documented here
linuxcnc.org/docs/2.8/html/hal/halmodule.html


And a different way here:
linuxcnc.org/docs/2.8/html/gui/gladevcp....evcp:adding-hal-pins

I am not sure under what circumstances one would prefer one over the other.

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

More
5 years 6 months ago - 5 years 6 months ago #204551 by andypugh
Here is a first attempt at a press controller.

Compile / install it with
Code:
sudo halcompile --install press.comp

Once installed
Code:
man press
will show the auto-generated docs.

It takes a number of position commands on HAL pins from a GUI, and outputs a target position and velocity.
These should be the inputs to either a limit3 or simple_tp HAL component (I am not sure which will work best) to control velocity, accel and limits. Then the output of that would go to your PID.

The press component also needs to see the position feedback. Provision might have to be made for homing if your scales are not absolute.

I have assumed a three-position foot pedal with up, down and neither outputs.

Starting at the top, pressing the down switch will request a down feed. Releasing the down will set the velocity to zero.
Actuating the up switch will start a retract. releasing the up switch on a retract will stop the motion.
When the press reaches the start height the speed will be changed.
At the finish height motion will stop. Releasing the pedal _without_ actuating the up switch, then re-actuating the down switch will set a target press.0.tweak-down lower. This can be repeated indefinitely.
Code:
component press "A component to control a press-brake"; pin in float brake-pos-fb "Position feedback of the press"; pin in float top_position = 0 "Position to return to"; pin in float return_speed = 1 "Speed to return to top at"; pin in float bend_start = 0 "Point of contact with work"; pin in float start_speed = 1 "Speed to move down to initial contact"; pin in float bend_finish = 0 "Position to complete bend"; pin in float bend_speed = 1 "Speed to move at during bend"; pin in float tweak-down = 0 "Extra bend increment"; pin in float pos-tolerance = 0.05 "How close to target to be to stop"; pin out float brake-pos-cmd "Brake position command to motion"; pin out float brake-vel-cmd "Speed command to motion"; pin in float backstop-pos = 100 "Required backstop position"; pin in float backstop-fb = 100 "Backstop position feedback"; pin out float backstop-pos-cmd "Position command out to backstop"; pin in bit up "Command to move up from pedal"; pin in bit down "Command to move down from pedal"; pin in bit abort "Abort current operation and stop all motion"; pin in bit interlock = 1 "Input signal from interlocks to allow cycle"; function _; license "GPL"; author "andypugh" ;; #include "rtapi_math.h" FUNCTION(_){ static int state = 0; static double target; switch (state) { case 0: // at the top, awaiting commands if (interlock != 1){ // interlock return; // do nothing. Needs further consideration } if (fabs(backstop_pos_cmd - backstop_fb) > 4 * pos_tolerance){ // new backstop position state = 10; break; } if (down){ target = bend_start; state = 5; return; } break; case 5: // moving down to work brake_pos_cmd = target; brake_vel_cmd = start_speed; if (up){ // aborted motion target = top_position; state = 8; return; } if (! down){ // pause the downfeed brake_vel_cmd = 0; } if (fabs(brake_pos_fb - target) < pos_tolerance){ // in position target = bend_finish; state = 6; } break; case 6: // bending brake_pos_cmd = target; brake_vel_cmd = bend_speed; if (up){ // aborted motion target = top_position; state = 8; return; } if (! down){ // pedal released if (fabs(brake_pos_fb - target) < pos_tolerance){ // in position, consider tweaking state = 7; } else { // not in position, just stop brake_vel_cmd = 0; } } break; case 7: // at bottom of stroke, waiting for a tweak if (up){ // return to top target = top_position; state = 8; return; } if (down) { // give it a tweak target += tweak_down; state = 6; } break; case 8: // return to top brake_pos_cmd = target; brake_vel_cmd = return_speed; // What to do if the down switch is pressed on the retract? if (! up) { // pedal un-released brake_vel_cmd = 0; } if (fabs(brake_pos_fb - target) < pos_tolerance){ // retracted state = 0; } break; case 10: // Backstop positioning backstop_pos_cmd = backstop_pos; if (fabs(backstop_fb - backstop_pos_cmd) < pos_tolerance){ // retracted state = 0; } break; default: rtapi_print_msg(RTAPI_MSG_ERR, "Unsupported state reached in state machine"); } }
Last edit: 5 years 6 months ago by andypugh.
The following user(s) said Thank You: tommylight, EW_CNC

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

More
5 years 6 months ago #204617 by EW_CNC

andypugh wrote:
Does that UI work? It looks like it is only partially set up, but perhaps I am missing things.

Yes, the UI works, and yes it is only partially set up. I had an electrician, friend helped me retrofit the tubing bender and we got it working and never took the time to refine it. He did the glade gui so I will still need to learn the process myself.
Thanks for the press.comp, looks good. I'm hoping to work at the project today and see if I can make any progress.

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

Time to create page: 0.102 seconds
Powered by Kunena Forum