Hello Guest it is April 16, 2024, 01:06:29 AM

Author Topic: Macro for inputs and outputs  (Read 7934 times)

0 Members and 1 Guest are viewing this topic.

Offline Jim G

*
  •  22 22
    • View Profile
Macro for inputs and outputs
« 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)

Offline Jim G

*
  •  22 22
    • View Profile
Re: Macro for inputs and outputs
« Reply #1 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


Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Macro for inputs and outputs
« Reply #2 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



Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Macro for inputs and outputs
« Reply #3 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

Offline Jim G

*
  •  22 22
    • View Profile
Re: Macro for inputs and outputs
« Reply #4 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

Offline Jim G

*
  •  22 22
    • View Profile
Re: Macro for inputs and outputs
« Reply #5 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

Offline Jim G

*
  •  22 22
    • View Profile
Re: Macro for inputs and outputs
« Reply #6 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...

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Macro for inputs and outputs
« Reply #7 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 ??



Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Macro for inputs and outputs
« Reply #8 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 ??

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Macro for inputs and outputs
« Reply #9 on: February 06, 2016, 03:32:57 PM »
Repeats are easy BUT teh Mcode has to work correctly first (;-)