PDA

View Full Version : UCCNC Modbus Master plugin..cant gete my VFD to run ????



eskolin
13-06-2021, 10:42 AM
Hello All

I have a Altivar 320vfd ( B&R P74) and I wanted to control it via Modbus in UCCNC, I use a USB-RS485 converter from my desktop PC and to the VFD

it look as every thing is "Green " in the Modbus-plug in, but it wil not start up ??? anyone who have a Idea what I am doing wrong ????

30070

the last number in the "Green" line is changing number all the time 30071

hope for help :-)

Bent

A_Camera
14-06-2021, 06:34 PM
Hi Bent,

It looks like you are only reading registers, not writing (sending) any commands to the VFD register which controls start and stop and the spindle speed. I include pictures of my Modbus Master screens, yours should look similar regarding start / stop and spindle rpm command. Of course, register numbers don't match, so you can't just copy mine, but as you see, I am writing to a register for on/off and rpm. That process in my case can be done in one commend, or two if I wanted to, but I do it in one.

30072

30073

30074

30075

eskolin
14-06-2021, 07:36 PM
Hi A_Camera

I wil try to change to "write multiplyregister" and see if anything is happend then....

in my "Variables table" I only have "0" ???

I will be back :-)

Ben

A_Camera
14-06-2021, 09:18 PM
You must also write a macro which actually controls everything.


// ----------------------------------------------------------------------------------------------------
//
// M20304 Seting the spindle speed, runing CW/CCW and reading some VFD and spindle parameters.
// This is a Modbus interface macro and is running in a macro loop.
//
// When this macro is called it will check the Set Spindle Speed and the Spindle Speed Override DRO
// and will calculate the matching frequency. This is set in Modbus register which is sent to the VFD.
//
// After this step it will check the state of RUN CW/CCW LEDs and will set the necessary VFD commands.
//
// Last it will read some VFD parameters and display in UCCNC.
//
// ----------------------------------------------------------------------------------------------------
//
// Constants
//
ushort RunSpindleCW = 129; // Rexroth EFC5610 RUN CW command
ushort RunSpindleCCW = 133; // Rexroth EFC5610 RUN CCW command
ushort StopSpindleRun = 136; // Rexroth EFC5610 STOP command

ushort SSetDRO = 869;
ushort SactDRO = 870;
ushort SSOverriddenDRO = 2451;
ushort MaxSpindleSpeedDRO = 178;
double MaximumRPM = 24000;

int OutputVoltage = 20010; // VFD and spindle monitoring parameter field numbers
int OutputCurrent = 20011;
int OutputPower = 20012;
int DCBusVoltage = 20013;
int OutputTorque = 20014;
int PowerModuleTemp = 20015;
int ActualSpeed = 20016;
int SpindleTemp = 20017;
int SpeedArrival = 800;

ushort OutputVoltageDRO = 20010;
ushort OutputCurrentDRO = 20011;
ushort OutputPowerDRO = 20012;
ushort DCBusVoltageDRO = 20013;
ushort OutputTorqueDRO = 20014;
ushort PowerModuleTempDRO = 20015;
ushort ActualSpeedDRO = 20016;
ushort SpindleTempDRO = 20017;
ushort SpeedArrivalLED = 800;

ushort SpindleRunReg = 0; // Dispayed UCCNC Modbus register list
ushort VFDFrequencyReg = 1;
ushort ActualSpeedReg = 11;
ushort OutputVoltageReg = 20;
ushort OutputCurrentReg = 10;
ushort OutputPowerReg = 22;
ushort DCBusVoltageReg = 23;
ushort OutputTorqueReg = 24;
ushort PowerModuleTempReg = 30;
ushort SpeedArrivalReg = 40;


//
// Variables
//
string SspeedOverride;
int IndexOfPercentSign;
string SSpeedOverride;

double Current;
double Power_kW;
double Torque;
double SSpeedHz;

//
// Program starts here
//
//-------------- Set spindle speed value firtst ---------------------------------------------------------------
//
//
MaximumRPM = AS3.Getfielddouble(MaxSpindleSpeedDRO);
SSpeedHz = ( AS3.Getfielddouble(SSOverriddenDRO));
if (SSpeedHz > MaximumRPM)
{
SSpeedHz = MaximumRPM; // Force maximum RPM to prevent exception
}
//
// Calculate the matching RPM frequency and send the value to Modbus register.
//
exec.SetModbusregister(VFDFrequencyReg, (ushort) Convert.ToUInt16(SSpeedHz / 0.6));
//
//-------------- 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); //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
}

// ----------------------------------------------------------------------------------------------------
//
// Reading the VFD parameters via Modbus
//
// ----------------------------------------------------------------------------------------------------
//
//
// Get the parameters from the VFD and output to display
//

exec.GetModbusregister(OutputVoltageReg, out OutputVoltageDRO);
AS3.Setfield(OutputVoltageDRO, OutputVoltage);

exec.GetModbusregister(OutputCurrentReg, out OutputCurrentDRO);
Current = Convert.ToDouble(OutputCurrentDRO * 0.01);
AS3.Setfield(Current, OutputCurrent);

exec.GetModbusregister(OutputPowerReg, out OutputPowerDRO);
Power_kW = Convert.ToDouble(OutputPowerDRO * 0.1);
AS3.Setfield(Power_kW, OutputPower);

exec.GetModbusregister(DCBusVoltageReg, out DCBusVoltageDRO);
AS3.Setfield(DCBusVoltageDRO, DCBusVoltage);

exec.GetModbusregister(OutputTorqueReg, out OutputTorqueDRO);
Torque = Convert.ToDouble(OutputTorqueDRO) * 0.1;
AS3.Setfield(Torque, OutputTorque);

exec.GetModbusregister(PowerModuleTempReg, out PowerModuleTempDRO);
AS3.Setfield(PowerModuleTempDRO, PowerModuleTemp);
exec.GetModbusregister(ActualSpeedReg, out ActualSpeedDRO);
AS3.Setfield(ActualSpeedDRO, ActualSpeed);
AS3.Setfield(ActualSpeedDRO, SactDRO);

exec.GetModbusregister(PowerModuleTempReg, out SpindleTempDRO);
AS3.Setfield(SpindleTempDRO, SpindleTemp); // Temorarily set the power module temp here

exec.GetModbusregister(SpeedArrivalReg, out SpeedArrivalLED);

if (SpeedArrivalLED == 1)
{
AS3.SetLED(true, SpeedArrival);
}
else
{
AS3.SetLED(false, SpeedArrival);

}


if (AS3.Getbuttonstate(144) == true) //Check if the Reset button is active.
{
exec.Clroutpin(3, 17); // Turn off the fan
AS3.SetLED(false, 801); // Turn off the LED
}


//
//------------------------------------------------------------------------------------------------------
//
// End of program

This is my code, but as I explained in the mail to you, you must change the code to match your VFD. This code is running in a macro loop.

30076

The macro loop monitors the buttons and places (in my case) 129 (CW), 133 (CCW) or 136 (STOP) commands in Modbus registers, together with the spindle rpm. My recommendation is that you keep it simple and initially you only try starting and stopping the spindle. Take the next step when you understand how everything is working together.

Note that you CAN'T simply copy my code and use it as it is, you must change it to match your VFD. This code works ONLY with my Bosch Rexroth EFC 5610. My code does so much more, and is too complicated to start with unless you are an experienced programmer.

A_Camera
18-07-2021, 09:38 AM
Hi A_Camera

I wil try to change to "write multiplyregister" and see if anything is happend then....

in my "Variables table" I only have "0" ???

I will be back :-)

Ben

Hi Ben,
How is it going? Did you manage to use Modbus?