LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Driver for Advantech DIO Module

Hello. Thank you for your time to read on my post. I would appreciate for any advise, hint or any improvement to my VI.
I am evaluating an Advantech ADAM-4055 DIO module. I want to create a LabVIEW driver which the maker do not have at the moment.
The module is connected to my PC via the RS-485 Serial Port. The makers Users Manual lists all the possible commands syntax to
communicate to the module. The ADAM-4055 DIO module has 8 inputs and 8 outputs.
I created a sample VI, as attached, which is not yet complete. The DI do not seems to work yet and I can't figure out yet how will i make
the DO indications.
I will send a command or syntax on the VISA Write function based on the Command Syntax of DIO Module. That command I expect will give
me both Input and Output status information. Using VISA Read function I will be able to see the status of all inputs and outputs via front panel in forms
of LED or switches.

Can anyone please help me correct my driver. Thank you very much.
0 Kudos
Message 1 of 29
(5,368 Views)
There are a couple comments:

First, always, alway, always connect up your error clusters. Many people seem to only think about error handling (if they think about it at all) after the initial debug is done. I don't know how many times I have helped people with mysterious problems that they couldn't locate, only to discover that one subvi or another was telling them exactly what was wrong but they couldn't see it because errors weren't being reported. (BTW: as a side note 90% of all instances of LV "locking up" can be traced to the same cause)

Second, rather than programming a VISA timeout and requiring the user to enter the number of bytes to read, I have typically found it more satisfying to handle the timeout my self and let the serial port tell me how many bytes it's received - and then read them. The problem is that if you get the count wrong you will never see anything coming back from the device. See attachment...

Third, the primary goal of the VI you posted should be implementing a basic IO routine for talking to that instrument. The next layer up in the code can worry about what commands to send and how to parse the results. The idea here is to be able to type examples from the documentation into the VI and read back what the manual says you're supposed to get.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 29
(5,348 Views)

Hi Mike,

Thank you for your generous reply and advises. I am now using your sample VI and talk to the instrument using the list of commands describe in their manual. But you know I am not getting any feedback from the sensor. I changed the wait time inside the sequence structure and timeout, and the same time monitor the bytes at port. The bytes at port is "zero" thus i just get error "code 42" everytime. If i am getting zero bytes at port, does this mean there is something wrong with my command syntax?

To double check my port, I opened the Utility software from the maker, and I can see that port communication is ok.

Thanks.

0 Kudos
Message 3 of 29
(5,307 Views)
It would tend to point at command syntax or some setup parameter that is different between the LV app and their utility. One thing to check is the line terminator. On Windows, LV inserts a line-feed into the character stream when you press the "Return" key. If the device is expecting a carriage-return that could be the problem right there.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 4 of 29
(5,289 Views)
Hi Mike,
 
Thanks a lot. The VI is now working fine. I went back to the Users Manual and i realized that i missed and got confused
with the Delimeter characters ($,#,%) which are being type first on the syntax and the Termination character, \r. Thanks a lot
for all the advise.
If you dont mind, i have one more additional question;
I have this DIO (digital input/output) in my network, and I will have an AI (analog input) too in the SAME network. The same network
means there is only one Resource (Com1). How can i connect or wire them correctly in the block diagram so they will both
output data simultaneously ?
Thanks again!
0 Kudos
Message 5 of 29
(5,267 Views)
Typically RS232 is strictly a point-to-point connection. However, there are multidrop serial protocols such as RS485. Devices that support this standard have an extra layer of protocol that supports an address. Advantech and DGH (who make similar devices) both make modules that support this type of operation.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 6 of 29
(5,261 Views)
I am actually using an Advantech products and via RS485. Hardware wirings I have them set-up already but on the software side (LV) I do not know how to make the wiring connections yet to get the modules data simultaneously.
I have tried the attached but i am not getting simultaneous output data.
 
------------------------------------------------------------------------
Typically RS232 is strictly a point-to-point connection. However, there are multidrop serial protocols such as RS485. Devices that support this standard have an extra layer of protocol that supports an address. Advantech and DGH (who make similar devices) both make modules that support this type of operation
------------------------------------------------------------------------
0 Kudos
Message 7 of 29
(5,257 Views)
With RS485 the modules are designed to be attached in parallel or daisy chained. But remember that you will not get them to respond truly in parallel because you only have one serial port. Hence even if you wire the writes in parallel in your application, LV will recognize the resource dependency and serialize the port write operations. If the access need to be truly parallel, you need to use two ports.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 29
(5,253 Views)

Hello Mike,

Sorry for the delay in my reply. I tried to get the AI and DIO data simultaneously using one network (for the sake of curiosity) like the one i attached but it was not successful. I can get data but its not a steady data, sometimes i will get AI or DIO but sometimes its not. Its like randomly taking of data. I have asked this because i want to make sure since I got this message from the Advantech that it is possible, but am still waiting for their detail information.

Anyway, thanks a lot for your kind information.

0 Kudos
Message 9 of 29
(5,199 Views)
Hello Bong,
as Mike already pointed out, you definitely cannot access modules in parallel through a RS485, because the receive wires (i mean receive for your computer) are shared among all modules. if the commands are sent in a semi-random way, there is no mechanism to prevent the modules to write to the serial line simultaneously; this would produce an unmeaningful signal on the computer side. You need to complete a send-receive session before issuing another command.
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 10 of 29
(5,198 Views)