Hi
This is my first time that i am going to try something like this so i kindly looking for some help in order to understand how to make it work .
i am using an Arduino Nano and a RS485 module
First of all here is some info from my VFD manual about the ModBus communication :
Manual says that Forward command = 01H 06H 2000H 0001H 43CAH
ModBus RTU control VFD
Address : 01H (is the address of the VFD)
Function : 06H (write function code)
Starting data address : 20H
: 00H (2000H is the address of control command)
Data(2Byte) : 00H
: 01H (0001H is forward command)
CRC CHK Low : 43H
CRC CHK High : CAH (43CAH (is 16bits CRC check code)
As i can understand the "H" is not taking in count in Arduino code (no Hexadecimal with H)
Right?
One problem is not sure how to convert all the Hexadecimal in right format for Arduino (i haven't used so much these functions in my previous projects - codes in order to have more experience with them)
/*
ModBus RTU control VFD
Address : 01H (is the address of the VFD)
Function : 06H (write function code)
Starting data address : 20H
: 00H (2000H is the address of control command)
Data(2Byte) : 00H
: 01H (0001H is forward command)
CRC CHK Low : 43H
CRC CHK High : CAH (43CAH (is 16bits CRC check code)
*/
#include <SoftwareSerial.h>
#define SSerialRX 10 //Serial Receive pin
#define SSerialTX 11 //Serial Transmit pin
#define SSerialTxControl 3 //RS485 Direction control
#define RS485Transmit HIGH
#define RS485Receive LOW
#define Pin13LED 13
byte Button = 8; // push button Forward
byte StopButton = 7; // push button Forward
// From manual vfd Forward command = 01H 06H 2000H 0001H 43CAH
// From manual vfd Stop command = 01H 06H 2000H 0003H C20BH
byte request1[] = {00, 00, 20, 00, 00, 00, 43, 00}; // not the right values
byte request2[] = {00, 00, 20, 00, 00, 00, 43, 00}; // not the right values
SoftwareSerial RS485Serial(SSerialRX, SSerialTX); // RX, TX
byte byteSend;
void setup()
{
// Start the built-in serial port, probably to Serial Monitor
Serial.begin(9600);
Serial.println("SerialRemote"); // Can be ignored
pinMode (Button, INPUT_PULLUP); //Define the pin as input
pinMode (StopButton, INPUT_PULLUP); //Define the pin as input
pinMode(Pin13LED, OUTPUT);
pinMode(SSerialTxControl, OUTPUT);
// digitalWrite(SSerialTxControl, RS485Receive); // Init Transceiver
RS485Serial.begin(9600);
}
void loop()
{
if (digitalRead(Button) == LOW)
{
digitalWrite(SSerialTxControl, RS485Transmit);
RS485Serial.write(request1, sizeof(request1));
}
if (digitalRead(StopButton) == LOW)
{
digitalWrite(SSerialTxControl, RS485Transmit);
RS485Serial.write(request2, sizeof(request2));
}
}
any suggestions will be welcomed
Thanks in advance