[ Vfdmod ] An easy VFD control over MODBUS RTU
- Todd Zuercher
- Offline
- Platinum Member
- Posts: 5007
- Thank you received: 1441
Please Log in or Create an account to join the conversation.
- s_volenszki
- Offline
- New Member
- Posts: 6
- Thank you received: 2
I had no time on the week just tonight and I fired up the logic analyser. The result was surprising, actually all response CRC are invalid checksum. I used Saleae Logic analyzer software with Modbus RTU analyzer. After I started to read the VFD documentation again and I found something:
"At the time of transmission, the low bytes are in CRC CHK high bit front and the high bytes are in the back. When CRC is added to the message, low bytes are added first, and then high bytes."
This is a command to read the VFD current frequency:
01 03 10 00 00 01 80 CA
This is the answer from the VFD:
01 03 00 02 09 C4 E3 C9
And if I calculate the 01 03 00 02 09 C4 CRC value:
CRC-16/MODBUS => 0xC9E3
So this is absolutely clear the VFD answering the CRC in reverse. Now only one question left, how can I reverse the CRC before the Vfdmod start to compare with the pre calculated CRC?
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Offline
- Platinum Member
- Posts: 5007
- Thank you received: 1441
Please Log in or Create an account to join the conversation.
I can't believe CRC works normally in writing mode, but needs to swap a pair of bytes in reading mode. It's insane!vfdmod: setting command speed value to 2500 (0x09C4)...
[01][06][10][00][09][C4][8A][C9]
Waiting for a confirmation...
<01><06><10><00><09><C4><8A><C9> <<< OK! Response is valid!
vfdmod: setting control word value to 6 (0x0006)...
[01][06][20][00][00][06][02][08]
Waiting for a confirmation...
<01><06><20><00><00><06><02><08> <<< OK! Response is valid!
vfdmod: reading 'spindle.rpm-out' from address 4096 (0x1000)...
[01][03][10][00][00][01][80][CA]
Waiting for a confirmation...
<01><03><00><02><09>
ERROR CRC received 0x209 != CRC calculated 0x20F0
Please Log in or Create an account to join the conversation.
- s_volenszki
- Offline
- New Member
- Posts: 6
- Thank you received: 2
I do not know what's next. I try to change Modbus data format and Modbus protocol type, if it will fail too, I think I either start to learn the 0-10V analog solution or the PWM solution (if the VFD supports), or ask may local supplier to give me quotation for a supported VFD (like Omron or Siemens).
Thank you all for your help so far.
Please Log in or Create an account to join the conversation.
- s_volenszki
- Offline
- New Member
- Posts: 6
- Thank you received: 2
What I did with Sako SKI-780:
- Set the PP-01 to 01 manual on the VFD control panel (01 = reset factory settings except motor parameters)
- I used the default 9600 baudrate.
- Set the command source to RS485 with serial console app (01 06 F0 02 00 02 9A CB).
- Set the main frequency source to RS485 with serial console app (01 06 F0 03 00 09 8A CC).
- Changed the Modbus protocol to 31, standard Modbus communication, through RS485 with serial console app (01 06 FD 05 00 1F).
- Changed the Modbus data format to 8,N,1 (value 3) through RS485 with serial console app (01 06 FD 01 00 03).
Read baudrate
Request: 01 03 FD 00 00 01 B5 A6
Response: 01 03 02 17 75 76 53
Calculated response CRC: 0x5376
Write baudrate
Request: 01 06 FD 00 17 75 76 71
Response: 01 06 FD 00 17 75 76 71
Calculated response CRC: 0x7176
Set spindle speed to 100Hz
Request: 01 06 10 00 09 C4 8A C9
Response: 01 06 10 00 09 C4 8A C9
Calculated response CRC: 0xC98A
So I don't know what was the key parameter for the solution, but now it works, and I hope, next time if someone walks the same way, will end up in less dead ends like me did (I think because of my inattention)
Please Log in or Create an account to join the conversation.
- hitchhiker
- Offline
- Premium Member
- Posts: 138
- Thank you received: 9
I want to work with your component but i think i am to stupid to do the correct changes to the ini......
i add the ini to this reply and a picture from the registers.
please please please help.... thanks...
Please Log in or Create an account to join the conversation.
- hitchhiker
- Offline
- Premium Member
- Posts: 138
- Thank you received: 9
thanks
Please Log in or Create an account to join the conversation.
Thanks @aekhv for this lovely bit of code!
Hope this information comes in handy for anyone using a Folinn VFD!
Here's the ini file I've used on Debian Bullseye with LinuxCNC 2.9 (default release packages work perfectly fine):
[Common]
MaxSpeedRPM=24000
MinSpeedRPM=6000
;AtSpeedThreshold=0.05
[RS485]
SlaveAddress=1
SerialDevice=/dev/ttyUSB1
BaudRate=9600
LoopDelay=500
ProtocolDelay=6
;IsConnectedDelay=10
ConnectionErrorList=110
ConnectionDelay=500
[Control]
Address=0x1000
RunForwardValue=0x0001
RunReverseValue=0x0002
FaultResetValue=0x0007
StopValue=0x0006
[SpindleRpmIn]
FunctionCode=0x06
Address=0x3000
Multiplier=10000
Divider=24000
[SpindleRpmOut]
Address=0x3001
Multiplier=30
Divider=10
[freq-running]
FunctionCode=0x03
Address=0x3001
PinType=float
PinName=freq-running
Divider=10
[bus-voltage]
FunctionCode=0x03
Address=0x3002
PinType=float
PinName=bus-voltage
[output-voltage]
FunctionCode=0x03
Address=0x3003
PinType=float
PinName=output-voltage
[output-current]
FunctionCode=0x03
Address=0x3004
PinType=float
PinName=output-current
Divider=100
[output-torque]
FunctionCode=0x03
Address=0x3006
PinType=float
PinName=output-torque
[run-speed]
FunctionCode=0x03
Address=0x3007
PinType=float
PinName=run-speed
[spindle-load-speed]
FunctionCode=0x03
Address=0x300F
PinType=float
PinName=spindle-load-speed
[power-on-time]
FunctionCode=0x03
Address=0x301A
PinType=float
PinName=power-on-time
[spindle-run-time]
FunctionCode=0x03
Address=0x301B
PinType=float
PinName=spindle-run-time
[fault-code]
FunctionCode=0x03
Address=0x8000
PinType=float
PinName=fault-code
And here's the files added to the custom.hal to make it work with the interface:
loadusr -W vfdmod bd600.ini --debug
net spindle-vel-cmd-rpm => vfdmod.spindle.rpm-in
net spindle-at-speed <= vfdmod.spindle.at-speed
net spindle-cw => vfdmod.control.run-forward
net spindle-ccw => vfdmod.control.run-reverse
Please Log in or Create an account to join the conversation.
I got a feeling my RS485 interface is bad but you have inspired me to keep trying!
It would be helpful if you could outline the changes you made in the VFD settings to enable RS485 control
Please Log in or Create an account to join the conversation.