LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Max to configure a serial port

Solved!
Go to solution

Hello,

 

   I have inherited some code that configure the serial port using the old serial code that does not allow the user to specify the term char and enable the term char. Any ideas on how this is done with the older serial code? I have also tried to use MAX to set the term char and enable it, I am able to communicate with my serial device with Max and I have saved the changes when I was done. So when I fire up the Labview code, my serial code fails because the term char is wrong and it is also not enabled.

  Any ideas what is going on with how the term char and term enables are set?

Regards,


Kaspar
0 Kudos
Message 1 of 24
(4,165 Views)
Solution
Accepted by Kaspar

What you do in MAX as far as the serial port configuration has no bearing on the LabVIEW program. (EDIT: Meaning that you can change the configuration in the LabVIEW code.)

 

If you load the old code in a version of LabVIEW that uses VISA for all the serial stuff then the VIs would have been automatically replaced by the shell VIs that NI created for old code. Inside they just use VISA. More than likely the old code use port numbers via numeric controls. For example, in the <LabVIEW>\vi.lib\Instr\serial.llb library you'll see these shell VIs. The "Serial Port Write" for instance, calls the "Open Serial Driver" VI that just returns a VISA session. It then uses VISA Write. Thus, you can set the termination characters by getting the VISA resource from "Open Serial Driver".

 

Of course, the best solution is to rewrite the code using VISA directly. It will be much cleaner. Smiley Wink

Message Edited by smercurio_fc on 04-13-2010 04:57 PM
0 Kudos
Message 2 of 24
(4,160 Views)

Hello,

 

  Thanks for getting back to me. I will have to look thru the code until I find where the term chars are set, which is not contained in the vi to init the serial port.

Regards,


Kaspar
0 Kudos
Message 3 of 24
(4,131 Views)

Hello,

 

   I have spent some time looking at the code that I have inherited and as far as the serial communications is concerned there are 4 Sub-Vi's that are used

 

  1. Serial Port Init
  2. Serial Port Write
  3. Bytes at Serial Port
  4. Serial Port Read

  The "Bytes at Serial Port" is used to determine the number of bytes in the input buffer and then it is passed to"Serial Port Read", so it looks like the whole concept of termination chars does not apply to this code. So the next step in this saga is to understand why the code does not work in the development environment but it does work in the runtime environment. I am using Labview 7.1.

  Does anyone have any ideas?

Regards,


Kaspar
0 Kudos
Message 4 of 24
(4,112 Views)
Define "does not work".
0 Kudos
Message 5 of 24
(4,106 Views)

Hello,

 

  "does not work" is defined at the Serial Port init return a warning of 37 that means device not found. But yet hyperterminal can communictae with the device.

Regards,


Kaspar
0 Kudos
Message 6 of 24
(4,102 Views)
Does the serial port show up in MAX under Devices and Interfaces  /  Serial & Parallel?
0 Kudos
Message 7 of 24
(4,100 Views)
Yes the port shows up in Max and I can use Max to talk to the device
Regards,


Kaspar
0 Kudos
Message 8 of 24
(4,094 Views)

Then LabVIEW ought to be able to use it just fine.  Are you sure that the port is selected properly either in a VISA I/O control or constant?

 

Maybe it's time to post your VI so we can see if anything looks wrong.

Message Edited by Ravens Fan on 04-14-2010 02:17 PM
0 Kudos
Message 9 of 24
(4,089 Views)

Kaspar wrote:

Hello,

 

  "does not work" is defined at the Serial Port init return a warning of 37 that means device not found. But yet hyperterminal can communictae with the device.


You said it's a warning. What do you mean by that? If you follow NI's convention, that only applies to error clusters in which the status Boolean is set to False, but the code is non-zero. The Serial Port Init only returns an error code, so it must be an error.

 

Are you sure you're referring to the correct port? 0 = COM1, 1 = COM2, etc. 

Have you made sure that no other programs are running that are actively using the port?

Are you running on Linux? You need permission to access the serial ports in Linux.

 

I still think it would simply be easier for you to replace the functions using the standard VIs.

0 Kudos
Message 10 of 24
(4,086 Views)