Jump to content

USB/Serial device


Recommended Posts

thank you rubo

i still cant do the communications between the two computers.

My device is instaled on COM4 and I put the resource as ASRL4::INSTR and I also tried as COM1 but I cant receive or send anything.

Somebody know where can I see a different example from the ones tha LabView have? or somebody can tell me which is the algorithm to do the communication?

I really need help

Thank you to all

Link to comment

The first thing to do is to check that the cable connections are correct. The intrument may require a null modem cable (where the transmit and receive pins (2,3) are reversed) or it might (rarley) do the crossover for you and require a straight through cable instead. Next check the pinout for the cable matches that for the instrument, especially if the instrument is D25 type connector, say and your PC com port is D9 type of connector.

The next things to try are changing the baud rate, parity, stop bits, etc to match that specified in the instrument documentation. Then start playing with the comms handshaking. Again, this should be specified in the instrument's documentation. If your instrument still doesn't communicate perhaps you need to enable communications from within the instrument's setup menu. Note that most LV examples use simple defaults for the serial comms setups (ie 9600, 8, N , 1, with no handshaking [9600=baudrate,8=databits,N=noparity,1=stopbits]) and so need tweaking to match the instrument. Note, it is sometimes easier to play with these settings with a program such as hyperterminal until you work out the correct parameters. Alternatively try the Serial Driver from ICON Technologies

Serial communications are broken up into several different types depending on the instrument. From a programmers point of view and in most cases, instruments are either a transmit receive type or a receive only type. (A third case is a full OSI model of ACK and NACK with error handling. Thankfully most instruments don't use this!)

- Transmit Receive: These instruments require sending of a command, waiting some time and receiving a response. For example you might have to send FREQ?\r\n to the instrument and it would respond with 2.345HZ\r\n.

- Receive Only: At intervals (either timed or in response to some stimulus at the instrument) data is spat down the serial line to the PC. For example, every second 2.345HZ\r\n arrives on the serial line.

The next most important aspect is the termination character. Most instruments use the \r\n pair of characters to indicate that the transmission has ended. So in the serial reader you would specify to read until these characters are matched (and you need to set a timeout long enough for the instrument to respond). Under VISA you can specify \n as the terminating character and this will work for the majority of applications (ie those that transmit in ASCII).

By now you should be seeing something in your LV program (or hyperterminal). Lastly you need to consider how the data is formatted. Many instruments communicate in ASCII (eg 2.345HZ\r\n) but others send their data as a stream of bytes (ie 00 01 02 03 04) all of which are unreadable and need to be decoded before the number can be returned. Encoding (transmit/receive type comms) and decoding information will be detailed in the intrument manual. As a last few examples, I could send the same number "5" either in ASCII (readable) form "5" or as the byte value of 05 (unreadable as in x05) and I could send the letter "A" either in ASCII form "A" or as the byte equivalent x41.

Confused? Don't rule out that someone has not already written a driver for the instrument you want to talk to. Check out the FAQ for a list of places to look for instrument drivers.

cheers, Alex.

Link to comment

Thank you for the explanation. The problem is that I always get the error code -1073807202

My project consist in serial comunication between 2 computers, and I cant do that!!!!

Maybe its the type of usb serial cable that Im using because when I connect the pin number 2 and 3 to transmit and receive myself the same error appears.

I would try to get some other cable.

PD.- Sorry for my english :oops:

Link to comment
im using the labview 7 student version and i also have the 6i version.

2509[/snapback]

Re-installing the software might work. If you haven't installed VISA into your 6i installation then it might be a matter of un-installing the VISA driver (from both 7 and 6i) and installing it again.

Is the 6i version student also? I seem to remember that the student versions used to be limited (eg cannot do DAQ, cannot do active X, cannot do ..., etc). I would check with NI whether the student version allows you to do VISA comms at all.

cheers, Alex.

Link to comment

Also, sort of already mentioned by aledain, did you confirm that your serial port works with Hyperterminal. This is always a good first test. If that doesn't even work, then clearly you have a hardware problem. If that works, you might have to check you LV installation (and/or VISA). With LV6i, you might be able to use some serial communications that does not use VISA, but the "older" serpdrv driver. This could maybe be easier for testing purposes since you don't need VISA.

With LV6i, check the vi's in the LLB: vi.lib\instr\serial.llb

(note that com1 is port 0. So com4 is port 3).

Hope this helps,

Oskar

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.