Modbus Master and Haunyang GT series Inverter

Post anything you want to discuss with others about the software.

Re: Modbus Master and Haunyang GT series Inverter

Postby eclsnowman » Sun Sep 12, 2021 10:42 pm

Thank you for the M4 code valhallaCNC. I seem to still be having issues getting CCW functionality working. It was working with ModbusEZ, but doesn't seem to be with Modbus Master. Looking over the Huanyang GT manual I can see Address 1000H (aka 4096) can have values of 1-8. 1 = CW/FWD, 2 = CCW/REV, 5 = STOP.

Image

I think I have the Modbus Master Function Settings done correctly per your instructions:

Image
Image

I can start and stop and the values move correctly from 1 (CW) to 5 (STOP).

Image
Image

But pressing the "SPINDLE CCW" button on the main screen or sending an M4 over MDI doesn't start the spindle in reverse like it did when I used to use ModbusEZ. And if I try and force the cell to 2 in the Modbus Master to get it to go in reverse it doesn't work.

I appreciate any advice you can provide.
eclsnowman
 
Posts: 9
Joined: Fri Nov 06, 2020 4:50 pm

Re: Modbus Master and Haunyang GT series Inverter

Postby valhallaCNC » Sun Sep 12, 2021 11:37 pm

There needs to be some additional code for the M20002 macro , look there. Need to add" ushort RunSpindleCCW= 2;" and some additional lines in the If code to check for that. I never used it so I didnt add it. Try that if i get some time I will look at it. Best I can do right now
valhallaCNC
 
Posts: 81
Joined: Wed Jun 30, 2021 8:04 pm

Re: Modbus Master and Haunyang GT series Inverter

Postby valhallaCNC » Mon Sep 13, 2021 12:03 am

I just did a quick code change , it may be wrong but it gets you in the ball park.....
Attachments
CCW Addition to M20002.txt
(1010 Bytes) Downloaded 517 times
valhallaCNC
 
Posts: 81
Joined: Wed Jun 30, 2021 8:04 pm

Re: Modbus Master and Haunyang GT series Inverter

Postby eclsnowman » Mon Sep 13, 2021 1:10 am

Thank you again for the help. I can barely "hello world" in code, but with your direction and some trial and error both M3 / CW and M4 / CCW are working as intended with VFD feedback.

Here is the code that made it work on my machine:

Code: Select all
// Created by ValhallaCNC Ver 1.00 8-18-21
// This is a Modbus M20002 macro and is running in a macro loop must be set to autorun.
// Need New M3 Macro to work with uptospeed in this macro, thanks to A_Camera this macro
// Set Your M3 start delay to zero if you want to use this feature

// UCCNC screen additions you must add these for the macro to work properly
// This is used on UCCNC Ver. 1.2113
// Add LED object to the main screen, 800 for UptospeedLED
// The 800 LED use pict #280 already in default BMP's

// Modbus Connection Settings USB to RS485
// Serial RTU, VFD & SPINDLE, 19200, 8 - N - 1, Retry 1, timeout 300, loop 25

// Modbus Communication Settings Ethernet to RS485
// Modbus Connection settings for USR-DR302
// TCP
// IP Address 10.10.10.15
// Port 503
// 3-25-100

// USR-DR302 Device settings ( My settings yours may be different)
// Static IP       10.10.10.15
// Subnet mask       255.255.255.0
// Gateway       10.10.10.10
// DNS          0.0.0.0
// TCP Server (Slave)    10.10.10.50 greyed out
// Remote Port       502 greyed out
// For VFD - 19200, 8 - none - 1, Local port 503, short comm 3, TCP count 4
// IN web setup page (10.10.10.15) need to check box RS485

// Modbus Master function settings using UCCNC registers 0 - 8
// Function ON-OFF-RESET - write single register  - slave 1 - modbus start 4096  - modbus count 1 - UCCNC start register 0
// Function VFD Speed    - write single register  - slave 1 - modbus start 8192  - modbus count 1 - UCCNC start register 1
// Function VFD Error    - read holding registers - slave 1 - modbus start 4097  - modbus count 1 - UCCNC start register 2
// Function VFD Status   - read holding registers - slave 1 - modbus start 12291 - modbus count 5 - UCCNC start register 3

// Huanyang GT inverter settings
// For Modbus Control P0.01 = 2, P0.07 = 7
// GT inverter PC.00 - PC.02 must match UCCNC modbus master communication setup
// For communication alarm PC.05 = 0 this alerts macro to a fault
// Two wire control for modbus connect to RS485+, RS485-

// It checks Set Spindle Speed and the Spindle Speed Override DRO, calculate the matching frequency
// Checks the state of SPINDLE ON LED and will send the necessary VFD commands.
// Will Check for VFD Errors with Popup msgbox for resetting
// Last it will read some VFD parameters and display in UCCNC.

// Constant spindle commands

ushort RunSpindleCW       = 1;      // RUN CW command
ushort RunSpindleCCW       = 2;      // RUN CCW command
ushort StopSpindle          = 5;      // STOP command
ushort ResetVFD          = 7;   // Reset VFD command
ushort ReleaseResetVFD       = 0;   // Releases Reset

// My max is 24000, yours may be different
double MaximumRPM       = 24000;

// UCCNC screen fields existing

ushort MaxSpindleSpeedDRO   = 178;
ushort UptospeedLED         = 800;   
ushort VFDcommfaultLED      = 801;
ushort SactDRO             = 870;
ushort SoverrideDRO         = 2451;

// UCCNC screen additions you must add these for the macro to work properly
// NEW UCCNC screen fields these are showfieldnb type objects and must be added
      
int VoltageDRO         = 20010;
int CurrentDRO         = 20011;
int SpeedDRO         = 20012;
int PowerDRO         = 20013;
int TorqueDRO         = 20014;

// UCCNC register to write

ushort SpindleRunReg      = 0;      
ushort VFDFrequencyReg       = 1;

// Variables

double OutputPowerKW ;
double SSpeedHz;
ushort ErrorHere ;
ushort []ReadUCCNCregisters ;
ushort Uptospeed ;
ushort Setspeed ;
int SSplus ;
int SSminus ;

//-----------------PROGRAM STARTS HERE---------------------

// Gets screen values for speed control

   MaximumRPM = AS3.Getfielddouble(MaxSpindleSpeedDRO);
   SSpeedHz = ( AS3.Getfielddouble(SoverrideDRO));

   if (SSpeedHz > MaximumRPM)
      {SSpeedHz = MaximumRPM;}   // Force maximum RPM to prevent exception

// Calculate the matching RPM frequency and sends the value to Modbus register.
// The 2.4 value is calculated from my displayed RPM / register 1  variable table
 
   exec.SetModbusregister(VFDFrequencyReg, (ushort) Convert.ToUInt16(SSpeedHz / 2.4));


// Reads multiple UCCNC register via modbus start at Address 0 - Reads to register 8 (Thats a total of nine)
// UCCNC Registers  Start-Stop-Reset[0], Speed[1], Fault[2], Volatge[3], Current[4], Speed[5], Power[6] not used, Torque[7]

   exec.GetModbusregisters(0,8,out ReadUCCNCregisters);

// Looks for VFD error, MSGBOX for resetting

   ErrorHere = ReadUCCNCregisters[2];
         
   if (ErrorHere == 4)
      {MessageBox.Show(exec.mainform,"Reset VFD Fault !", "VFD Fault", MessageBoxButtons.OK,MessageBoxIcon.Question );
         exec.SetModbusregister(SpindleRunReg, ResetVFD); //Resets VFD Error (7)            
            Thread.Sleep(2000);
               exec.SetModbusregister(SpindleRunReg, ReleaseResetVFD);} //Releases Reset (0) to accept commands
                                                            
   else
      {}


//-------------- Send start/stop command for the spindle --------------------------------------------------------
//
//   Check the CW and CCW LEDs and convert the state to spindle control commands.
//   The command is set in the Modbus register which is sent to VFD using the UCCNC Modbus internal handler.
//
//   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);}
   
    else
   
      if ( AS3.GetLED(51) == true ) // If the RUN CCW LED is active
      {exec.SetModbusregister(SpindleRunReg, RunSpindleCCW);}
   
   else // CW and CCW LEDs are off, send turn spindle OFF commnad
   {exec.SetModbusregister(SpindleRunReg, StopSpindle);}


// Get the parameters from the UCCNC register and outputs to screen
            
      AS3.Setfield(ReadUCCNCregisters[3], VoltageDRO);

         AS3.Setfield(ReadUCCNCregisters[4], CurrentDRO);

            AS3.Setfield(ReadUCCNCregisters[5], SactDRO);

               OutputPowerKW = (ReadUCCNCregisters[3] * ReadUCCNCregisters[4]);   
               AS3.Setfield(OutputPowerKW, PowerDRO);

                  AS3.Setfield(ReadUCCNCregisters[7], TorqueDRO);

// Sets status of uptospeed LED
// The +- 3 is a range, my actual RPM are within one RPM of my set RPM

   Uptospeed = ReadUCCNCregisters[5];
   Setspeed = ReadUCCNCregisters[1];
   
   Setspeed = (ushort) Convert.ToUInt16(Setspeed * 2.4);

   SSplus = Setspeed + 3;
   SSminus = Setspeed -3;
   
   if(SSminus <= Uptospeed && Uptospeed <= SSplus)

      {AS3.SetLED(true, UptospeedLED);}
      
   else
      {AS3.SetLED(false, UptospeedLED);}


Attachments
M20002.txt
Modified M2002 for CW and CCW
(6.39 KiB) Downloaded 535 times
eclsnowman
 
Posts: 9
Joined: Fri Nov 06, 2020 4:50 pm

Re: Modbus Master and Haunyang GT series Inverter

Postby davidrid » Mon Jan 08, 2024 2:07 pm

i'm able to get everything setup like the instructions said, i can hear the VFD fan kick in when i turn spindle on, but no speed out out of the spindle.
any suggestions?
davidrid
 
Posts: 7
Joined: Mon Jan 01, 2024 3:16 am

Re: Modbus Master and Haunyang GT series Inverter

Postby sebba » Fri Nov 01, 2024 3:29 pm

Hello,

I want to implement the modbus control for my vfd, using your example and codes. So, thank you for sharing this.

So: UCCNC v1.2117 here, but tested also with v1.2113 with same issues. Fuling DZB200B VFD. Manual attached.
When I'm trying to add a "Write single register" function, I get it a red "Loop waiting" error when start loops.
The strange part: first MDI command after restart uccnc, like M3 S9000, start the spindle at 9000 but after that MDI become "unavailable", I mean I cannot type more commands, it is like frozen.
Also, UCCNC program itself become laggy. Buttons are working.
Clicking again on SPINDLE CW button turn the spindle off

What could be the reason to have this error for Write single register function?
Reading holding register functions are running ok, no issues.

Similar commands are running in Mach3, same addreses, same vfd, same computer, same usb adapter and no errors.

Any advice is welcome
Thank you,
Seb
Attachments
dzb200_series.pdf
(1.06 MiB) Downloaded 31 times
- YQWQ
User avatar
sebba
 
Posts: 53
Joined: Mon Dec 21, 2020 9:56 am
Location: Bucharest, ROMANIA

Re: Modbus Master and Haunyang GT series Inverter

Postby valhallaCNC » Fri Nov 01, 2024 4:01 pm

I looked at your manual, addresses are the same. Sounds like it's in your modbus setup. All have to be green to work. Maybe a conflict in your UCCNC start register ?
Is slave address correct ?
That's all I have...
valhallaCNC
 
Posts: 81
Joined: Wed Jun 30, 2021 8:04 pm

Re: Modbus Master and Haunyang GT series Inverter

Postby sebba » Fri Nov 01, 2024 4:42 pm

thank you for very fast reply
same slave 1 for Mach3, same for modbusSZ (which finally work but with wrong speed - 2400 instead of 6000rpm)
it is a new uccnc installation, just some inputs and outputs configured, windows 7
variable tables are looking good

LE:
Tested on W10 with uccnc 2117 in demo mode. same issue
- YQWQ
User avatar
sebba
 
Posts: 53
Joined: Mon Dec 21, 2020 9:56 am
Location: Bucharest, ROMANIA

Re: Modbus Master and Haunyang GT series Inverter

Postby sebba » Sat Nov 02, 2024 9:04 am

hello again
questions, maybe stupid:
the write function should run without a macro for defining variables? I tried both ways, same error.
could be some hardware related issue, even is working under Mach's modbus config and brains?
thanks
- YQWQ
User avatar
sebba
 
Posts: 53
Joined: Mon Dec 21, 2020 9:56 am
Location: Bucharest, ROMANIA

Re: Modbus Master and Haunyang GT series Inverter

Postby valhallaCNC » Sat Nov 02, 2024 1:28 pm

Macros do not need to be running for modbus to function.
I looked through the manual again, did you set F0.01 on the VFD to option 2 . That's for modbus control ,don't know if it make a difference.

F0.01 Command source selection
0 Keyboard :
1 Terminal :
2 Communication :
valhallaCNC
 
Posts: 81
Joined: Wed Jun 30, 2021 8:04 pm

PreviousNext

Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: Google [Bot] and 30 guests