November 22, 2024, 10:56:27 PM

mod-RS485-ISO

Started by gawnie, January 28, 2015, 02:16:08 PM

Previous topic - Next topic

gawnie

hello,

I am trying use a MOD-rs485-iso with an Arduino and a Modbus Slave simulator on a PC running windows 7.

The setup is shown in the diagram attached. Both the Z-B and Y-A jumpers are connected (closed). 

I cannot get the MOD-rs485-iso board working. I have a linksprite rs485 shield working with the same setup so I know it is neither the Arduino code or the FTDI chip that is causing issue.

Can someone please give me some instruction as to how to get this board up and running? Am I missing an electrical connection etc?

many thanks

DIAGRAM LINK: http://s17.postimg.org/j2epsgdhb/Mod_RS485_ISO_diagram.png

selfbg

Hello, can you post the initialization procedure for the MOD-RS485-ISO?

gawnie

hello Selfbg,

What do you mean by intialisation procedure?


LubOlimex

He meant what were the commands that you send to the RS-485 module? What is the software routine that you perform to make the connection?

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

gawnie

Ok. I am using a SimpleModbus library sketch to write a random integer to regrister 40001:

"
#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 9600
#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 5

#define LED 9

// The total amount of available memory on the master to store data
#define TOTAL_NO_OF_REGISTERS 2

// 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, 0, 1, 1);
  modbus_construct(&packets[PACKET2], 1, PRESET_MULTIPLE_REGISTERS, 1, 1, 0);
 
  // Initialize the Modbus Finite State Machine
  modbus_configure(&Serial2, baud, SERIAL_8N2, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS, regs);
 
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
 
}

void loop()
{
  modbus_update();
 
  regs[0] = random(0,1000); // update data to be written to arduino slave
  Serial.print("Regs output");
  Serial.println(regs[0]);
    Serial.print("Input from PC");
  Serial.println(regs[1]);

}

"




selfbg

Well, I can't see where you enable RX and TX on MOD-RS485-ISO (If you're using MOD-RS485 correct me).
MOD-RS485-ISO need I2C commands to enable read/write channels.

Please check the documentation and examples.