Hello Guest it is March 28, 2024, 10:56:43 AM

Author Topic: Help with maths on variables in PMC - Feedback from VFD  (Read 1603 times)

0 Members and 1 Guest are viewing this topic.

Help with maths on variables in PMC - Feedback from VFD
« on: January 09, 2021, 09:07:47 PM »
I have set up Modbus comms between my Powerflex VFD and Mach4 and I am able to control the spindle, read status logic bits, etc, but I was hoping to get the output frequency from the drive and display it as an RPM DRO on my screen. To control the speed on my spindle via PMC, I am taking the Core Val 'Spindle RPM', putting it into a variable and dividing by 6 to get the required Hertz. Then writing that variable to the VFD register.

When I attempt to do the reverse with the VFD Hertz output register, I can move the register value with a Read Reg instruction and the variable shows the correct value in the bottom section of the PMC editor. But if I try to multiply the value by 6 at the end of the rung, I get the following message
"Variable 'VFDRpm' not assigned to, e.g. MOV statement, and ADD statement, etc. This is probably a programming error; now it will always be zero."

Offline bcoop

*
  •  61 61
    • View Profile
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #1 on: January 11, 2021, 10:04:37 AM »
in the variable list you've shown, i do not see a tag defined as VFDRpm,  should you be using SpinRPM instead ? 
Bob
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #2 on: January 11, 2021, 02:35:25 PM »
Thanks Bob - Just realized that the first image I uploaded must have got cropped. The SpinRPM variable is the set speed from Mach4 that I am dividing by 6 to get the Hertz required and sending to my VFD with the RPMset variable.

What I need to do now is read back the real time VFD output so I can display the speed on screen.

I can read the VFD Hertz output register via Modbus no problem and using PMC, I can move the VFD Hertz output into a variable which I have named VFDHz, but I cannot multiply that value to get an indication of the spindle RPM.
« Last Edit: January 11, 2021, 02:40:01 PM by pintek »

Offline bcoop

*
  •  61 61
    • View Profile
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #3 on: January 11, 2021, 02:44:13 PM »
the new image is also a bit clipped, but it appears that rung 7 & 11 are invalid rungs,  the instructions should stop (attached to) at the right hand vertical Line.  can you post a copy of the code file or a full screen image
Bob
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #4 on: January 11, 2021, 02:50:00 PM »
PMC File attached.

Offline bcoop

*
  •  61 61
    • View Profile
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #5 on: January 11, 2021, 05:18:59 PM »
Ok, try this one,  rename as desired, you will have to go into the 
[read register] instruction and reselect your registers
hope it works now
Bob
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #6 on: January 11, 2021, 05:47:37 PM »
Thanks Bob. Appreciate you spending to the time to look at my issue, but unfortunately no go.
If you hit simulation mode, it gives the variable unassigned error pops up for variable VFDHz.

Tried generating LUA code and assigned a readout on the screen to display RPM in case the reported error was incorrect, but just get zero when the spindle is running and the Modbus register is showing the correct value.

If I assign the Modbus register to display on the screen, it works without a hitch. Just can't seem to assign a math operation to the variable.  :o

« Last Edit: January 11, 2021, 05:50:49 PM by pintek »

Offline bcoop

*
  •  61 61
    • View Profile
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #7 on: January 12, 2021, 08:40:16 AM »
I did a little more testing, i was able to get rid of the error by inserting an ADD instruction to add zero to VFDHz, but the result is the same. value is alway zero. when reading a modbus register into the internal register VFDHz.    I think this is something that support will need to look at, looks like some issue with how PMC is handling the instructions.
sorry couldn't be more help, i have worked quite a bit with modbus in Mach4 but not using PMC, just writing the code in Lua Scripts. 
Bob
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #8 on: January 12, 2021, 02:47:53 PM »
Not sure how Mach handles values from Modbus. Could be treating it as a string which would explain the issue.
Will keep tinkering and see if I can nut it out.

Thanks again for taking the time to assist Bob.
Re: Help with maths on variables in PMC - Feedback from VFD
« Reply #9 on: January 15, 2021, 02:03:16 AM »
The variable is probably not initialized before you are trying to multiply. Here is a multiplication example where is read ADC from modbus, multiply by 48 and move the value into another modbus register.

Just FYI because this tripped me up...Mach PMC puts characters in front of different PMC variable names, the registers have an 'A' before the name so it would be AVFDHz when using it later.
« Last Edit: January 15, 2021, 02:11:19 AM by compewter_numerical »