LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial communication with cRIO RS232

Solved!
Go to solution

My goal here is to use the NI9870 in my cRIO9030 to drive an applied motions motor (STM23Q-3AE), which can be controlled using a serial communication language (SCL). I have a labview VI (attached) that I am able to drive the motor from when connected to my computer's COM port; however, I have been unsucessful running the motor when connected to the NI9870. I am using an S8 Serial Cable (10Pos Modular Plug to DB-9) to connect the motor to the ethernet port. I am not sure how to use SCL without visa write, so I attempted to run the cRIO in scan mode, but was unsucessful with my current VI. Please let me know what you think I am doing wrong or if there is another way to approach this. Also let me know if you need any more info. Thanks for the help!

0 Kudos
Message 1 of 29
(7,124 Views)

It would help if you attached your project file as well.  Actually, it would be best to just zip up the entire project and post that.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 29
(7,093 Views)

I used the "Using the NI 987x Modules in Scan Mode" KowledgeBase Support documents to set this file up, but other than that all I really have in my project file is the VI. Please let me know if there is anything else

0 Kudos
Message 3 of 29
(7,087 Views)

I was not able to look at your code because I'm avoiding versions of LabVIEW newer than 2015 (I still need to support older Windows systems and 2016 breaks that ability) but I have attached some code that I built a couple of years back to send serial commands out through 9870 modules located both in the cRIO's backplane and in an attached EtherCAT backplane. In my application, the video devices that were receiving the commands didn't have much to say so the communicattions was pretty-much one way (out) but this at least will give you one example of how the comminucation might be accomplished.

0 Kudos
Message 4 of 29
(7,016 Views)

Thanks for that code. I was able to get everything that you used running, but was unable to get my motor running. I'm guessing it may have something to due with the string to binary function and what is eventually sent to the 9870. I was able to run the motor using commands: VE10↵AC100↵DE100↵DI20000↵FL↵ in using SCL Utility or the pictured visa code when attached to my computers com port. However, I am still having trouble sending commands from the host to cRIO to operate the motor.

0 Kudos
Message 5 of 29
(6,992 Views)

Have you configured the 9870 for the correct RS-232 settings? Right-click on the module in the project and select properties and adjust as needed.  As an example, the settings I use here for my hardware are in the attached image. Have you got the cable correctly configured between the 9870 and your device? Transmit connects to receive, ground-to-ground and handshaking is connected (or looped or open) as needed. Here I'm using an NI-9949 breakout block along with the special 10-conductor shielded RJ50 cable to expose the conductors I need to complete the cable.

 

 

0 Kudos
Message 6 of 29
(6,985 Views)

Yes I believe my settings are correct, actually the same as what you posted. I pulled these setting directly from my computer's com port as I can get the motor to run from that. I am actually unsure on the cable though. I purchased the NI S8 Serial Cable (10Pos Modular Plug to DB-9), but I only attached the com to com and ethernet to ethernet. Is this something I can check. I have also been playing around with some example files for the 987x Serial loopback DMA, also to no success.

0 Kudos
Message 7 of 29
(6,976 Views)

I have a breakout box with LEDs that lets me see which side is transmitting but that does not do you any good. If you have a null modem you can insert between the devices and if having it there fixes the problem, then there's your answer. You can also try connecting the 9870 to the COM port on your PC and using the PC to check to see that the correct data is coming across from the 9870.  (this was easier under XP when HyperTerm still was easy to find and use but perhaps you can use your SCL code or your LabVIEW COM interface. FWIW HyperTerm can be made to work under later versions of the OS).

0 Kudos
Message 8 of 29
(6,971 Views)

Great suggestions, I'm purchasing a led breakout connector and a null modem to check/fix everything on the hardware side. I will update once I check everything. Do you know what I should be looking for in terms of the channels that light up?

0 Kudos
Message 9 of 29
(6,962 Views)

On my breakout box the LED labels are referenced to one connector/side of the box (for the other side, the labels like Transmit & Receive would need to be swapped to make sense). Anyway, I plug it in-line and send some characters across the link and look to see if the transmit or receive LED is flashing, while the characters are passing (dropping the baud rate can help see this).

 

I looked to see if NI said how the S8 cable was constructed (as DTE or DCE) but they neglected to include this information with the part's description. If it has a female (with sockets) DB9 connector (I cannot tell from the description; again an NI oversight) then I suspect it is a DCE connection so as to be compliant with the RS-232 specification and a null model would not normally be required. If it is a male (with pins) DB9 connector, then it should be a DTE connection and a null modem should be required. 

 

Looking at the STM23Q-3AE motor manual it says "Your drive was shipped with a communication cable. Plug the large end into the serial port of your PC and the small end into the RS-232 jack (RJ-11 connector) on your drive." Since most PC's with serial ports get this DTE/DCE thing correct and have male DB9s configured as DTE ports I suspect the cable supplied with the drive is configured as a DCE (modem) device. As such, it should work (at the hardware interface level) with the 9870 if the S8 cable is indeed a DTE connection.

 

These are the few NI links I was able to turn up regarding these connections. Note that none of them actually say anything about how the S8 cable is actually wired.

http://forums.ni.com/ni/board/crawl_message?board.id=140&message.id=18715

What Is the Pin-out If I Want to Convert an RJ50 Serial Connector to DB9 or DB25?

 

 

0 Kudos
Message 10 of 29
(6,949 Views)