Arduino with advancedHMI

Check out this post it has been done to some extent...

Following is part of the uploaders comments from a year ago (Read posts below in reverse order...............

Is very simple, send u the value of the ADC's serial Arduino, and read the value in visual stdio, use the advanced HMI project? components in source forge.

Arlindo Astyzem 9 months ago
hello, thank you for comment, was simple! I send a string and read the form. example for arduino : ======================== float temp void setup(){ Serial.begin(9600);} void loop(){ temp = (analogRead(0)*0.004887586)*10­0; Serial.print(temp); Serial.print(";"); Serial.print(mini); Serial.write(10); Serial.write(13);} on VB you can use something like: dim rx as string rx =? serialport1.readline inside of a timer you will put: gauge1.value = rx if you have doubts, I am available.

Arlindo Astyzem 1 year ago

hallo any chance for a example of turning on and? off output on this microcontroller thx in advance

grunftz 2 years ago

I saw that. It is nice of the OP to put some code in there. I was a little confused by the "Serial.write(10); Serial.write(13);" commands and the term "mini".

gauge1.value = rx: can this be done with advancedHMI? It seems like it wants to point to some ethernet or serial connection and then a plc ram location for the value, not internally.

Is it really as easy as a few lines of code?

As per a previous post, I have been communication with AdvancedHMI Support Team, gave them the link to our forum post and they responded as follows:

"I read the forum posts and I see the last question was whether the controls could be written to directly. The answer to that is yes. If you add a control and removed the value from the CommDriver property, you can then set the Value property in code.

Essentially the component request values from the drivers to fill in the properties with values. It is not necessary to do it that way."

end of quote - Nice to see such a pro-active support team.

Regards all

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.

GWManning great to hear of your success.
As there seems to be no complete examples or tutorials specifically on how to set this up and especially for a newbee like myself I have a couple of questions as follows which will also help others following this topic:

  1. I've found the site Google Code Archive - Long-term storage for Google Code Project Hosting. and also found slave mode driver code. A related site has the ModBus Master as well.
    My question is to get Arduino working with AdvanceHMI should I set up the Arduino as a ModBus Slave which will then be connected to the PC serial bus (e.g. Com1) even through a USB/232 adapter?

  2. If so then do I then download the Slave Driver and copy the downloaded Modbus folder into the Arduino\libraries folder.

  3. Could you upload an example for all to see or even do a YouTube tutorial. Hope I'm not asking too much as I'm sure there is others like myself who would like the guidance.

Thanks in antisipation

Thank you all for your input. This is excellent info for a noob like myself.

Yes, an example of how to do this would be like gold. My weakness is in the PC side and modifying the visual studio express components.

GWManning:
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

http://arduino.cc/forum/index.php/topic,132177.0.html

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

Enjoy

The Modbus library that I used was this one for Modbus over ethernet:
http://code.google.com/p/mudbus/

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. Recommendations For You - DealeXtreme

Cheers

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
http://www.ebay.com.au/itm/170892514760?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1438.l2649

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.

Enjoy

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.

!!!FACE PALM!!

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.

!!!FACE PALM!!

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