New Modbusmq project: Testers needed!

I am having the same issue.
Works with 018, but can't even ping the IP when using 021.

Sure would be nice to find a fix for this.

I think there is a problem with calling

Client client = server.available();

as a global

so change that line to

Client client = 0;

please tell me if this helps
for me it seams to fix the problem

It works with:

Client client = 0;

But now I have the same problem with the DEBUG flag. It has to be disabled because if it is enables the Arduino hangs.

hgs75 do you get it working with debug flag?

No i also couldn't get it to work with the DEBUG flag set.
but i thought it was because i used it with conjunction with i2c
so i just disabled DEBUG and moved on

Thanks, changing to "Client client = 0; " worked.

On another note: Is anyone using a simple web interface with Modbusmq, to configure IP, Gateway etc...?

Or have a suggestion as to how to get both Server, Client and different ports working together?

this is a beginning of IP changer over Ethernet but i didn't manage to implement it fully in to the Modbus code
(i have managed to get it to work only by a switch at the beginning of the program before the loop)

#include <EEPROM.h>

#include <SPI.h>


#include <Ethernet.h>
#include <Wire.h>

#define maxLength 100

int stringtoint(String &s);

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 177 };
String inString = "";
int val;
Server server(80);

void setup()
{
  
    int DO_RESET_ETH_SHIELD = 8;
    pinMode(DO_RESET_ETH_SHIELD, OUTPUT);      // sets the digital pin as output
  digitalWrite(DO_RESET_ETH_SHIELD, LOW);
  delay(1000);  //for ethernet chip to reset
  digitalWrite(DO_RESET_ETH_SHIELD, HIGH);
  delay(1000);  //for ethernet chip to reset
  
  
  if ((EEPROM.read(1) != 0) && (EEPROM.read(1) != 0xFF)){
    
  ip[0] = EEPROM.read(1);
  ip[1] = EEPROM.read(2);
  ip[2] = EEPROM.read(3);
  ip[3] = EEPROM.read(4);
  
  }
  
  delay(100);
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);
  //BlinkM_beginWithPower();  
  //BlinkM_stopScript( blinkm_addr );  
}
void loop()
{
  
  
  
  
  int IP1=ip[0];
  int IP2=ip[1];
  int IP3=ip[2];
  int IP4=ip[3];
  
  
  
  Client client = server.available();
  if (client) {
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        if (inString.length() < maxLength) {
          inString += c;
         }        
         
         
        if (c == '\n' && current_line_is_blank) {

          if (inString.indexOf("?")>0){
          
           int IP1p = inString.indexOf("IP1");
           int IP2p = inString.indexOf("IP2");
           int IP3p = inString.indexOf("IP3");
           int IP4p = inString.indexOf("IP4");
           int End = inString.indexOf("H");
           
           String IP1S = inString.substring((IP1p+4), (IP2p-1));
           String IP2S = inString.substring((IP2p+4), (IP3p-1));
           String IP3S = inString.substring((IP3p+4), (IP4p-1));
           String IP4S = inString.substring((IP4p+4), (End-1));
           
            IP1 = stringtoint(IP1S);
            IP2 = stringtoint(IP2S);
            IP3 = stringtoint(IP3S);
            IP4 = stringtoint(IP4S);
           
           EEPROM.write(1, IP1);
           EEPROM.write(2, IP2);
           EEPROM.write(3, IP3);
           EEPROM.write(4, IP4);
           
           /*
           Serial.print(IP1);
           Serial.print(".");
           Serial.print(IP2);
           Serial.print(".");
           Serial.print(IP3);
           Serial.print(".");
           Serial.print(IP4);
           */
           /*
           int IP1 = atoi(IP1S.toCharArray());
           int IP2 = atoi(IP2S.toCharArray());
           int IP3 = atoi(IP3S.toCharArray());
           int IP4 = atoi(IP4S.toCharArray());
           
           
           
           
           
           Serial.println(IP1+"."+IP2+"."+IP3+"."+IP4);
            
            */
            
          }
          
          
          
          /*
          if (inString.contains("?")) {
           int Pos_r = inString.indexOf("r");
           int Pos_g = inString.indexOf("g");
           int Pos_b = inString.indexOf("b");
           int End = inString.indexOf("H");
           r = atoi(inString.substring((Pos_r+2), (Pos_g-1)));
           g = atoi(inString.substring((Pos_g+2), (Pos_b-1)));
           b = atoi(inString.substring((Pos_b+2), (End-1)));  
           BlinkM_fadeToRGB( blinkm_addr, r, g, b );
         }
          */
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          client.println("<html><head></head><body>");
          client.println("<h1>Network Settings</h1>");
          client.println("<h3>Saved IP is:  ");
          client.print(IP1);
          client.print(".");
          client.print(IP2);
          client.print(".");
          client.print(IP3);
          client.print(".");
          client.print(IP4);
          client.println("</h3>");
          client.println("<form method=get>IP:.......<input type=text size=2 name=IP1 MAXLENGTH=3><input type=text size=2 name=IP2 MAXLENGTH=3><input type=text size=2 name=IP3 MAXLENGTH=3><input type=text size=2 name=IP4 MAXLENGTH=3>&nbsp;
");      
          //client.println("<form method=get>Subnet:<input type=text size=2 name=S1 MAXLENGTH=3><input type=text size=2 name=S2 MAXLENGTH=3><input type=text size=2 name=S3 MAXLENGTH=3><input type=text size=2 name=S4 MAXLENGTH=3>&nbsp;
");  
          client.println("<input type=submit value=submit></body></html>");
          break;
        }
        if (c == '\n') {
          current_line_is_blank = true;
        } else if (c != '\r') {
          current_line_is_blank = false;
        }
      }
    }
    delay(1);
    inString = "";
    client.stop();
  }
}
 
 
 
 int stringtoint(String &s){
            int n;
           char carray[4];
           s.toCharArray(carray, sizeof(carray));
           n = atoi(carray);
           return(n);
 }

Posted by: chris.moe Posted on: 20.10.2010 at 19:06:02
It works with:

Client client = 0;

But now I have the same problem with the DEBUG flag. It has to be disabled because if it is enables the Arduino hangs.

hgs75 do you get it working with debug flag?

Yes, it works with the debug flag, but now I am using an arduino FIO and a WIZ812, use this diagram to make the conections:
http://www.pjrc.com/teensy/td_libs_Ethernet.html
The code works fine, I am testing with modscan32, and I still working with the 0018 IDE. :smiley:

I am trying to use this with IDE 21 and Arduino uno. I have integrated it with the remarks earlier posted, but I can not get it to work. Ping does not work.

When I use another ethernet example it seems to work.

What could be wrong. Could someone post his file that works with IDE21.

Thanks

Can you post your code please

Is there a way to add an attachment without using the code insert. The code is rather big as you know Using the code insert would make it unreadable.

I dont think so

Here is the link (To be clear this is not my code all the credits go the maker(s) of it)

http://rapidshare.com/files/428138539/modbusmq.rar

you are not using the latest revision of the modbus code or you are missing a lot of parts from it

try downloading it again and only change to

Client client = 0;

in the beginning of the file

OK it works. I was working with an older version like you said.

Thanks :slight_smile:

Just curious if anyone has implemented modbusmq using the WiFi 2.0 shield?

If so what changes would be required?

There are a number of issues with this library before I even get started. If the IP has a 0 in the middle (192.168.0.xx) it, the strncpy causes a mal-formed IP. I have changed them to memcpy.

There is no reference to the subnet mask in the IP configuration. This too needs rectification.

Now on to making the rest of the library work.

Thanks
David

the library seems to work, as i could test it with modpoll, but i'm struggling since too weeks to find a guide or sample code to map the I/O or even to read or write registers, please for anyone who succeeded to implement it to post his code to guide us

Well finally i figured it out, i'm not a programmer so i'n not sure if this is the right way to do it, but here is my code may it help somebody
in this code
PWM pins 3,5,6,9 are mapped to Holding register 40001-4
Analogue pins 0-5 are mapped as input registers 30001-6
Digital pins 2,4 are mapped as input status 10001-2
Digital pins 7,8,13 are mapped as coil status 00001-2

NB. arduino couldn't handle 2 concurrent tcp connections

I have been testing the library and everything seems to work for what I use it.

Changing SPI communication speed with WIZ5100
If I understood everything well, then this should be the function tto be used. "setClockDivider(uint08 rate)"

Does anybody know where in the program I should write this function to change the SPI communication speed with the WIZ5100? I have tried some places like in setup and I do not see any noticable difference with my modbuspoll software.