Jump to content

serial


pjsaczek

Recommended Posts

Hi all, i'm realy sorry for only asking, and never answering questions. I'm still learning! and yes, I have looked through the archives

I'm trying to control and take data from a hounsfield testing machine through serial. I'm using the basic serial write and read VI. I'm able to control the machine through hyperterminal, but when using labview, sending the same strings results in nothing. i've done loopback tests with the labview VI which prove the port works, and labview is comunicating with it. I've even sent strings through labview through a serial wire to another computer with hyperterminal open with no problem. anyone have any ideas why I can't do it through labview at the moment? any help is greatly apreciated!!

Link to comment

Hello,

Have you tried this example that ships with LabVIEW, see attached.

Make sure you COM settings are correct (i.e. baud rate etc) .

I would also verfy you don't need to pull up one of the handshaking lines this would be found in your instrument documentation.

If your device is not seeing your commands try a different carrage return constant after the text you want to send. I notice in the example I posted a carriage return is not concatenated after the text. Sometimes the instrument nees a carrage return to recognize the commands. LabVIEW has end of line, carrage return, and line feed constant. Sometimes it doesn't matter what you put to send text. Sometimes your instrument will only recognize one. For example end of line works, plain carrage return doesn't.

In general that is all I can help with right now. If you could post your code that might help.

Thanks

Dan

Link to comment
QUOTE(ASTDan @ Sep 10 2007, 02:56 PM)
Hello,Have you tried this example that ships with LabVIEW, see attached.Make sure you COM settings are correct (i.e. baud rate etc) . I would also verfy you don't need to pull up one of the handshaking lines this would be found in your instrument documentation.If your device is not seeing your commands try a different carrage return constant after the text you want to send. I notice in the example I posted a carriage return is not concatenated after the text. Sometimes the instrument nees a carrage return to recognize the commands. LabVIEW has end of line, carrage return, and line feed constant. Sometimes it doesn't matter what you put to send text. Sometimes your instrument will only recognize one. For example end of line works, plain carrage return doesn't.In general that is all I can help with right now. If you could post your code that might help.ThanksDan
thanks alot, in the instructions it says the command has to be ended with <CR>. so for example, for it to read off the current position of the tester, and the force on the load cell, type RB<CR>. is the basic serial VI putting some more characters on the end? or do I need to add something to the end?cheers, pete oh, and the instrument doesn't do handshaking cheers!
Link to comment

Try Concatating a cariage return on the output text as shown. Sorry for my terriable spelling.

QUOTE(pjsaczek @ Sep 10 2007, 11:52 AM)

thanks alot, in the instructions it says the command has to be ended with <CR>. so for example, for it to read off the current position of the tester, and the force on the load cell, type RB<CR>. is the basic serial VI putting some more characters on the end? or do I need to add something to the end?cheers, pete oh, and the instrument doesn't do handshaking cheers!
Link to comment

QUOTE(pjsaczek @ Sep 10 2007, 10:52 AM)

thanks alot, in the instructions it says the command has to be ended with <CR>. so for example, for it to read off the current position of the tester, and the force on the load cell, type RB<CR>. is the basic serial VI putting some more characters on the end? or do I need to add something to the end?cheers, pete oh, and the instrument doesn't do handshaking cheers!

No LabVIEW is not adding anything to the strings on its own and I would be really mad if it would. However if you use VISA in a more recent version (let's say less than 5 years old or so) you can configure it to do that for a serial session automatically for you. But personally I find that not such a good idea. I prefer to code each command in such a way to append the correct end of string indication explicitedly.

Rolf Kalbermatter

Link to comment

QUOTE(pjsaczek @ Sep 12 2007, 04:47 AM)

so, if this is a common problem, does that mean there is a solution?

As indicated already, if you talk to a serial device always add explicitedly the end of message character for that device to the command or if you want to be more dependant on a specific VISA feature set the "Serial Settings->End Mode for Writes" property for that VISA session to "End Char" and make sure you also set the "Serial Settings->End Mode for Reads" property and the "Message Based Settings->Termination Character" property accordingly as well as the "Message Based Settings->Termination Character Enable" to True. As already said it could have problems with older VISA versions (really old) and I find it better to explicitedly append the correct termination character myself to each message.

Also note that since about VISA 3.0 or so the default for serial VISA sessions for "Serial Settings->End Mode for Reads" is already "End Char" and the "Message Based Settings->Termination Character" property is set to the <CR> ASCI character as well as the "Message Based Settings->Termination Character Enable" is set to true. However "Serial Settings->End Mode for Writes" property is set to "None" for quite good reasons as it does modify what one sends out and that can be very bad in certain situations.

LabVIEW as general purpose programming environment shouldn't do that for you automatically since there are many somewhat more esoteric devices out there that use another termination character or mode then appending a <CR> character or <LF><CR> character sequence.

Rolf Kalbermatter

Link to comment

thanks alot for all the help! it's working now.... ending with <CR> worked on hyperterminal, but in labview I needed to add the Cariage_Return to the end of the strings I was writing........ rookie error!

now i'm just wondering how to arrange my program. it has to basicaly start the machine running, then take readings of the force etc, then stop the machine. I'm thinking sequence structures are the way to go?

cheers again,

pete

Link to comment

I would recomend a State machine archture over a sequence structure. In LabVIEW when you select New go to State Machine template. You can also type in State Machine on NI's website to find some good info on this versitile archtecure.

sorry for my bad spelling its late

Dan

QUOTE(pjsaczek @ Sep 13 2007, 08:48 AM)

thanks alot for all the help! it's working now.... ending with <CR> worked on hyperterminal, but in labview I needed to add the Cariage_Return to the end of the strings I was writing........ rookie error!

now i'm just wondering how to arrange my program. it has to basicaly start the machine running, then take readings of the force etc, then stop the machine. I'm thinking sequence structures are the way to go?

cheers again,

pete

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.