Jump to content

Serial drivers


Recommended Posts

Hi,

I just started working on LabVIEW. I am trying to communicate with a shutter controller through serial ports. I can't find the driver I needed for this particular controller in the Instrument Library provided by NI. And I can't find anything that helps me to start writing a driver. Is there a site, book, or anything that will show me how to start writing a driver for a serial port?

Thanks,

Nan

Link to comment

Hi

here what you should try to find out.

1) Contact the manufacture that made your shutter controller to find out if they have labview driver and/or a command manual

2) Pending they do not have one (driver and are not wiling to give you the command manual), they certainly provide you with an application (non labview) that can control your hardware. From there there are two approaches

2.a) If the application they provide accept command line parameters (quite rare) then you can pass these parameter from labview

2.b) If the application does not accept command line parameters, Download the free portmon from http://www.sysinternals.com/ntw2k/freeware/portmon.shtml and observe (spy) what command are passed from the application that come with your hardware so you can then used them later from labview to control your hardware.

PJM

Link to comment

Thanks for your reply. I think you got ahead of me:) I am still trying to figure out how to start writing a driver using the Instrument I/O in the LabView. I don't understand the concepts very well about communicating to the controller with the PC.

Is there a book or some kind of source where I can go and learn to write a driver? I know I will need to have the ASCII codes of the serial port and the commands, but before that, where/how do I start writing the driver? It seems very complicated, with the initializing, writing, reading, and closing functions. And it is really frustrating that I havn't got anything day for the last few days just trying to figure out how to write the driver. I am glad I found this site and you! Do you know any sort of source where I can find step-by-step tutorial to show me how to use the the serical functions listed under Instrument I/O in LabVIEW?

Thanks,

Nan

P.S. Anybody live around Morgantown, WV? Maybe we can have a small meeting or something to solve things more quickly:)

Link to comment

I typed in a whole lot of stuff for you, but in the process thougt of something.

You can look at the serial communication examples in LabVIEW (HELP >> EXAMPLES) to get an idea of how to do it. It's relatively easy once you get the hang of it.

You'll need to know the port configuration required by the device you're talking to. (i.e. baud rate, parity, stop/data bits, etc) for the configuration.

Link to comment

Bryan is right - examples are a great way of learning this stuff.

here are some really basic concepts:

- use the VISA "Open" function to open a connection to your serial port

- use a VISA Property Node to set perameters such as your baud rate

- use the VISA "Write" function to send commands to you instrument

- use the VISA "Read" function to read results back from your instrument

- use the VISA "Close" function to release your serial port

attached is a REALLY simple example

you will find the devil is in the details, but if you can find some documentation is should help. You really need to find out what commands to send to the instruments, and in what format to send them. Also you will need to find out what to expect back from the instrument.

To make 'drivers' out of all this, you would wrap each of the VISA functions in you own custom VI's that automatically issue the correct commends etc.

hope this helps get you started!

John H.

post-21-1086639080.png?width=400

Link to comment

EXACTLY what John said.

You can also use the "VISA Bytes at Serial Port" VI (basically a property node) to see exactly how many bytes worth of data reside at the port waiting to be read if you're not sure how many bytes to expect. (Located in the Serial, palette).

Wire the output of that to your byte count input on your "VISA READ" and it will read in exactly the number of bytes that are waiting.

If you're proficient enough at LabVIEW, you can also use state machines, aka "action engines" to do all of your functionality using just one VI. This can get messy though if things aren't kept organized from the beginning. I normally try to do my drivers this way if they're not too involved.

Link to comment

Hi Nan

All the previous suggestions are quite helpful. Controlling the serial ports is like a never-ending trial & error experiment. Timing is everything. Since it is the most common device interface around, it is very useful to get to know how it works.

I wrote a LV driver for an antenna rotator control box recently (for a project) and it came with its own set of control app. I needed to have this box controlled by LV and the distributor did not have one. But I did get the format of the commands. This is important since serial commands can in ASCII or binary format (you have to find out).

To find out how the control app was communicating with the box, I created a "loopback" line on a regular DB-9 cable into a spare port (I had a USB-to-4 RS232 port converter since my PC only has one serial port).

The purpose of this cable is to monitor the communication of the app and the box without interfering. You would then use a terminal program (Hyperterm, Procomm, etc) to monitor that port. You can also get this from an elex dealer (I got one from Fry's Elex called an RS-232 Break-Out-Box for $29) that can do the same. But if you already have spare cables around, preferably the unsealed type, you can solder the TD of the main cable to the RD of the monitor line, and vice-versa. The Signal GND (pin 5) needs to be connected also. For the lines to be uninturrupted, a regular diode (I used 1/8 watt) should be on each of the TD & RD lines.

I played with the serial port parameters until I found the correct baud rate, parity, #bits, etc.

Then you can use the built-in Visa serial functions to send/receive your ASCII or binary-formatted commands.

Enjoy!

:thumbup:

winmac96

Link to comment
  • 4 years later...

CITATION(Michael_Aivaliotis @ Jun 9 2004, 12:28 AM)

Hello,

For start i'm sorry for my english who's very bad but....

I 've a big problème with my serial modem communication.

I try to communicate with a serial modem to open a tcp ip connection.

I receive the distant response modem (with AT commands)who say ("CONNECT 9600")...It's funny but...;I' havn't TPC/Ip connection!!!!

My question is: How can i log labview on the distant modem ?(Back of of this modem there is an DHCP / FTP serveur)

Please help me , there is 4 four day that i search in unanswered world .

I want create a automatic remote connection who start and stop when i want

If anyone can help me just a little beat...

Thanks

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.