FieldPoint Family

cancel
Showing results for 
Search instead for 
Did you mean: 

operate a serial device through cFP-2020

I cannot send or receive serial commands from the RS-232 ports on my cFP-2020 module. I am using LV RT 7.0. As per advice found here in the forums, I've written an embedded vi to create data channels on the cFP unit for writing to and reading from COM1 on the device. A second version, included here, is embedded on the controller and refreshes the data (first question - is this necessary?). The only difference is that it lacks the "create channel" portions that apparently only need to be run once. I have not written a remote program to send and receive commands from a laptop yet, rather I've written directly to the data channels through Meas. & Automation wizard. The wizard states that it is writing the info, but I'
ve got nothing on the other end of the serial cable. The cable itself is jumpered between DTR-DSR and RTS-CTS and communicates through the RXD and TXD lines. I've measured voltage at the RXD and TXD lines directly on the cFP-2020 during transmission, and - no change.
My main question is - how do you communicate through the RS-232 ports on the cFP-232?
Message 1 of 4
(4,191 Views)
You are on the right track, but there are several problems with the code that you have posted.
1) The VISA Resource does not appear to have been given a default value and thus may not be configuring the serial port that you expect. You can make a resource default by right-clicking on the control and choosing Data Operations --> Make Current Value Default.
2) The VISA Configure Serial Port should be outside of the While loop. You do not need to reconfigure the serial port on every iteration of the loop.
3) The VISA Close should be outside the While loop. You will be consuming time and resources by closing the serial port (and opening it) every iteration of the loop.
4) You never actually explicitly create the two published data items. By calling the Publish VI with the names, it will create them if they do not exist, but they may not be the correct type.
5) On the VISA Read function, you wire the value of 0 to the byte count. This means you will read 0 bytes from the serial port and publish a 0 character long string. Use the Bytes at Serial Port Property to determine the current number of bytes in the buffer and retrieve all of them at the same time.
6) You have no timing in the loop and have the both instances of the publish VI having a timeout of 0 (return immediately). To make the VI wait for a command received via the COM1_In item, set the timeout to -1. You may want to wait a small amount of time (e.g. 100 ms) to receive a response from the instrument before reading the serial port, otherwise you may be missing the response until the next iteration of the loop.
7) You always publish data to the COM1_Out even if there was no response. This will clear out the data that was previously published. A better way may be to only update the data if a response is received (Bytes at Port >0). However, if responses of 0 bytes are valid for your setup, leave that portion of the code as is.

I have written a VI that corrects the above problems. I do not have a [c]FP-RT controller available to test it, but it should work fairly well for you. You will need to change and default the serial port to be appropriate for the your controller.

Regards,
Aaron
LabVIEW Champion, CLA, CPI
Message 2 of 4
(4,191 Views)
This vi runs smoothly; thank you. Unfortunately I still can't get communication through the port. We're ready to give up, but I've got a couple of questions first: what is the actual name for the COM ports? They don't show up in measurement and automation explorer, but we've tried COM1, ASRL1, and even switched to the non-VISA serial vis with no success. Secondly, what do dip switches 1 and 2 do? 3-5 are user defined and 6-9 are assigned, but I can find no documentation for 1 and 2.

Any other ideas on how to get this thing to function would be appreciated.

Cheers,
MDF
0 Kudos
Message 3 of 4
(4,191 Views)
The serial ports on an cFP-2020 are COM1, COM2, COM3, and COM4. Try turning the VISA control from a control to a constant. Also, you can try wiring the port using a null-modem cable from the cFP-2020 to your computer and using hyper-terminal.

It may be that the settings (baud rate, flow-control, etc...) are incorrect. I recently had to troubleshoot a serial device that was not working and it turned out that despite the manual saying that it used hardware flow control, it did not.

DIP Switches 1-5 (channels 0 - 4) are user-definable. Only switches 6-8 are pre-defined.

Regards,
Aaron
LabVIEW Champion, CLA, CPI
0 Kudos
Message 4 of 4
(4,191 Views)