LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA serial not working right in Windows 7

Okay, I chaged around my code so it now reads one character at a time and concatenates the characters into a string and stops as soon as it sees the terminating character (<LF>).  Once again...works great on the XP computer, no go on the Win 7.  I placed probes in the XP computer's execution and it worked great.  The while loop would iterate the exact number of characters that came in the response.  But not a peep from Win 7.

 

Kathryn, I tried changing the "byte count" in the read statement to a value larger than it would ever see, and that didn't work in XP or Win7.

 

I've attached my code for all to look at.  Please let me know what I'm missing here!

 

 

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 21 of 32
(1,037 Views)

@spaceman_spif wrote:

Okay, I chaged around my code so it now reads one character at a time and concatenates the characters into a string and stops as soon as it sees the terminating character (<LF>).  Once again...works great on the XP computer, no go on the Win 7.  I placed probes in the XP computer's execution and it worked great.  The while loop would iterate the exact number of characters that came in the response.  But not a peep from Win 7.

 

Kathryn, I tried changing the "byte count" in the read statement to a value larger than it would ever see, and that didn't work in XP or Win7.

 

I've attached my code for all to look at.  Please let me know what I'm missing here!

 

 


Ugh, this should be a no-brainer.  Have you tried cutting the communication code out and running it by itself?  Frankly, from the structure seen in the first picture, I suspect there are very bad practices being used in other parts of the VI.  Unfortunately, I cannot open your file.  If you know there is a termination character, you can reduce your whole communications loop to three or 4 nodes and dispense with the loop entirely.

 

Sometimes serial communications can be a PITA, but this looks VERY straightforward.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 22 of 32
(1,025 Views)

@billko wrote:

 

Ugh, this should be a no-brainer.  Have you tried cutting the communication code out and running it by itself?  Frankly, from the structure seen in the first picture, I suspect there are very bad practices being used in other parts of the VI.  Unfortunately, I cannot open your file.  If you know there is a termination character, you can reduce your whole communications loop to three or 4 nodes and dispense with the loop entirely.

 

Sometimes serial communications can be a PITA, but this looks VERY straightforward.


What exactly do you mean by cutting out the communication code and running it by itself?

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 23 of 32
(1,022 Views)

I've attached a JPG of my code for you to see.  The only thing you can't see is off to the left where I set up the COM port settings.

 

 ETA:  You also can't see that this sequence is nestled inside a while loop that runs continuously.

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 24 of 32
(1,020 Views)

I hate saying this, but the code in the picture represents a misunderstanding of THE LabVIEW fundamental concerning dataflow.  I would really recommend looking over the various tutorials here and then probably think of rewriting all your code to date.  I'm sorry that on the surface it sounds mean and discouraging, but I believe you could do better by orders of magnitude and everything would make a lot more sense.  I have to believe that many of the hitches you are seeing will probably disappear with better LabVIEW practices.

 

As for cutting out the communications part, either copy and paste the relevant code into another VI or slect the appropriate VIs and make a subVI out of it.  Sometimes it's a lot easier to run just a small part of your code instead of trying to diagnose the problem by running the whole thing.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 25 of 32
(1,006 Views)

I tried a different version of my code, this time with wait timers placed right after the write and read commands.  I made them variable in steps of 50 ms, and I tried running it with delays of 0 ms, 50 ms, 100 ms, 200, etc all the way up to 2 full seconds.  Nothing.  But works great in XP.

 

billko, if you think my code sucks, that's fine.  But I would appreciate it if you would at least take the time to tell me exactly why it sucks rather than just make blanket, disparaging comments and offer little else.  And honestly your comment confused me because my code is rather simple, and if it's so fundamentally flawed, it would never work, yet it does perfectly fine on my computer.  It's just four sequences repeated over and over.  First, I write out a query, next I clear my read buffer, then I read the response one character at a time until I see the terminating character, and finally I extract the relevant info and display it.  When that's done, I move on to another query.  After I read the last query, I loop back and start over.

 

(I'm still not so sure it isn't a driver issue, as we're now seeing other issues with these laptops running programs that use the USB ports.  One program uses the USB as a virtual COM port, and I had to install special drivers for that to run properly under Windows 7 (XP was pnp).  I'm thinking the conflict might reside there, even though that program does not run while this LV program does.  The strange thing is Win7 would correctly identify the device as a USB-to-serial device whenever I would connect it, and it worked fine every day for over a week.  But as of yesterday, when the device is connected, Windows now thinks it's a USB mouse and it won't communicate.)

********************************************
Amateur programmer for over 10 years!
********************************************
0 Kudos
Message 26 of 32
(983 Views)

@spaceman_spif wrote:

I tried a different version of my code, this time with wait timers placed right after the write and read commands.  I made them variable in steps of 50 ms, and I tried running it with delays of 0 ms, 50 ms, 100 ms, 200, etc all the way up to 2 full seconds.  Nothing.  But works great in XP.

 

billko, if you think my code sucks, that's fine.  But I would appreciate it if you would at least take the time to tell me exactly why it sucks rather than just make blanket, disparaging comments and offer little else.  And honestly your comment confused me because my code is rather simple, and if it's so fundamentally flawed, it would never work, yet it does perfectly fine on my computer.  It's just four sequences repeated over and over.  First, I write out a query, next I clear my read buffer, then I read the response one character at a time until I see the terminating character, and finally I extract the relevant info and display it.  When that's done, I move on to another query.  After I read the last query, I loop back and start over.

 

(I'm still not so sure it isn't a driver issue, as we're now seeing other issues with these laptops running programs that use the USB ports.  One program uses the USB as a virtual COM port, and I had to install special drivers for that to run properly under Windows 7 (XP was pnp).  I'm thinking the conflict might reside there, even though that program does not run while this LV program does.  The strange thing is Win7 would correctly identify the device as a USB-to-serial device whenever I would connect it, and it worked fine every day for over a week.  But as of yesterday, when the device is connected, Windows now thinks it's a USB mouse and it won't communicate.)


That something appears to work doesn't mean it was done correctly.  I could rebuild an engine and not paid anttention to the timing gear positions, overtightened some bolts, while leaving others too loose.  I could've not paid attention to vavle lash.  It might even run like that, but it would be pure luck that it did, and maybe it's struggling up those hills because the timing is way off.  And I told you EXACTLY what was wrong with the code that I saw.  You do not understand data flow, otherwise you wouldn't have any of the sequence structures that you have and also you would have connected the string outputs directly to the indicators.  That alone tells me that you should really check out all the tutorials online because you are misunderstanding THE basic LabVIEW concept.  That alone leads to so many other misuderstandings that I couldn't possiby list them all here, but that I suspect would be inherant to your code, given the apparent misconceptions present in the picture.  Please, do yourself a favor, check out the tutorials - and LabVIEW examples also - and you'll figure out what I mean.  I'm not trying to be mean, but I just don't know how else to put it.

 

You said it was sometimes trying to identify itself as a USB COM port, so I'm thinking that maybe your USB-to-serial adapter is configured to the same COM port that your app is trying to use?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 27 of 32
(967 Views)

 

 

I don't know if this is gonna help ya spaceman but what kind of errors are you getting when it does not work?

 

ALso can you place a 20 or 30 ms wait function in each loop so that you at least can have a chance to see the response when it goes bad.

 

You need to be polling for any characters in a loop by itself first so that you can test whats coming intop the buffer on your win7 PC.

 

You need to read  from the property the "num of bytes in serial port " (Sorry I don't have LV on this PC) and then see what happens when

it stops giving you characters.

 

IF it is a win7 thing than it is probably due to how win7 accesses the UART and then places charaqcters in the visa buffer, however what was said earlier

applies. I would not assume in my code that there are any characters waiting to be read just because there is a read function waiting for them.

 

Instead use the bytes at serial port to let labVIEW tell you what is there.

 

This is especially true with devices that misbehave like your device apparently does. Query the bytes received at serial port property to get a closer look at what is happening in your case.

Hope this helps and good luck with it.

 

 

 

 

 

0 Kudos
Message 28 of 32
(966 Views)

The code style isn't good. It's usual in ANY language to put any reuseable code into a function (or in lv a subVI) - so here all you have is a different command being dealt with in exactly the same way every time. The use of sequence structures is discouraged, and a lot of the frames in that jpeg are unnecessary as the data flow principle, which is what billko is referring to, will manage what happens when, and you could probably just remove it, and therefore some apparant complexity.

 

Those VIs are the ones we use in almost exactly the same way, and we moved from XP to Windows 7 with no problems. But if you are having other issues with the windows 7 systems and USB devices it is probably something there more than anything else. Your initial view that it isn't the LabVIEW code is probably on the ball from what you're saying and the picture builds up.

0 Kudos
Message 29 of 32
(945 Views)

My apologies to spaceman:

 

Upon further review of my first post, it would've been much better for me to say something like, "and after you've read through the tutorials, you should probably re-examine all your code with this new information in mind."  Looking back at my first post, it sounded like I was really brining the hammer down on you, and I didn't mean it that way at all.  The first post really sounded like an attack, and I'm very sorry for that.  😞

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 30 of 32
(937 Views)