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)*100; 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
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.
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.
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:
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?
If so then do I then download the Slave Driver and copy the downloaded Modbus folder into the Arduino\libraries folder.
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.
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
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.
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?
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.
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.