Pages: 1 [2]   Go Down
Author Topic: Arduino with advancedHMI  (Read 8419 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
« Last Edit: November 12, 2012, 12:07:37 pm by kanurys » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Jacksonville, AR
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Jacksonville, AR
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Jacksonville, AR
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nice posting and research, guys. This might be the excuse I was waiting for to get an Ethernet shield smiley. 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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Jacksonville, AR
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 
Logged

Jacksonville, AR
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

!!!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!
Logged

Jacksonville, AR
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 82
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

!!!FACE PALM!!

So that is what it means - don't you love Google ....
http://en.wikipedia.org/wiki/Facepalm
Logged

Pages: 1 [2]   Go Up
Jump to: