Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: Jim G on February 03, 2016, 03:44:40 PM

Title: Macro for inputs and outputs
Post by: Jim G on February 03, 2016, 03:44:40 PM
Trying to get this macro to work better -
The controller sends a signal to an air valve that sends a signal to the tow Desoutter drillers to activate
There is a cam switch at on the drillers that is to send a switch to the controller when the cycle is done so the controller moves to the next position and does it all over again.

The problem is the "sleep " command .... not sure why it is isn't working correctly but I have to have a sleep that is greater than the driller cycle... My desire is that the sleep command just takes the signal form the driller completion and turns that sustained signal into a momentary signal.  If I am not drilling and the signal stays on the controller moves quickly - like the sleep command is ignored. But when actually drilling the sleep command has to be longer than the drill cycle or it tries to move the part before the driller has finished up. Make sense? MMMMM?

Here is the Macro - it works - just want to get the thing to cycle faster.

ActivateSignal(OUTPUT1)
While Ismoving()
Sleep(1100)        ' Wait 1.1 sec  This can be adjusted as needed
Wend
While IsActive(INPUT1)= False
Sleep(50)
Wend
DeactivateSignal(OUTPUT1)
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 03, 2016, 05:39:07 PM
this needed a bit of editing - should read these before I post right...
 
The controller sends a signal to an air valve that sends a signal to the two Desoutter drillers to activate
There is a cam switch on one of  the drillers that  sends a signal to the controller when the cycle is done so the controller moves to the next position and does it all over again.

The problem is the "sleep " command .... not sure why it is isn't working correctly but I have to have a sleep that is greater than the driller cycle... My desire is that the sleep command just takes the signal form the driller completion and turns that sustained signal into a momentary signal.  If I am not drilling and the signal stays on the controller moves quickly - like the sleep command is ignored. But when actually drilling the sleep command has to be longer than the drill cycle or it tries to move the part before the driller has finished up. Make sense? MMMMM?

Drilling wood so there is quite a bit of difference in the density sometimes from board to board so I have to have a sleep cycle that is longer than the longest drilling cycle - which really slows things down..

Jim


Title: Re: Macro for inputs and outputs
Post by: BR549 on February 03, 2016, 06:47:49 PM
Nope no sense at all, (;-) You need to post teh entire script

Which sleep are you referreing to there are 2.

What I see from your piece of script is

You activate output1
Start a wait loop and sleep for 1.1 sec then continue
End the loop

Start another wait loop based on teh state of input1  IF not active then loop and
Sleep 50 ms between each loop .

When it finally sees teh signal from input1 then deactivate output1



Title: Re: Macro for inputs and outputs
Post by: BR549 on February 03, 2016, 07:02:50 PM
IF I read what you are doing right here is want you need.

ActivateSignal(OUTPUT1)     ' Activate output
While Ismoving()
Wend

While IsActive(INPUT1)= False    'Wait for the done signal
Sleep(20)
Wend

DeactivateSignal(OUTPUT1)   ' Deactivate Output
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 06, 2016, 02:31:43 PM
Tried this and it didn't wait for the driller to get done before it moved.
If I leave the spaces in there it won't run at all...
MMMMMM?
Seems like I can always get the output signal to work - I just can't get it to wait for the input signal from the driller to start moving again.

Jim
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 06, 2016, 03:19:03 PM
Here is the entire script.
We also just had to add .003 to each 3" movement and .005 to each 5" movement or we had an accumulated error at the end of the cycle that was nearly .125.
MMMMM?  Is that normal?


G90
G0G17G40G49G80G90
G91
G1X5F600
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X5
M901
G1X10
M0
G90
G0X0
M30
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 06, 2016, 03:19:52 PM
Instead of doing the repeat on this I would like a loop that just repeats will X number of times...
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 06, 2016, 03:23:26 PM
Spaces have nothing to do with anything in Mach3 Scripting.

If that does not work then it is 1 of 2 things Your signal is not being seen OR the logic expression for the signal is wrong.  

Do you see the Input1 signal activate on the diagnostic screen when teh driller is done ??



Title: Re: Macro for inputs and outputs
Post by: BR549 on February 06, 2016, 03:29:44 PM
Motion error would be a possible setup problem with your steps per. Either they are not correct OR leaves the step motion so course as it cannot make the correct motion based on full steps. 

For example IF your setting gives you a Min move per step as say .003 and you tried to move .008 as an inc move then it will stop short at .006 rather than overrun to .009.

Are your DROs displaying the correct values for each move ??
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 06, 2016, 03:32:57 PM
Repeats are easy BUT teh Mcode has to work correctly first (;-)
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 06, 2016, 04:33:11 PM
Repeats (;-) and YES it all works HERE including the M901 Mcode.

G0 G17 G40 G49 G80 G90
G91 (Set Inc Mode)
G0 X0 Y0
F600
M98 P001 L22 (Loop 22 times)
G0 X0 Y0
G90  ( Reset Abs Mode)
M30
%
o001
G1X5
M901 ( call driller, wait for signal)
M99
%
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 07, 2016, 10:50:17 AM
On the overall movement thing - I do not have an encoder or dro....
But If I tell it to move 120" it moves 120" measured with a tape measure. In reality it probably moves a few thousands less. Seems like every step it loses just a bit and since we are doing a lot of steps it adds up .
The Macro works if I put in a sleep that is longer than the drill cycle and I do see that it is getting the input from the end of drill cycle..

Title: Re: Macro for inputs and outputs
Post by: stirling on February 07, 2016, 11:03:00 AM
Try this:

Code: [Select]
ActivateSignal(OUTPUT1)

while isActive(INPUT1)
  sleep 10
wend

while not isActive(INPUT1)
  sleep 10
wend

DeactivateSignal(OUTPUT1)
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 07, 2016, 11:15:50 AM
Leave in the blank lines or not?
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 07, 2016, 11:30:18 AM
OK that tells me that the logic is not working IF the sleep is controlling the wait.

When your driller signals back that it is done does the led for input1 turn ON or turn OFF ?

In config for the input signal (inpout1) is it set for active high or active low. Can you show a picture of your setup in ports pins .

Also please post exactly what you have for teh M901 script. It works fine here when I test it.  We just need to get teh logic correct on your end.

(;-) TP
Title: Re: Macro for inputs and outputs
Post by: stirling on February 07, 2016, 12:06:12 PM
Blank lines are completely irrelevant.

Just copy it and try it
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 07, 2016, 03:47:54 PM
Ok - been playing with it.
When I load your macro it doesn't wait for anything... just runs !

More info in a few minutes.

Title: Re: Macro for inputs and outputs
Post by: Jim G on February 07, 2016, 04:14:08 PM
so how do I attach pics n videos?
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 07, 2016, 04:19:18 PM
Push the reply button then select additional options. Then use browse to point to the file you want to upload. Double check the size of your pictures (;-) keep them small if you can.
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 07, 2016, 04:26:53 PM
they are too big.. .mmmm gotta get them smaller.. give me a minute
Title: Re: Macro for inputs and outputs
Post by: Jim G on February 07, 2016, 05:17:26 PM
have the damned pics small but it wont send them - keep getting some error about file names.
Renamed them and it still won't work...
My regular email is midwestcypress@gmail.com
Maybe we can figure this out directly  instead of on here?
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 07, 2016, 08:19:42 PM
Yep each picture that has ever been uploaded has to have a seperate name .  No duplicates allowed.

(;-) TP
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 07, 2016, 08:21:26 PM
Try something for me . In your script change the word False to true and remove te sleep or reduce it down to say sleep(20). That will check the logic state.

(;-) TP
Title: Re: Macro for inputs and outputs
Post by: stirling on February 08, 2016, 06:51:46 AM
Ok - been playing with it.
When I load your macro it doesn't wait for anything... just runs !

If by "just runs" you mean it turns the output on and then straight off, then you have a problem with your input signal. The first loop runs whilst the input is active and the second whilst it's INactive.

It therefore must be BOTH in quick succession. Either your input isn't doing what you think - or it's bouncing.
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 08, 2016, 11:31:57 AM
OK I will let Stirling take lead on this discussion ;)

(;-) TP
Title: Re: Macro for inputs and outputs
Post by: stirling on February 08, 2016, 12:10:42 PM
LOL - why thanks Terry BR549 - didn't know there was a concept of "lead" - nor that permission was needed.  :D
Title: Re: Macro for inputs and outputs
Post by: BR549 on February 08, 2016, 02:19:46 PM
HIYA Ian not a problem here  8)    BUT it sometimes confuses teh person asking for help if 2 try to help at teh same time asking different questions.  ;)

There are plenty of questions to go around Unless RUSS is lurking about  >:D  Then it is every man for himself  ;D

(;-) TP

Title: Re: Macro for inputs and outputs
Post by: stirling on February 09, 2016, 06:52:48 AM
Terry - A good point well made. Apologies if I've confused things.