Go Down

Topic: Arduino with advancedHMI (Read 39256 times) previous topic - next topic


Nov 12, 2012, 06:03 pm Last Edit: Nov 12, 2012, 06:07 pm by kanurys Reason: 1

I was able to get it to work using the Mudbus.h library and the AdvancedHMI Modbus driver. Just remember when the sketch refers to Mb.R[0] that means the Modbus PLC address is 40001.

Would you be so kind as to post a link to your arduino sketch (or sample code) and advancedHMI solution? I really need something working to study.

Also, how do you get VB all setup to talk to the com port that the arduino is on? (COM4 in my case)


While we all wait for further guidance from GWManning :
Under topic area "Networking, Protocols, and Devices" of this forum a post today may be of help as we delve into modbus

MAX 485 & ModbusMaster - Basic Guide


Problem with such an active forum like this is there are so many topic areas with info happening.



The Modbus library that I used was this one for Modbus over ethernet:

This does require the use of the Ethernet shield.

I used the "Mb" sketch in the example that came with the Mudbus library.

Avoid using pins 4,10,11,12,and 13 when using the Ethernet shield

Modbus has a weird addressing scheme. It stores values in memory locations referred to as registers. These registers are designated in the example as "Mb.R[0], Mb.R[1]" and so on.

// Section of Code from Example Sketch
Mb.R[0] = analogRead(A0); //pin A0 to Mb.R[0]

Here, a value will be read from the analog pin A0 and stored in Register 0

To access register zero in Advanced HMI the PLC address is 40001
To access register one the address would be 40002 and so on.

I hope this helps!


Thanks GWManning, I kept on thinking "mudbus" was a typo until I tried the link.

kanurys (& others) I also found some further Modbus interfacing info in following site

Sounds like I need to order an Ethernet Shield to go further, thanks again GWM


Ok I took the quickstart guide from Advanced HMI and modified to be tailored to Arduino communication via Mudbus



Thanks GWM for your excellent document

Before I place an order would you know if there would be any problem with a WizNet W5100 chip
e.g.  http://dx.com/p/ethernet-shield-with-wiznet-w5100-ethernet-chip-tf-slot-118061?item=2



I am using the Arduino branded Ethernet shield and it uses the same Wiznet w5100, I will guess that the other shield will work the same.


Nice posting and research, guys. This might be the excuse I was waiting for to get an Ethernet shield :). As for now, I'm sucking on good ol' processing and serial communication for my HMI. I'll give that excellet guide a try as soon as I get a shield. Thanks for contributing this. I'm sure it will benefit many people.


I know you're going to hate me for asking, but what about going the other direction - click a button in advancedHMI and have it do something on a digital pin on the Arduino?


kanurys I've just ordered following from Hong Kong for less than US$10   I will expect take 3 weeks to get to me in Western Australia

We (and others watching) are both on the same learning curve but in response to your question above re HMI graphically comanding the Arduino outputs I feel once you get the first stage of Arduino working to say your local home router and presenting data on a basic web page by addressing an IP address a lot of the next stage using HMI will become evident.

I'm expecting my first Arduino in the post any day so of course connecting to an external serial port through a level converter chip (say MAX232) is the first task to master. To that end I've downloaded the "brey terminal" from another topic on this forum from retrolefty and this is the best terminal program I've seen which allows me to serially connect 2 PCs with one PC using the terminal program to respond to predefined strings with another string
e.g. PC1 sends "Are you there PC2"   to which PC2 responds "Yes I am"   Great tool to diagnoise serial connections. Program even has a graphing capability on incoming serial data. Go to following post.



I have not been able to get reliable results controlling the digital pins as of yet. I have managed to turn on a led via the HMI, but cannot turn it back off.  I'm sure its a simple setting somewhere but I am not having any luck so far.  Mb.C[8] in the sketch is at PLC address 00009. If I create a button to toggle bit and tell it that PLC address it will turn it on but will not toggle back off. 



Figured it out.  Mb.C[8] is either true or false. So the button for ON needs to be "set to true" and the button for OFF needs to be "set to false"

then in code it will look like this:

if(Mb.C[8]) digitalWrite(8,HIGH) ;
   else digitalWrite(8,LOW) ;

That did the trick!


There seems to be a communication problem I need to sort out. I can either read an analog value or control pushbuttons. If I try both the analog display takes up the bandwidth and the pushbutton signals get lost.

I'm guessing maybe a timer on the analog so that it only pulls a reading once every few seconds may work.



So that is what it means - don't you love Google ....


thanx a lot for your all replies
also i need have one of HMI and want to connect it to my project of medical machine. (instead of keyboard and display)
so i think it is very difficult to do that with arduino unless i use a special protocol please any help ?

Go Up