I want to control a motor and am using an inverter, ATV312 from Schneider. Arduinowise, I am using my good old UNO and a RS485 board with a MAX485 on it. The module is like this one:
So the Schneider manual describes the 2 pins D0 and D1 (A and B on my case) being on the RJ45 plug on the inverter and also says there is a modbus common pin. This module doesn't have any common pin so I have connected just A and B. Also the inverter doesn't have any ground pin anywhere so I can connect it to the Arduino ground.
I am using the SimpleModbusMaster library and I am sending correct packages (I sniff them with a USB-RS485 device I have) but the Inverter won't start. I also tried to read a register like higher output frequency but it will not respond.
For example the message bytes to read multiple registers (I just need one) is:
01 03 02 58 00 01 04 61
SlaveID 1, Function 3, 0x0258 is the address of the register, 0x0001 is one register I need to read and 0x6104 are the CRC16 bytes.
So the message is ok. On the inverter, baud rate etc are all correct and the Fr1,Fr2 and Cd1,Cd2 functions are set to Modbus.
It seems like the message is not getting to the Inverter, I checked the cable and it is ok, I also tried a 150Ohm resistor on my module between A and B, no luck.
Common is probably another name for ground in this context.
It seems like the message is not getting to the Inverter, I checked the cable and it is ok, I also tried a 150Ohm resistor on my module between A and B, no luck.
Your module already is terminated (by a 120Ω resistor) so you must not add another one.
So the message is ok. On the inverter, baud rate etc are all correct and the Fr1,Fr2 and Cd1,Cd2 functions are set to Modbus.
Standard Modbus data format is 8E1, it's also the default on the Schneider inverter. Do you have you serial configured accordingly? Post your complete code (don't forget code tags, that's the </> button in the editor)!
Thank you very much for your reply. Yes I have tried both 8N1 and 8E1 but no response from the inverter.
Please have a look at the code (requesting value of 0x0258 register)
#include <SimpleModbusMaster.h>
/*
The example will use packet1 to read a register from address 0 (the adc ch0 value)
from the arduino slave (id=1). It will then use this value to adjust the brightness
of an led on pin 9 using PWM.
It will then use packet2 to write a register (its own adc ch0 value) to address 1
on the arduino slave (id=1) adjusting the brightness of an led on pin 9 using PWM.
*/
//////////////////// Port information ///////////////////
#define baud 19200
#define timeout 1000
#define polling 200 // the scan rate
#define retry_count 10
// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2
// The total amount of available memory on the master to store data
#define TOTAL_NO_OF_REGISTERS 1
unsigned int readRegs[1];
unsigned int x;
// This is the easiest way to create new packets
// Add as many as you want. TOTAL_NO_OF_PACKETS
// is automatically updated.
enum
{
PACKET1,
//PACKET2,
TOTAL_NO_OF_PACKETS // leave this last entry
};
// Create an array of Packets to be configured
Packet packets[TOTAL_NO_OF_PACKETS];
// Masters register array
unsigned int regs[TOTAL_NO_OF_REGISTERS];
void setup()
{
// Initialize each packet
modbus_construct(&packets[PACKET1], 1, READ_HOLDING_REGISTERS, 0x0258, 1, readRegs);
// Initialize the Modbus Finite State Machine
modbus_configure(&Serial, baud, SERIAL_8E1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
}
void loop()
{
modbus_update();
x=readRegs[0];
}
I also grounded the common signal wire from the inverter to the arduino ground, still no luck..
Plus, I forgot to mention that when I set on menu CTL->Fr1->nDB(modbus) I get an SLF flashing error. I thought that was not permanent but then I realized that when I go to LOCAL mode then when I return to that menu, the inverter changes that to A11.. Then I have to change to nDB(Modbus) and I get the SLF error..
Just to clarify, this code WORKS! It was my mistake, I swapped A and B and it worked. I had triple checked the connection of the RJ45 but the manual with the "view from underneath" note pinout is really confusing.
Now I have some other issues with the use of the library but that's for a different topic.