UCCNC MODBUS MACROS.

If you have a question about the software please ask it here.

UCCNC MODBUS MACROS.

Postby shakil1740 » Mon Jul 11, 2022 10:10 pm

// Check CW and CCW LEDs, start or stop the spindle based on LED states.
// After exiting this macro the Modbus register is set up for CW, CCW or Stop
//
if ( AS3.GetLED(50) == true ) // If the RUN CW LED is active
{
exec.SetModbusregister(SpindleRunReg, RunSpindleCW); //Turn spindle on in CW rotation if LED is on
}
else

if ( AS3.GetLED(51) == true ) // If the RUN CCW LED is active
{
exec.SetModbusregister(SpindleRunReg, RunSpindleCCW); //Turn spindle on in CCW rotation if LED is on
}
else // CW and CCW LEDs are off, send turn spindle OFF commnad
{
exec.SetModbusregister(SpindleRunReg, StopSpindleRun); // Send Rexroth EFC5610 STOP command to VFD
}

// ----------------------------------------------------------------------------------------------------
In this code snippet " if ( AS3.GetLED(51) == true ) // If the RUN CCW LED is active
{
blah blah
}
else
{
blah blah
}
not working but
" blah blah "
without if statement works perfectly fine.
please help. Thanks in advance.
shakil1740
 
Posts: 9
Joined: Mon Jul 11, 2022 8:22 pm

Re: UCCNC MODBUS MACROS.

Postby shakil1740 » Sat Jul 16, 2022 1:15 am

OK finally found the solution,
This code worked flawlessly,

Code: Select all
[attachment=0]M20220.txt[/attachment]
Attachments
M20220.txt
(1.27 KiB) Downloaded 165 times
shakil1740
 
Posts: 9
Joined: Mon Jul 11, 2022 8:22 pm

Re: UCCNC MODBUS MACROS.

Postby shakil1740 » Sat Jul 23, 2022 3:05 am

YL620-A VFD revised codes for CW and CCW directions are as follows.
Code: Select all
// M20220 MODBUS macro for YL620-A VFD

 while(exec.IsMoving()){}         // Do nothing until system come to Idle
                                              // This is the most important part of the macro

 bool CW_LED   = AS3.GetLED(50);                    // Check if CW led is ON or OFF
 bool CCW_LED = AS3.GetLED(51);                    // Check if CCW led is ON or OFF

 string Sset_DRO_Value = AS3.Getfield(869);             // Read Sset DRO
 double RPM = Convert.ToDouble(Sset_DRO_Value);   // string to double to uint.NO.
 ushort FREQUENCY = (ushort) (RPM / 6);                  // And convert RPM to FREQUEY             
                                                       
   exec.SetModbusregister(1, FREQUENCY);                // Send FREQUENCY VALUE to VFD   

 ushort RunSpindleCW   =  18;                      // YL620-A RUN CW command
 ushort RunSpindleCCW  = 34;                      // YL620-A RUN CCW command
 ushort StopSpindleRun    = 1;                      // YL620-A STOP command                                                         

 if (CW_LED == true)                                            // If CW LED is ON
  exec.SetModbusregister(0, RunSpindleCW);        // Send RUN CW command to VFD
 else                                                                   // else if CW LED OFF
 if (CCW_LED == true)                                         // If CCW LED is ON
  exec.SetModbusregister(0, RunSpindleCCW);     // Send RUN CCW command to VFD
 else                                                                  // else if CW LED OFF
  exec.SetModbusregister(0, StopSpindleRun);     // Send STOP command to VFD
// End of File


M20220.txt
(1.66 KiB) Downloaded 142 times
shakil1740
 
Posts: 9
Joined: Mon Jul 11, 2022 8:22 pm


Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 4 guests