Arduino Forum

Using Arduino => Interfacing w/ Software on the Computer => Topic started by: kanurys on Nov 11, 2012, 07:10 pm

Title: Arduino with advancedHMI
Post by: kanurys on Nov 11, 2012, 07:10 pm
Hi guys, I'm toying around with getting my Uno to communicate with advancedHMI on my Windows 7 pc. I'm interested in sending some temperature readings to the HMI which have been processed by the arduino. I know people have done it, but there is no doccumentation out there for a very basic setup. If I figure it out, I'll make a quick write-up to post.

There isn't much info on on google and I'm somewhat of a beginner at programming compared to many of you. How do I get the HMI to read my data on the USB com port from the Arduino?
Title: Re: Arduino with advancedHMI
Post by: PaulS on Nov 11, 2012, 07:46 pm
A link that describes what advancedHMI is would be good. I'm too lazy to do even that little research. If you go that far, I'd be happy to look at whether what you want to do is even possible, and, if so, provide some details as to how.
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 11, 2012, 07:56 pm
Sorry, I should have done that. advancedHMI is a free Human Machine Interface which is compiled with Microsoft Visual Studio Express. On their page they have a quick tutorial to get it up and running easily. I installed VS Express 2012 and have it running great.

http://advancedhmi.com/default.html (http://advancedhmi.com/default.html)

http://www.microsoft.com/visualstudio/eng/downloads#d-express-windows-desktop (http://www.microsoft.com/visualstudio/eng/downloads#d-express-windows-desktop)


I'm not familiar with how to call to com ports in an IDE or windows. And once I can access the correct port, how do I send/receive data on it in VS Express? Is serial communication even possible with the arduino this way?
Title: Re: Arduino with advancedHMI
Post by: PaulS on Nov 11, 2012, 08:16 pm
Quote
Since all VB remains accessible, no need to try to accomplish complex things with a crippled scripting language. This gives the most flexible and expandable HMI software available.


So, take a look at the Playground. There is a section on Interfacing with software. On that page, there are links defining how to interface with a variety of languages, including Visual Basic.
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 11, 2012, 08:36 pm
I might be able to modify the code of each object to interact using Firmata. I like this Firmata interface. It seems really easy to use.
Title: Re: Arduino with advancedHMI
Post by: PaulS on Nov 11, 2012, 09:25 pm
Quote
It seems really easy to use.

Sure, if you like straight-jackets. They've never been my favorite style, though.
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 11, 2012, 09:33 pm

Quote
It seems really easy to use.

Sure, if you like straight-jackets. They've never been my favorite style, though.


Good point. Can anyone point me in a good direction for some VERY basic firmata implementations on visual studio/arduino. Their examples are a little hard to follow from their website.
Title: Re: Arduino with advancedHMI
Post by: rbright on Nov 12, 2012, 01:34 am
So far this excellent product only seems to work with a couple of PLC drivers including Allen Bradley and systems with ModBus protocol.

I've sent an email to 'support@advancedhmi.com' to test the water to see if they have/intend releasing a basic RS232 driver of some form suitable for microcontrollers like PICAXE & Arduino. Let's see how/if they respond otherwise I suppose someone needs to do a PLC driver which is well beyond my ability.

Does anyone see any other options?

Regards
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 12, 2012, 01:42 am
I'm in the same boat. I don't have a ton of skill in programming drivers, etc..

What about arduino to rs485 converter? What does modbus entail?
Title: Re: Arduino with advancedHMI
Post by: rbright on Nov 12, 2012, 02:04 am
Check out this post it has been done to some extent...
http://www.youtube.com/watch?v=iXHfhHFcrCQ

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

Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 12, 2012, 03:37 am
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?
Title: Re: Comments From AdvancedHMI Support
Post by: rbright on Nov 12, 2012, 08:19 am
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
Title: Re: Arduino with advancedHMI
Post by: GWManning on Nov 12, 2012, 09:49 am
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.
Title: Re: Arduino with advancedHMI
Post by: rbright on Nov 12, 2012, 12:47 pm
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 http://code.google.com/p/arduino-modbus-slave/ 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 
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 12, 2012, 03:29 pm
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.
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 12, 2012, 06:03 pm

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)
Title: Re: Arduino with advancedHMI - ModBus
Post by: rbright on Nov 13, 2012, 01:03 pm
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
Title: Re: Arduino with advancedHMI
Post by: GWManning on Nov 14, 2012, 03:07 am
The Modbus library that I used was this one for Modbus over ethernet:
http://code.google.com/p/mudbus/ (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!
Title: Re: Arduino with advancedHMI
Post by: rbright on Nov 14, 2012, 04:47 am
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
https://sites.google.com/site/jpmzometa/

Sounds like I need to order an Ethernet Shield to go further, thanks again GWM
Title: Re: Arduino with advancedHMI
Post by: GWManning on Nov 14, 2012, 07:05 am
Ok I took the quickstart guide from Advanced HMI and modified to be tailored to Arduino communication via Mudbus

https://skydrive.live.com/redir?resid=B585278291D16AA7!183&authkey=!AKZlYO_EiLJ0s38 (https://skydrive.live.com/redir?resid=B585278291D16AA7!183&authkey=!AKZlYO_EiLJ0s38)
Title: Re: Arduino with advancedHMI
Post by: rbright on Nov 14, 2012, 01:13 pm
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

Cheers
Title: Re: Arduino with advancedHMI
Post by: GWManning on Nov 14, 2012, 10:46 pm
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.
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 14, 2012, 11:21 pm
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.
Title: Re: Arduino with advancedHMI
Post by: kanurys on Nov 14, 2012, 11:31 pm
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?
Title: Re: Arduino with advancedHMI
Post by: rbright on Nov 15, 2012, 01:53 am
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.
https://sites.google.com/site/terminalbpp/   

Enjoy
Title: Re: Arduino with advancedHMI
Post by: GWManning on Nov 15, 2012, 02:30 am
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. 
Title: Re: Arduino with advancedHMI
Post by: GWManning on Nov 15, 2012, 02:56 am
!!!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!
Title: Re: Arduino with advancedHMI
Post by: GWManning on Nov 15, 2012, 04:45 am
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.
Title: Re: Arduino with advancedHMI - !!!FACE PALM!!
Post by: rbright on Nov 15, 2012, 09:29 am
!!!FACE PALM!!

So that is what it means - don't you love Google ....
http://en.wikipedia.org/wiki/Facepalm
Title: Re: Arduino with advancedHMI
Post by: firasalfares on Sep 01, 2014, 03:27 pm
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 ?