Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Tecmaqcnc on March 19, 2025, 03:44:42 PM

Title: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on March 19, 2025, 03:44:42 PM
I need to create a macro or script to manage the raising and lowering of two pressure rollers of the part against the machine bed.

I need the front roller to deactivate (raise) by activating an output when it is 80mm or less from the edge of the geometry at the origin in Y, and to raise again when it exceeds the 80mm Y dimension.

The rear roller needs to raise when it is 80mm or less from the maximum Y value in the Gcode, and to lower again when it is outside this range.

Could you help me?

It would be something like a variable or something like that.

I've seen that this data can be used from Mach:

MaxY – Get maximum Y extent for current G-code file

SetParam("YMachine", Axis position)

The variables would be something like this, but I don't know if Mach3 works this way...

MaxY=>MaxY-80, DeactivateSignal(OUTPUT3) ' Deactivate rear piston lowering

MaxY=<MaxY-80, ActivateSignal(OUTPUT3) ' Activate rear piston lowering

YMachine=>YMachine-80, DeactivateSignal(OUTPUT2) ' Deactivate front piston lowering

YMachine=>YMachine+80, ActivateSignal(OUTPUT2) ' Activate front piston lowering






Necesito crear una macro o script, para gestionar la subida y bajada de dos rodillos de presion de la pieza contra la bancada maquina.

El rodillo delantero, necesito que desactive (suba) activando una salida cuando este en Y a 80mm o menos del filo de la geometria en el origen y que vuelva a subir cuando se supere la cota 80mm en Y.

El rodillo trasero necesita que suba cuando este a 80mm o menos del Y maximo del Gcode, y que vuelva a bajar cuando este fuera de este rango.

Podriais ayudarme?

Seria algo como una variable o algo asi.

He visto que se pueden usar estos datos desde mach:

MaxY – Get maximum Y extent for current G-code file

SetParam(“YMachine”, Axis position)

Las variables serian algo asi, pero nose si mach3 trabaja de esta forma.....

MaxY=>MaxY-80, DeactivateSignal(OUTPUT3) ‘ Desactivar bajada piston trasero

MaxY=<MaxY-80,ActivateSignal(OUTPUT3) ‘ Activar bajada piston trasero

YMachine=>YMachine-80, DeactivateSignal(OUTPUT2) ‘ Desactivar bajada piston delantero

YMachine=>YMachine+80,ActivateSignal(OUTPUT2) ‘ Activar bajada piston delantero

Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: TPS on March 22, 2025, 02:54:52 AM
something like this should work:
Code: [Select]
'Get the actual values
ActY = GetOEMDro(1)
MinYCoord = GetOEMDro(5)
MaxYCoord = GetOEMDro(11)

'front lowering
If ActY <= (MinYCoord+80) Then ActivateSignal(OUTPUT2)
'front raising
If ActY > (MinYCoord+80) Then DeActivateSignal(OUTPUT2)
'rear lowering
If ActY <= (MaxYCoord-80) Then ActivateSignal(OUTPUT3)
'front raising
If ActY > (MaxYCoord-80) Then DeActivateSignal(OUTPUT3)

if you put it in macropump.M1s it will run cyclic.
not tested just written down
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on March 22, 2025, 04:31:41 AM
Thanks a lot, mate, I'll try it!!

Have a great weekend!
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on April 01, 2025, 01:47:50 PM
Hi, I uploaded the programming to the macropump today, but it didn't work.

The outputs I used were always active; they wouldn't deactivate.

The macropump already had a subroutine for switching work zones, but I don't think that's the problem.

I'm posting the entire programming here in case you can help me. Thanks!

'Get the current values
ActY = GetOEMDro(1)
MinYCoord = GetOEMDro(5)
MaxYCoord = GetOEMDro(11)

'front lowering
If ActY <= (MinYCoord+80) Then ActivateSignal(OUTPUT10)
'front raising
If ActY > (MinYCoord+80) Then DeActivateSignal(OUTPUT10)
rear lowering
If ActY <= (MaxYCoord-80) Then ActivateSignal(OUTPUT11)
'front raising
If ActY > (MaxYCoord-80) Then DeActivateSignal(OUTPUT11)


If(GetInBit(90, 2)) And Not (GetOemLed(800)) Then
Code("G55")
Wait
If getDro(24) = 2 Then
Code("G52 X-275.95 Y167.36 ")
Wait
End If
If getDro(24) = 3 Then
Code("G52 X-551.09 Y-2.87 Z0")
Wait
End If
Wait

End If

If(GetInBit(90, 3)) And Not (GetOemLed(800)) Then
Code("G56")
Wait
If getDro(24) = 2 Then
Code("G52 X-275.95 Y167.36 ")
Wait
End If
If getDro(24) = 3 Then
Code("G52 X-551.09 Y-2.87 Z0")
Wait
End If

End If


End

'-----------------------------------------------------------------------------
Sub Wait()
WhileIsMoving()
Sleep(15)
wend
End Sub
'-----------------------------------------------------------------------------
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: TPS on April 01, 2025, 02:08:49 PM
the code looks ok for me.

the other code looks like you are using a CSMIO controler?
how did you configure the outputs in ports and pins?
normaly you use the SetOutBit(x,y) or ResetOutBit(x,y) for those outputs.

it is very dangerous to use Sleep's in macropump because macropump is called
normaly every 20ms as a 'cyclic' task.

also all your GCode commands should not be in macropump, they are looking like
they are related to a toolchange and should be in M6Start macro, just a thought.
 
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on April 01, 2025, 02:21:50 PM
Thanks for your suggestion. Another programmer made it. It's a subroutine to divide the machine into two work zones. With this programming, the machine switches zones so it's always working while the operator places another part on the other side.

If I change this current programming to macro M6, will the machine use this programming at the start of each program? Or when calling M6?

Correct, the machine has a CSMIO.

I configured the output ports and pins normally. I checked enabled and configured the port and pin numbers, just that...

Could you tell me how to configure the outputs as you indicated with SetOutBit(x,y) or ResetOutBit(x,y)?
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: TPS on April 02, 2025, 01:42:39 AM
there is a small mistake in code :

original:

'Get the current values
ActY = GetOEMDro(1)
MinYCoord = GetOEMDro(5)
MaxYCoord = GetOEMDro(11)

'front lowering
If ActY <= (MinYCoord+80) Then ActivateSignal(OUTPUT10)
'front raising
If ActY > (MinYCoord+80) Then DeActivateSignal(OUTPUT10)
rear lowering
If ActY <= (MaxYCoord-80) Then ActivateSignal(OUTPUT11)
'front raising
If ActY > (MaxYCoord-80) Then DeActivateSignal(OUTPUT11)



should be:

'Get the current values
ActY = GetDro(1)
MinYCoord = GetOEMDro(5)
MaxYCoord = GetOEMDro(11)

'front lowering
If ActY <= (MinYCoord+80) Then ActivateSignal(OUTPUT10)
'front raising
If ActY > (MinYCoord+80) Then DeActivateSignal(OUTPUT10)
'rear lowering
If ActY <= (MaxYCoord-80) Then ActivateSignal(OUTPUT11)
'front raising
If ActY > (MaxYCoord-80) Then DeActivateSignal(OUTPUT11)

Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on April 02, 2025, 09:37:37 AM
Hi, thank you very much! I'll try it.
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on April 12, 2025, 12:13:35 PM
Hi, I've tested the code and it works correctly now, but I need the Y-axis position comparison to be based on the G code. Currently, it's based on the machine's absolute Y-axis position.

Should I change ActY = GetDro(1) to another parameter?

Could you help me? Thanks.
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: TPS on April 13, 2025, 03:33:34 AM
maybe GetOEMDro(801) is what you are looking for.
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on April 13, 2025, 03:44:47 AM
With GetOEMDro(801), can I use it for the two functions shown in the attached files?

I need to work with those two, MaxY and MinY.
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: TPS on April 13, 2025, 03:46:44 AM
i mean:

ActY = GetOEMDro(801)

it will not effect the Min and Max.
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on April 13, 2025, 03:53:01 AM
I need to compare the current position of the machine with the minimum and maximum Y values ​​in the G code, to raise or lower the rollers when they are close to the maximum and minimum Y limits.
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: TPS on April 13, 2025, 03:56:12 AM
I need to compare the current position of the machine with the minimum and maximum Y values ​​in the G code, to raise or lower the rollers when they are close to the maximum and minimum Y limits.
that is what the code does? if you are using G54,G55 .. it should do it during you run your G-code program.
Title: Re: Macro/Script rodillos de sujeccion fresadora
Post by: Tecmaqcnc on April 13, 2025, 04:04:43 AM
I'll try ActY = GetOEMDro(801).

Thank you.

If we are using G55 and G56