LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a message over serial does not working sometimes

Mark, i definitely agree with the usefulness of modular code. regarding the 'modular' aspect of this vi, by looking at the screen shot that i posted, any suggestions on how can this be made into a more reuseable code? it is a quite simple vi and the problem is that the data which is being sent is different for each of the 20 vi's i was referring to earlier. 

 

 

 

 

Message Edited by USar on 02-22-2010 01:45 PM
0 Kudos
Message 21 of 25
(816 Views)

Hi

 

You can easily create a vi that has exactly the same connector as the visa write vi.

Inside you call visa write in a for loop for each character in the string to write.

 

Then replace all visa write vi's with the new created visa write 1 by 1 vi.

greetings from the Netherlands
Message 22 of 25
(781 Views)

We have developed a GOOP (developed prior to native LVOOP) object that is essentially a wrapper around the VISA VIs. This object allows our applications to easily support multiple interface types without requiring code modification. In addition, we have developed various methods for this object that allow us to specialize our connectivity tasks. We use quite a few polymorphic VIs (methods) which allow us to have a common API for various types of tasks. For example, we have a polymophoric data write method that will accept a string control, a file path or a file reference as input. It also accepts the connection reference. In this manner we use a common API for our code yet we have the flexibility to have the actual task of transmitting the data behave in different ways depending on our particular need. We also provide separate read and write timeout attributes on our objects. VISA only provides a single timeout value.

 

With your specific code I would eliminate the port initialization everytime you send data. This should be done once in the beginning and not called for every write.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 23 of 25
(777 Views)

so it seems like sending the data char by char seems to work so far. *fingers crossed*

 

attached is the screen shot of the vi i had created to do this. i created a vi for the data which is going to be common amongst all vi's and use that as a sub vi for the highlevel vi's. also, the sub vi write..vi writes to the port char by char.

0 Kudos
Message 24 of 25
(765 Views)
I would create a generic subVI that accepts a string control as input and then send that out character by character in a loop. You can convert the string to a byte array and feed into a FOR loop. Using a generalized approach you can easily reuse it for all of your various messages.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 25 of 25
(761 Views)