How to send commands from pc to ADAM-4520

arran

Member
Join Date
Sep 2015
Location
UK
Posts
53
Hi ,

I working on a project to send data using VB to ADAM-4520 (RS-232 to RS-422/RS-485 isolated converter). So far I have checked on the internet and couldn't find help on how to do this. Would someone be kind enough and provide me some link to websites that you know might help me understand the basic of how I can talk to it from VB. Any help is really appreciated.

Thank you
 
My project is for Dispensing chemicals

I will be communicating to:

SY3220-5L image below:

021-561-1.jpg


and to ITV2030-312BS3 with a image below:

mqotS51osEKnVaQ4Luzi-1w.jpg


So overall, I will be using VB to determine the amount of chemical to add accurately.

Hope this helps.
 
Last edited:
There must be another device in between. The ADAM-4520 is an RS-232 to 485 converter, but the 2 devices you listed require a 24V signal and an analog signal to control.
 
VB has a .COM model for serial communication. You need to reference that object model. It will depend on your version of VB. Once you've got a reference to the proper object model the handling of the serial port is relatively easy and there are tons of examples on the internet.

Good luck,

Yosi
 
The other components I have are:

CDUK16-200
thumbnail.php


Adam 4024
adam-4024-10.jpg


And I installed Adam-4500 Series Utility

This is all I have. If there's anything else you think I might need please let me know
 
I did some research on the coding aspect of it. This involved creating object and opening the communication channel, etc.

The link to the page is http://downloadt.advantech.com/ProductFile/Downloadfile3/GF-1HAUW/Using%20Basic%20Script%20in%20ADAMView%20to%20Open%20a%20COMport%20to%20Send%20ASCII%20Commands.pdf.

I understand most of the code however the part DIM CommandTag AS TAG, I don't get what TAG supports to be. Not sure if I need to import something into the code apart from the MSCommLib. Maybe you understand what they are trying to do here.


Also the OUTPUTS 0,MyComm.Input, when written in VB changes to OUTPUTS (0,MyComm.Input). So it's taking that as a subroutine. This means it's changing the original meaning. Would have an idea why this is line not recognized.

Thank you for the help in advance
 
Last edited:
The ADAM-4024 can be controlled using ADAM ASCII or Modbus/RTU protocols. I would recommend setting up the module to use Modbus and use a modbus driver otherwise you will have to write the code to send the ADAM ASCII commands to the serial port. Appendix G in the user manual gives the Modbus addresses to use. For example 40001 controls the value of channel 1

Another option that would be the fastest route would be to use AdvancedHMI. It has a ModbusRTU driver. Here are a few quick steps to get started:

- Download and extract AdvancedHMI
- Open the solution in Visual Studio
- Build the solution
- Open the MainForm
- Add the driver to the form, then set your com port, baud rate, etc.
- Add a BasicLabel to the form and set PLCAddressValue property to 40001
- Set PLCAddressKeypad property to 40001
- Run the application and click on the BasicLabel to enter a new value
 
Thank you Sir for that. I will have a look into this and try it out and see how it goes.
 
I just have two question, when you say click on the BasicLabel to enter a new value.
I will writing this value to the channel 1.
Sorry for asking, but it's just I'm new to this.
So using the method you described above I will be able to communicate to the Adam module but the value that I would be adding. How do I know what it will do? Is there a data book that tells what the value sent is doing.

I had a look at the Adam-4520 and Adam-4024 on the Advantech website (this is where it was ordered from), there's not mention that it supports Modbus/RTU protocol. However, other modules mention it is supported. I assume as you gave me info about advanced HMI that it will support both these ADAM modules. I'm I right to say this?

Thank You for the help in advance
 
Last edited:
Thank you very much for the pdf document. It really helped me a lot in understanding how the module would link up.

I continued reading the document up to the coding part (24-27).
I started to code using the instruction using that.

I had a bit of problem with the code. So chr$(13), gave an error so I changed this to Convert.ToChar(13) to change that.
Buffer$ gives an error as "Type character ' $' does not match declared data type 'Double'. I researched this in the internet and found $ means it's a string type variable. So I understand that buffer$ needs to be declared. So to remove the buffer$ I declared it has Dim buffer$ = "". Now I don't know what it needs to assigned to. At the moment it's " ". Do you know the specific string it needs to be assigned to?

Plus, I added another error writing this line MSComm1.CommPort = 1, so what I did was to create an object as:
Dim MyComm As MSComm = CreateObject("MSCOMMLib.MSComm"). Than I replaced every MSComm with MYComm. Not sure if this is correct haven't tried it out. Just waiting for your help with buffer$ = ? .


If it’s not too much to ask, apart from the document that I listed before for coding, do you know of any other documents that may provide me with other examples. I have tried to research the internet but had no luck so far.

Thank you
 
Last edited:
Offered without comment because I didn't write it.

Code:
Private Sub btnReceive_Click()
txtReply.Text = MSComm1.Input
End Sub

Private Sub btnSend_Click()
OutCom = txtCommand.Text
MSComm1.Output = OutCom + vbCr
End Sub

Private Sub UserForm_Initialize()
On Error GoTo 10
    MSComm1.InBufferSize = 16384
    MSComm1.InputMode = comInputModeText
    MSComm1.OutBufferSize = 16384
    MSComm1.CommPort = 1
    MSComm1.PortOpen = True
    MSComm1.Settings = "9600,N,8,1"
10: lblMessage.Caption = Error
End Sub
 

Similar Topics

Hi Guys, Got an interesting question, has anybody tried to use a PLC to re-configure a router? I have done so using SNMP (relatively...
Replies
4
Views
1,578
Hello: Just posted a similar inquiry with regards to Rockwell HART master. Trying to figure out whether the Siemens offering is better. I need to...
Replies
14
Views
4,767
https://literature.rockwellautomation.com/idc/groups/literature/documents/um/1794-um063_-en-p.pdf Hello. Trying to figure out if it would be...
Replies
1
Views
1,798
What is the best way to send multiple serial ASCII commands from a Compactlogix PLC to another piece of equipment? The issue is that the equipment...
Replies
2
Views
1,792
Hi all. I want to print QR codes from a Beckhoff PLC and I am considering to purchase the ZD42oT zebra printer. I have never used ZPL commands...
Replies
0
Views
1,503
Back
Top Bottom