Arduino - MODBUS - Lib. problem.

I have started working with Arduino Due, in programming of MODBUS facing problem. Code are as below & attached the Lib. file attached used in this project.

// code below.

Basic.pde - example using ModbusMaster library

This file is part of ModbusMaster.

ModbusMaster is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ModbusMaster is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with ModbusMaster. If not, see Licenses - GNU Project - Free Software Foundation.

Written by Doc Walker (Rx)
Copyright © 2009-2013 Doc Walker

*/

#include

// instantiate ModbusMaster object as slave ID 2
// defaults to serial port 0 since no port was specified
ModbusMaster node(2);

void setup()
{
// initialize Modbus communication baud rate
node.begin(19200);
}

void loop()
{
static uint32_t i;
uint8_t j, result;
uint16_t data[6];

i++;

// set word 0 of TX buffer to least-significant word of counter (bits 15…0)
node.setTransmitBuffer(0, lowWord(i));

// set word 1 of TX buffer to most-significant word of counter (bits 31…16)
node.setTransmitBuffer(1, highWord(i));

// slave: write TX buffer to (2) 16-bit registers starting at register 0
result = node.writeMultipleRegisters(0, 2);

// slave: read (6) 16-bit registers starting at register 2 to RX buffer
result = node.readHoldingRegisters(2, 6);

// do something with data if read is successful
if (result == node.ku8MBSuccess)
{
for (j = 0; j < 6; j++)
{
data[j] = node.getResponseBuffer(j);
}
}
}
// code end.

facing problem, message as under.

Arduino: 1.5.6-r2 (Windows 8), Board: “Arduino Due (Programming Port)”

Basic.pde:25: fatal error: ModbusMaster.h: No such file or directory
compilation terminated.

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

Modbus library.zip (203 KB)

First of all, i would like to remind you that you should always use the CODE tags (# sign up there on the menu buttons) when posting your code.

A question for you. Did you write this code yourself or did you copy it from somewhere?
I see right on the beginning something strange with your comments. Just before you start the big comment you use

// code below.

but i think you should be using

/* code below.

I also don’t see you adding the library. You have the #include command:

#include

…but there is the library missing, something like

#include <ModbusMaster.h>

dvj215:
This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

Yes it would. So why don’t you turn the verbose on and shows us that output. It is quite helpful to find out what the problems are…
:wink:

Good luck with your project!
=)

Thanks for your quick response, I am new to Arduino platform,

Find the error message with verbose,
Arduino: 1.5.6-r2 (Windows 8), Board: “Arduino Due (Programming Port)”

Build options changed, rebuilding all

D:\Aurdino\Software\arduino-1.5.6-r2/hardware/tools/g++arm_none_eabi/bin/arm-none-eabi-g++ -c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=156 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E_ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER=“Unknown” -DUSB_PRODUCT=“Arduino Due” -ID:\Aurdino\Software\arduino-1.5.6-r2\hardware\arduino\sam\system/libsam -ID:\Aurdino\Software\arduino-1.5.6-r2\hardware\arduino\sam\system/CMSIS/CMSIS/Include/ -ID:\Aurdino\Software\arduino-1.5.6-r2\hardware\arduino\sam\system/CMSIS/Device/ATMEL/ -ID:\Aurdino\Software\arduino-1.5.6-r2\hardware\arduino\sam\cores\arduino -ID:\Aurdino\Software\arduino-1.5.6-r2\hardware\arduino\sam\variants\arduino_due_x C:\Users\admin\AppData\Local\Temp\build5798579608417303669.tmp\Basic.cpp -o C:\Users\admin\AppData\Local\Temp\build5798579608417303669.tmp\Basic.cpp.o

Basic.pde:25: fatal error: ModbusMaster.h: No such file or directory
compilation terminated.

Find the copy of the program attached.

MODBUS.ino (1.77 KB)

Basic.pde:25: fatal error: ModbusMaster.h: No such file or directory

Is there some part of that message that you don't understand?

I have already add the MODBUS library, also check in library folder the file exit. Still got this error message. Can you check / compile with DUE board?

Hi dvj215,

I am testing your code with Arduino Due which you mentioned is working on another thread.

http://forum.arduino.cc/index.php?PHPSESSID=oei2l9a6p832hun0itcsgkcbd5&action=dlattach;topic=176142.0;attach=84184

I check the signals with oscilloscope, the Tx and Rx signals on arduino can be seen, however, there is no signal on the Modbus line when the arduino responses. I found that the enable signal which is connected to arduino pin-2 is always low, how do I change that?

Thank you very much.