MechMate CNC Router Forum

Go Back   MechMate CNC Router Forum > Miscellaneous hardware and software > Human Interface Devices (HID's)
Register Options Profile Last 1 | 3 | 7 Days Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old Fri 08 September 2006, 06:24
Mike John
Just call me:
 
Gerald

Can you tell me about the 4 button control boxes?

...........Mike
Reply With Quote
  #2  
Old Fri 08 September 2006, 10:46
Gerald_D
Just call me:
 
One button box has 4-buttons, but the boxes at the ends of the gantry have 3-buttons:



1. E-Stop (Red)
2. Resume (green)
3. Pause (yellow)
4. Reserved for z-zero, but not figured out yet...
Reply With Quote
  #3  
Old Fri 08 September 2006, 23:22
Mike John
Just call me:
 
Gerald

Now all I need to know is, how do I do it?

I guess the button box has some sort of electronics (or does each button have its own which I guess is connected to the computer (or is it the control box, or both) and I see a need for some programming.
I can see the solution, I don't know how to get there.


..........Mike
Reply With Quote
  #4  
Old Sat 09 September 2006, 01:50
Gerald_D
Just call me:
 
Mike, you have a good understanding of the connection of the z-zero plate - one wire is ground/earth, the other wire goes to an "input" point on the controller board. Touch the wires together and you have an input. The pushbuttons do exactly that. (There is no circuit inside those boxes)

It depends on how many spare inputs you have - 2 of them are probably occupied by the E-stop and the z-zero plate. You might only be able to fit 2 buttons to the 2 spare inputs?

Guys like Dick will help you program them for your ShopBot.

Be careful though....more switches mean more wires acting as antennae....your SB may end up cutting an ellipse every time your cellphone rings.
Reply With Quote
  #5  
Old Sat 09 September 2006, 02:33
Mike John
Just call me:
 
Gerald,
That makes it simple. In the missing Shopbot Forum thread you spoke of a breadboard, which I thought meant some kind of electronics, which confused me.
Dick.
I have 3 pallets with 15 'blanks fitted' that all cut, one after the other, from 1 file.
It is possible to start replacing blanks when the File has 3 blanks left to cut. You replace the first ten (left and centre pallets), the Shopbot stops at the end of the file, if the first pallet is replaced, then it is safe to start again. Normally both the first and second pallet are replaced when the Shopbot stops.
Now I can safely replace the third pallet.
What I want to do is this.
Do all the zeroing at the start of the day, set the program going, get it to pause at the end of the file.
At the press of a button (A) I want the file to restart again at the beginning (JH).
If Vaniescu needs to relieve himself I want him to be able to press a button (B) that pauses the Shopbot, and, on his return press button (A) and everything carries on from where it paused.
In the case of a minor problem, Vaniescu presses 'Pause' (button 'B') and calls for Mike.
In case of a big problems he whacks the existing E-stop and screams for Mike.

At the start of the next day we repeat the cycle.

I understand most of your little program.
I think ON INP(2,1) means when input 2 is closed then carry out the GOTO.
What I dont understand is the ON INP(2,1) instruction after the GOTO. Here I expect to find the first line (or next line) of the Z zero routing.
mind you BASIC is a bit rusty!!

So, three buttons in input 2 - 3 - 4 as E-stop - pause - restart.
I can see how, at the end of the, file I can loop until the restart button is pressed, and how the GOTO will be an instruction to re-start the file.
I dont know how to program the 'Pause' button, which can happen anytime within a file, and then how to tell the restart to now go to the next line.

Thanks for your help.

............Mike
Reply With Quote
  #6  
Old Sat 09 September 2006, 07:00
Dick van Randen
Just call me:
 
OK, some can be done as you want some you have to compromise.

Mostly it has to do with ON INP (on input) command.
ON INP is known as a hardware interrupt. That is a port or switch is constantly monitored and when it is activated a vector, which is known in Basic as a GOTO or GOSUB is executed.

ON INP(2,1) GOTO StartZero '<----Vector goto the StartZero: label

If there is no vector the interrupt is ignored.
ON INP(2,1) <----- No Vector , No where to go and nothing happens ie it is off

The problem with hardware interrupts is that they are great for repeating things , but a problem when you want to pause. They don't remember where they came from ( line number ) so there is no easy way of going back to the place PAUSE was pressed. I don't know of a way where you can pause, move to a safe spot and then resume from where the pause started.

The only port that pauses and allows you to resume is port 3 , the limit switch port. But it doesn't allow you to move anywhere safe.

Back to the Pause File interrupt on a different switch.

The best you can do is have the blanks cut in a loop , the blank iteration determines the starting point for that blank. In the program there is a PAUSE subroutine it grabs the number of COMPLETED blanks and moves to the safe zone. When PAUSE is pressed again it moves back to the START of the next piece ( even if it was 95% complete) and starts cutting again. No other way that I know of.

You have 3 pallets with 5 pieces each. A, B and C
You will need min two switchs port 2 (and port 4 ( 3 is used for limit switchs) port 2 For RESTARTING the Job from Pallet A and port 4 PAUSE/RESUME from anywhere in the three.

So far so good??
Reply With Quote
  #7  
Old Sat 09 September 2006, 07:59
Mike John
Just call me:
 
Dick
The file I use looks a bit like this. (Although the numbers are incorrect here)

J3,39.794,39,5
FP,D:\blankA1,,,,,2
J2,39.794,107
FP,D:\blankA2,,,,,2
J2,39.794,175
FP,D:\blankA3,,,,,2
J2,39.794,243
FP,D:\blankA4,,,,,2
J2,39.794,311
FP,D:\blankA5,,,,,2
J3,157.397,39,5
FP,D:\blankB1,,,,,2
and so on, and so on

If, after each blank, I insert
J3,39.794,39,5
FP,D:\blankA1,,,,,2
LOOP:
ON INP(2,1) GOTO interupt
(I deliberately didn't use Pause)
GOTO LOOP
J2,39.794,107
FP,D:\blankA2,,,,,2
LOOP:
ON INP(2,1) GOTO StartZero
GOTO LOOP

interupt
Pause


Then a non-urgent pause will occur at the end of the blank that is being cut as the pause button is pressed.

Now I can restart by pushing the restart button.

Is this correct?

............Mike
Reply With Quote
  #8  
Old Sat 09 September 2006, 12:20
Mike Richards
Just call me:
 
Mike,
It seems to me that the program will continue with the first statement after the Pause command in the interrupt routine, NOT the next inline statement.

You might try something like this:

LOOP1:
&flag = 0
ON INP(2,1) GOSUB INTERRUPT
IF &flag = 0 THEN GOTO LOOP1

J2,39.794,107
FP,D:\blankA2,,,,,2

LOOP2:
&flag = 0
ON INP(2,1) GOSUB INTERRUPT
IF &flag = 0 THEN GOTO LOOP2

END

'-----------------------
' Interrupt routine
INTERRUPT:
Pause
&flag = 1
RETURN
Reply With Quote
  #9  
Old Sat 09 September 2006, 17:41
Dick van Randen
Just call me:
 
Mike J

What Mike R has given is pretty close to what you want. I would put the Loop at the front of the cut routine (Mike R's example) , instead of having it at the back, like you wanted. This is important so that a piece is completly cut when it returns from an INTERRUPT.

You haven't indicated where StartZero will be. If it is to start the whole sequence over again the label needs to be at the front of the program and the StartZero interrupt needs to be turned off once it has been used. You don't want to start all over when your in the middle of the last blank on pallet C. Don't forget that this is a hardware interrupt! Stop whatever you are doing and go and do this...now!

Good call on not using PAUSE it is a reserved word in basic and would have created problems.

In the INTERRUPT routine you could include the ability to move up and out of the way as well. Keeping in mind where your table's 0,0 is. Are you changing the 0,0 position each time to cut a new blank?

I would strongly suggest you use two switches , it could get confusing as to what might happen next if you push the same button to do different things. Also suggest a third switch as a lockout that needs to be pressed when one of the other two is chosen. This would ensure that the operator has both hands away from the work when the program resumes and also avoids accidental button presses.

I have seen systems where the lockout button is mounted on the other end of the board shoulder width apart and has safety cap that needs to be flipped open to press.


Reply With Quote
  #10  
Old Sat 09 September 2006, 22:31
Mike John
Just call me:
 
Mike and Dick
Thanks a lot, it is now coming clear!
I see how you can put port 2 (or 4) into the 'ON' (1?) position by closing (and keeping closed) the port button with the lockout button. I assume from Dicks' safety idea that, in fact, these would be push buttons that go off when released.
I assume, therefore, that it must be possible to, somehow, change a variable (from 0 to 1 say), and use this to trigger the innterupt at the end of that blank.
Then, after the restart, the variable would be changed back to 0.
So the program has to continually check for this input, then change the variable.
How do I do that?

As all this is going on within the Shopbot program, can I assume it wont introduce any problems, as widows programs working in the background might?
I use DOS at the moment. Could I continue using DOS with these routines?
I have a computer lying idle that could be used for a Windows system, I am just reluctant to change, on the principal :If it 'aint broken,don't change it!'
edited to add

would this work?
&check=0
LOOP1:
&flag = 0
ON INP(2,1) LET &check=1
IF &check=1 GOSUB INTERRUPT

IF &flag = 0 THEN GOTO LOOP1

J2,39.794,107
FP,D:\blankA2,,,,,2

&check=0
LOOP1:
&flag = 0
ON INP(2,1) LET &check=1
IF &check=1 GOSUB INTERRUPT

IF &flag = 0 THEN GOTO LOOP1

END

'-----------------------
' Interrupt routine
INTERRUPT:
Pause
&flag = 1
RETURN

...............Mike
Reply With Quote
  #11  
Old Sat 09 September 2006, 22:56
Mike John
Just call me:
 
OK
I can see why that won't work!
I need to set the &check variable at any time during the cutting.
I could do this by introducing that line in between every line in the main cutting program, but this seems somewhat impractical!
and I see I should clear that variable in the interupt routine!
BASIC slowly returning to the surface! Us Grandads still have it!!

.........Mike
Reply With Quote
  #12  
Old Sat 09 September 2006, 23:21
Mike John
Just call me:
 
As you can see, I am playing with this, re-thinking as I go along.
The above suggestions, it seems to me, will simply carry on looping between blanks, not going onto the next blank, until the interupt routine is carried out.
What is needed is something that checks, before each blank, to see if the button has been pressed.
If it has not, it simply continues to the next blank.
If the button has been pressed, it carries out the interupt routine until the resume button is pressed.

So, if pressing the button anywhere during the program can change &check from 0 to 1 anywhere during the file, then
IF &check=1 GOSUB INTERRUPT
is the only line needed between blanks.
Is this correct?
How do I get the computer to change the state of &check at any time during the running of the file?

.......Mike
Reply With Quote
  #13  
Old Sun 10 September 2006, 00:00
Mike Richards
Just call me:
 
Mike,
Sometimes it helps to NOT think in computer terms. Think in terms of everyday objects, like road construction people who raise and lower flags, depending on whether or not they want traffic to stop. Like a flagman, a button can either raise (set) or lower (clear) a flag. Or one button can raise one flag and lower another.

So in your example, you would first lower (clear) the flag variables. Until a button is pushed, the flag variables would stay cleared. As you approach each blank, you would check to see if the flag was raised (1) or lowered (0). If the flag was lowered (0), you would cut the blank. If the flag was raised, you would GOSUB a subroutine that just looped until you pressed another button. When you pressed that button, the flag would be cleared and you would return from the subroutine to the place in the program where the subroutine was called and continue cutting.

The command:

ON INPUT( port, state) GOSUB some_subroutine

is just the same as a foreman telling a flagman that when the flagman sees a construction vehicle within a certain distance, the flagman is to raise his flag to stop traffic until the construction vehicle travels to another point on the road. By issuing an ON INPUT(port,state) command, you're just telling the computer that when you push a button, you want the computer to recognize that you've pushed the button and then do something out of the ordinary until you push another button.
Reply With Quote
  #14  
Old Sun 10 September 2006, 05:03
Dick van Randen
Just call me:
 
I see how you can put port 2 (or 4) into the 'ON' (1?) position by closing (and keeping closed)
the port button with the lockout button. I assume from Dicks' safety idea that, in fact, these would be push buttons that go off when released.
I assume, therefore, that it must be possible to, somehow, change a variable (from 0 to 1 say), and use this to trigger the interrupt at the end of that blank.
Then, after the restart, the variable would be changed back to 0.
So the program has to continually check for this input, then change the variable.
How do I do that?


Not entirely true.

Think of ON INP as equivalent of the word "FIRE!"
It doesn't matter what you are doing or what time it is when you hear that word you do two things, STOP what you are doing and do something else NOW!
There is nothing to check at the end of a blank being cut. If you hit Pause and invoke the INTERRUPT the bit will stop dead in its tracks and wait for the program to tell it what to do next.

The push buttons are momentary , you just press them once and let go , you don't have to hang on to them. In fact if you invoke the statement ON INP (2,1) then the buttons are ignored. If you didn't do that and you hung onto the buttons the
program would continually revisit the ON INP line.

here is an example

ON INP (4,1) GOSUB INTERRUPT ' set port 4 switch to goto INTERRUPT label

3,39.794,39,5
FP,D:\blankA1,,,,,2

END

'Subroutines

INTERRUPT:
LOOP:

ON INP(2,1) GOTO RESUME

GOTO LOOP ' wait for the START/RESUME switch to be pressed Once it is pressed jump to the 'resume label and return from where the INTERRUPT was generated.

RESUME:
RETURN

If you hold the switchs down you will stay on the first line GOSUB INTERRUPT , if you let go the program will run , but if you press the buttons again it will haul the program back to GOSUB INTERRUPT. That is why it is important to turn off the ON INP. Keep in mind this is not a fast rule , there may be special cases where you want to keep it on.

To correct the problem you would put ON INP (4,1) right after the LOOP: label in the sub routine section.

Where would you put the statement ON INP (2,1) to turn off the resume interrupt after it had been used?
Reply With Quote
  #15  
Old Sun 10 September 2006, 06:40
Dick van Randen
Just call me:
 
Whoops! There are a couple of mistakes in the file.

The program will run (I think, I hope ) but two problems arise, one with the Pause key and the other with the Resume key.

Can you spot them?
Reply With Quote
  #16  
Old Sun 10 September 2006, 21:51
Mike John
Just call me:
 
Dick

I am having a problem fully understanding the concept. My fault, not your explanation.

With the following

ON INP(4,1) GOSUB PAUSE_FILE
J2,39.794,175
FP,D:\blankA3,,,,,2

does the PAUSE(4) button have to be pressed at the moment that line is reached.
What happens if the button is pressed during the running of the 'blankA3' file?
If I press the button twice, does it go from 0 to 1 and back to 0?
If the program recognises the PAUSE(4) button to having been pressed at any time during the running of 'blankA3', does it then activate the PAUSE at the end of that file, when it reaches the ON INP statement?
When it returns, does it go back to that ON INP statement, check for the button on/off, if off(0) does it then start cutting the next file?

Or does it stop at the moment the button is pressed, halfway through cutting the 'blankA3' file, and return to the ON INP at the start of 'blankA3'.re-cutting the start of the file again?
Either of those ways would work for me.
What wouldnt work, if it stops mid-file, is if the RETURN goes to the line in the 'blankA3' when the button was pushed.
If the next move had a negative Z, then the cutter would ramp into the material from the safe position.

I do appreciate your taking up time to give me these lessons. I taught my son, from age 8 to 12, how to program. Since then he has taught me!!
He is now 31, and a programming wiz kid in Sydney. Maybe you have met him? Tall with a lot of dark hair, looks a bit like me, no moustache.
Unfortunately, being in Sydney, he is not on hand to assist!

...............Mike
Reply With Quote
  #17  
Old Mon 11 September 2006, 01:23
Dick van Randen
Just call me:
 
Vantastic Programming 101


ON INP(4,1) GOSUB PAUSE_FILE
J2,39.794,175
FP,D:\blankA3,,,,,2

does the PAUSE(4) button have to be pressed at the moment that line is reached.


No. What the ON INP statement does is set up the action that will happen when the button is pressed . It comes into effect once the line has been processed and stays in effect EVERYWHERE in the program till you change it or turn it off. By the way each time ON_INP (4,1) GOSUB PAUSE_FILE is invoked a small change takes place . The action remains the same but where the program returns to gets changed.

What happens if the button is pressed during the running of the 'blankA3' file?

It will immediatly stop processing (cutting) the blank file, even if 99% complete and go to the last invoked ACTION for that button.

If I press the button twice, does it go from 0 to 1 and back to 0?

Actually I believe it is 1 to 0 and then 1 to 0 again you are pulling the port low. In any case two button pushes will interrupt the program twice . There is no harm done here , but it is good practice to turn off the button once it has gone into a loop and another ACTION needs to happen. However, in this case we should leave it on. More on this down the list.

If the program recognises the PAUSE(4) button to having been pressed at any time during the running of 'blankA3', does it then activate the PAUSE at the end of that file, when it reaches the ON INP statement?

No. It stops mid file and goes into the PAUSE_FILE loop. The ON_INP has to be turned on at the beginning of a program block if you want that switch monitored in the program block being executed. The BASIC interpreter reads and runs the program one line at a time in sequence.

When it returns, does it go back to that ON INP statement, check for the button on/off, if off(0) does it then start cutting the next file?

Good point. I don't believe it does . I turned it off in PAUSE_FILE. Here is a good example of leaving it on so that it is still active when it returns to cut the file over. The way it is written now it will ignore a key press on return from the Paused blank. Then it turns on again. (Geez Mike , your making me sweat, we have M R and G D looking over our shoulders)

Or does it stop at the moment the button is pressed, halfway through cutting the 'blankA3' file, and return to the ON INP at the start of 'blankA3'.re-cutting the start of the file again?

Yes, but as your prev question pointed out there is a glitch. The PAUSE button will not function during the recut.

Either of those ways would work for me.
What wouldnt work, if it stops mid-file, is if the RETURN goes to the line in the 'blankA3' when the button was pushed.
If the next move had a negative Z, then the cutter would ramp into the material from the safe position.


That won't happen. But even if it did there is away around that as well. It is all a matter of how much you like to type, circumvent the system and get into using SYS VAR ie %(1) and %(2) the X and Y locations at the time of the interrupt.

So Mike J what do you have so far as a program? As it sits mine doesn't work all that well.
Reply With Quote
  #18  
Old Mon 11 September 2006, 05:11
Dick van Randen
Just call me:
 
Hey Mike,

Don't rush, take your time and write something and come back with it. If it with stands scrutiny you get to try it out and see if you pass. The proof is as they say "in the vanilla pudding"


D
Reply With Quote
  #19  
Old Tue 12 September 2006, 21:23
Scott Worden
Just call me:
 
I don't know if this helps or not, but you can also test the state of an input (such as 1,1 or 1,0) and stay in a loop like this.

WAITHERE:
&TEST=%(51)
IF &TEST=1 THEN GOTO REPEAT
PAUSE .2
GOTO WAITHERE

I use this with a momentary button to wait for me to change a blank and then continue. %51 is the state of input 1. I'm not sure what the other inputs are.
Reply With Quote
  #20  
Old Wed 13 September 2006, 03:49
Dick van Randen
Just call me:
 
Hey Scott,

That's excellent ! The rest of the inputs are 2 - 8 respectively %52 to %58 .

What I really like about your idea is that multiple ports can be detected while still using the interrupt! Suddenly 7 inputs is no longer the limit.
Reply With Quote
  #21  
Old Fri 11 January 2008, 04:40
sailfl
Just call me: Nils #12
 
Winter Park, FL
United States of America
Gerald,

As I get closer to starting a build, I have been putting together a buy list. This has forced me to look closer at some of the items and I have questions about the location of the E-Stop and other buttons on the Gantry.

1) Location - It makes sense to me to have the two three button boxes located at each end of the gantry but it makes no sense to me to have the four button box at the center of the gantry. It would seem to me that the better location of this box would be at the 0,0 end of the X located in the center at the end of the table. The current location of the 4 button box means that for the majority of the time the machine is running, these buttons are not accessible.

2) Functionality - Are the buttons actually being used? I understand the importance of have an E Stop and a Resume but do you use the pause. Is there some other function you would rather have.

3) Have you implemented the 4 button?

Thanks
Reply With Quote
  #22  
Old Fri 11 January 2008, 04:58
J.R. Hatcher
Just call me: J.R. #4
 
Wilmington, North Carolina
United States of America
Send a message via Skype™ to J.R. Hatcher
Nils the way I see it, without a pause button You don't need a resume. The machine can't resume from an e-stop, it can only resume from a pause.
Reply With Quote
  #23  
Old Fri 11 January 2008, 05:01
sailfl
Just call me: Nils #12
 
Winter Park, FL
United States of America
Okay, I agree that you need at least three buttons and the functionality of those buttons are useful.
Reply With Quote
  #24  
Old Fri 11 January 2008, 08:30
Gerald D
Just call me: Gerald (retired)
 
Cape Town
South Africa
1.) The buttons on the y-car are used while walking/crawling on the table. I am dead serious. Remember our standard board (and table size) is 2.7 X 1.8 meter [9 x 6 ft]

2.) Pause & Resume very commonly used. Should hope that the e-stop is never used, but that it is always available.

3.) No. It was planned that the 4th button would start a z=0 procedure and touch the z-axis down to a plate.

Quote:
Originally Posted by sailfl View Post
. . . . button box at the center of the gantry. It would seem to me that the better location of this box would be at the 0,0 end of the X located in the center at the end of the table.
That is a very dirty position from a dust viewpoint, G-clamps are used in that area, some jobs (eg signs) overhang that area while cutting, prone to bashing while loading the table.
Reply With Quote
  #25  
Old Fri 11 January 2008, 09:41
sailfl
Just call me: Nils #12
 
Winter Park, FL
United States of America
Gerald

I asked Sean about putting moving the buttons when I was there and he convienced me that as usual your design is good.

Thanks
Reply With Quote
  #26  
Old Fri 11 January 2008, 10:47
Gerald D
Just call me: Gerald (retired)
 
Cape Town
South Africa
So why did you ask me to motivate it again?
Reply With Quote
Reply

Register Options Profile Last 1 | 3 | 7 Days Search Today's Posts Mark Forums Read

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 21:28.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.