Jump to content

serial link with microcontroller


terence

Recommended Posts

hi guys,

I'm trying to use labview (i'm a newbie to it) to establish a read and write data link to my microcontroller. at the moment i'm just outputting a constant character to com1 from my micro (AVR). i tried using the example that came with labview 7.1 (basic read and write) but i can't even run it. ii've attached the error i received.

ANy ideas?

Thanks

post-4458-1142477517.jpg?width=400

Link to comment

-1073807202 VISA: (Hex 0xBFFF009E) A code library required by VISA could not be located or loaded

It looks like you have not installed the VISA drivers (which will also include the definitons for the VISA error codes I believe - sort of a chicken & egg problem here - you cannot tell that a part is missing without the missing part).

All of these address this same problem in one way or another:

http://forums.ni.com/ni/board/message?boar...=171590#M171590

http://forums.ni.com/ni/board/message?boar...ry.id=0#M165490

http://forums.ni.com/ni/board/message?boar...ry.id=0#M119405

http://forums.ni.com/ni/board/message?boar...ry.id=0#M171528

and eventually, after you get VISA installed, this may be useful as well:

http://forums.ni.com/ni/board/message?boar...=172286#M172286

Link to comment
i've installed the drivers and the program runs for a few seconds before returning an error (see screenshot). i configured the micro to output a constant character 'b'. using tera terminal, i receive the characters correctly. but using labview i get a framing error. any ideas?
A framing error usually results because you are using the wrong baud rate or bits per character or number of bits. It can also occur from noise on the communication link.
Link to comment

I have experience with Microcontrollers and I had similar problems with it, specially the carrige return and line feeds. I programmed my microcontroller to have the carrige return and line feed but it beraly works in LabView, it must be somthing simple that I missed out as well, even though it worked fine in Hyperterminal.

anyway, I have modified you program a little, this design worked for me, it might be the solution for you too.

NOTICE: I have disabled the Carrige return, since that gave me a lot of problems, but with me it worked, even though theoratically to me it doesn't make sense.

P.S You must get the Serial settings correct i.e. the baud rate, parity bit etc. just as WMassey mentioned.

Download File:post-4068-1143025798.vi

Link to comment

The attached VI won't necessarily fix your framing error but it may allow you to read out complete messages from your microcontroller. The "bytes at serial port" function is a good way to tell when a message has started arriving at the serial port and it can even be used to determine when a nearly complete message has arrived (so you can avoid a timeout in the READ function) but the value that the "bytes at serial port" function returns is usually a BAD value to wire into the "byte count" input of the READ function, especially if you are using a read termination character, because the byte count value will limit the read to that number of bytes and no more. What you really want to do is this:

  • define a read termination character
  • enable the read termination character
  • set a reasonable timeout value (higher baud rates = shorter times)
  • periodically check the number of "Bytes at Serial Port"
  • when the number of bytes at port look to be equal to (or slightly less than) the shortest-possible complete message then call the READ function
  • Specify a "byte count" to the read function that is longer than the longest-possible message
  • The READ function will return one complete message (or timeout if the message gets interrupted.)

It works well. Try it.

Download File:post-2800-1143043196.vi

Link to comment

thanks for all your help so far, i'm really appreciative!

i played around with the program and was still receiving some junk instead of just the single character. i added in a delay and flush buffer before the bytes at port and receive the correct information. however this error occurs, and i'm not too sure what it means:

Warning 1073676294 occurred at VISA Read in revised_bertserial2.vi

Possible reason(s):

VISA: (Hex 0x3FFF0006) The number of bytes transferred is equal to the requested input count. More data might be available.

i've attached the modified vi. thx guys

the baud rate im using is 57600

Download File:post-4458-1143084484.vi

Link to comment
i played around with the program and was still receiving some junk instead of just the single character. i added in a delay and flush buffer before the bytes at port and receive the correct information. however this error occurs, and i'm not too sure what it means:

Warning 1073676294 occurred at VISA Read in revised_bertserial2.vi

Possible reason(s):

VISA: (Hex 0x3FFF0006) The number of bytes transferred is equal to the requested input count. More data might be available.

the baud rate im using is 57600

The meaning of the message is that the READ function terminated on byte count (which is set to 999) rather than a termination character (which is set to <LF>, if you did not change the default ). And I'd have to say that if you can, 1) flush the buffer and 2) immediately get another 999 characters from the port, then you have got something wrong with the hardware or are listening to a device that sends continuously. But wait a minute, you did say it was outputting a "b" character over & over again.

Are you seeing a bunch of bbbbbbbbbbbbbbb's?

If it is still gibberish then you still are not using the correct communication parameters or else the microcontroller is not sending out a valid bitstream. You will have to figure out and fix either or both of these before we can help you further I think.

If you are getting a bunch of bbbbbbbbbbbbbb's then I would expect this behavior from the LabVIEW code because it is expecting all valid messages to be terminated with a <LF> character and your controller is never sending one. Modify your controller's program to send a message like Hello<LF> and then retry the VI.

Link to comment
thanks for all your help so far, i'm really appreciative!

i played around with the program and was still receiving some junk instead of just the single character. i added in a delay and flush buffer before the bytes at port and receive the correct information. however this error occurs, and i'm not too sure what it means:

Warning 1073676294 occurred at VISA Read in revised_bertserial2.vi

Possible reason(s):

VISA: (Hex 0x3FFF0006) The number of bytes transferred is equal to the requested input count. More data might be available.

i've attached the modified vi. thx guys

the baud rate im using is 57600

The problem might also arise because after the serial port is init'ed, it can't identify the start bit correctly because of the continuous data stream. Change the program so it replies a finite number of characters after receiving a command. Continuous stream devices are more difficult to interface (they are evil!) because it is harder for both hardware and sofware to synch with the stream.

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.