LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using File I/O to manipulate compact DAQ module terminals

Solved!
Go to solution

Hello, 

 

I am currently brain storming the structure of my VI for testing my motor controller drive for an individual project. 

 

I was wondering whether it is possible to manipulate the terminals of the compact DAQ using File I/O function. I wasn't sure what type of commands and function blocks are required to achieve this?

 

The reason I wish to use File I/O functions is to avoid creating a large GUI design which may end up becoming too large to deal with. The motor controller has an RS232 port which I wish to communicate with and will use LabVIEW to work with non standard protocols. LabVIEW probably needs to work at a fairly low level and the LabVIEW program will have to construct/deconstruct the messages.

 

The ability to send and receive individual serial bytes is really required in my testing (in matlab there are functions serial/fwrite and serial/fread to do this but I’m not sure if LabVIEW has the equivalent functions).

 

LabVIEW really needs to emulate a PC COM port which will manipulate the motor controllers functionality.

 

Would appreciate any links or examples that can give me an idea of how to build the code as well as any specific commands that LabVIEW needs to achieve what is described above. 

 

Many Thanks

0 Kudos
Message 1 of 6
(3,222 Views)

The CompactDAQ modules are controlled using the NI-DAQmx API. File IO has absolutely nothing to do with this. While simulating an RS-232 port with digital IO is theoretically possible it is a pretty complicated and cumbersome way to go about this. Not to mention slow!!

 

Your description about wanting to emulate a serial port also poses even more questions. What do you really want to do? What has Matlabs serial/fread/fwrite with CompactDAQ to do??

 

From what I know about Matlab (which admittedly is not a lot) this is most similar to the NI-VISA programming interface which you use in the NI world to interface to GPIB, TCP/IP, Serial Port and to some degree USB devices.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 6
(3,212 Views)

Hi Rolf, 

 

The motor controller is designed to connect to a PC serial 'COM' port using a 'virtual COM port driver' so that parameter information can be exchanged using ASCII COMMS. 

 

The serial byte format is standard – 1 start bit, 8 data bits, 1 stop bit. The user can select 9 different baud rates from 300 to 57600.

 

The question is what functions/processes are going to enable me to achieve this in LabVIEW without having to design such a large block diagram?

 

0 Kudos
Message 3 of 6
(3,208 Views)
Solution
Accepted by topic author neunited

Hi neunited,

 

all you need to do is to plugin your USB (?) cable into your PC, it should automatically create a new COM port.

With LabVIEW you can communicate over that port using VISA functions.

See the "Basic serial Read and Write" example VI, but don't get used to the BytesAtPort function too much…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(3,205 Views)

Hi GerdW, 

 

Thanks very much for your response. 

 

Is it possible for VISA functions to work alongside DAQmx in a simulation simultaneously and are they easy to integrate with each other? 

 

My only concern is that VISA functions blocks may have compatibility issues with DAQmx functions? The cDAQ and motor controller RS232 must work together at the same time during the simulation run. I just want to ensure that I am not crossing any wrong paths before they actually happen. 

 

Hope that makes sense. 

 

Many Thanks

0 Kudos
Message 5 of 6
(3,197 Views)
Solution
Accepted by topic author neunited

VISA and DAQmx function calls work happily alongside each other as long as you do not create dependencies between the two yourself. Learn what dataflow means in LabVIEW. This is the most important defining operation how functions will work either in parallel or sequentially after each other.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 6
(3,191 Views)