LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop slow.. stop button not working.. easy fixes, but can't do it myself

Alright, this is probably some seriously easy stuff, but I am not that great with LabView. 

 

To be short, my project is an HMI that interfaces with an Xbee attached via USB. I have the Xbee recognized using VISAs and I am even able to send at least one AT command to it (+++) and get predictable results. However what I do not understand is why my while loop executes at about one interation per 10 seconds........ it is unbearably slow and I don't really understand why. Also when I press my Stop button nothing happens.. it not only will not exit the loop but turns my cursor to probe mode.. I have no idea what's going on. Hopefully someone can help.

 

 I have attached the file.

 

Thank you!

0 Kudos
Message 1 of 13
(5,761 Views)
  • You have a breakpoint on your full diagram (notice the red border), thus the VI will pause immediately when run. (To fix, get the breakpoint tool from the tools palette and click on the diagram background until ther red border disappears)
  • Your while loop has no small wait, meaning the loop rate is not deterministic
  • Your "enable device" switch is read only once at the start of the program, thus the "boolean" will never update again.
  • Your stop button mechanical action should be "latch when released".
  • Is your VISA device configured correctly? Maybe you are waiting for more data than is ever actually returned?
0 Kudos
Message 2 of 13
(5,752 Views)

Other thing , you should use shift register to pass VI reference in while loop.

0 Kudos
Message 3 of 13
(5,750 Views)

@puneet K wrote:

Other thing , you should use shift register to pass VI reference in while loop.


That does not make any difference here.

0 Kudos
Message 4 of 13
(5,745 Views)

Thanks for the reply.

 

  • I removed the breakpoint. I went to Select Edit»Remove Breakpoints from Hierarchy as it said in the Help file, but doing so I don't actually understand what the problem was.
  • The enable device was just a place holder, sorry.
  • Thanks, I can never figure out which mechanical action to set it o
  • This is my first time using VISA so I hope so. I get this error now when I hit the stop button, though:
    Error -1073807343 occurred at VISA Open in HMI2.vi

    Possible reason(s):

    VISA: (Hex 0xBFFF0011) Insufficient location information or the device or resource is not present in the system.

    I'm assuming it's a general error and not something anyone else can really help me with though. 

     

    I added a wait time, but even still, when I select my Xbee device for the VISA device, it only goes through the loop once every 5-6 seconds........

     
0 Kudos
Message 5 of 13
(5,695 Views)

Take a peek at the shipping example VISA Serial Read -Write.  With RS-232 devices there is usually some way to determine when a "packet" is completed.  There are several popular methods:

 

Hardware Handshaking:   There are a few flavors but each uses signal lines that are not the ones that carry data to establish when its ok to send data and when data is available. This used to be used more frequently than it is today and is more usefull in schemes where one sender has data once in a while and the reciever does not want to poll the device unless it sees a "Request to send."  Modern computors and modern communication schemes are obsoleting the need for this.

 

XON/XOFF: The Reciever  sends an XOFF charater to the transmitter when its recieve buffer is nearly full and the transmitter shuts up while the reciever processes its buffer.  Again, modern computors and modern communication schemes are obsoleting the need for this.

 

Termination characters:  The sending device sends a special charater at the end of every message (often a linefeed ASCII 0x0A)  To implement this you need to make sure that your message does not contain that letter- You would be surprised how often you want to transfer raw ADC counts 0x00-0xFF rather than scaled readings (10.234e+5) takes 9 times as long to send.

 

VISA handles each of these and can automatically detect a read "End" and return your data right away.  Otherwise, VISA read will return when the number of characters you ask for is read OR when the timeout expires.  The default timeout is 10 seconds you never read 1024 characters.

 

 

Message Based flow is also popular and works by the sender always sending the packet length at the start of a message.  There is no standard on this so VISA cannot implement it.  Digi-International uses this a lot.


"Should be" isn't "Is" -Jay
Message 6 of 13
(5,691 Views)

Sorry, 

0 Kudos
Message 7 of 13
(5,682 Views)

In this concern FOR loop are the real issue because they can execute 0 times resulting in output tunnels being set to the default value for the datatype. In that situation you can lose the contents of references and error clusters (two common things that pass through loops). WHILE loops on the other hand always execute at least once so (assuming everything is written correctly inside the loop) the output tunnels should always be valid.

 

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 13
(5,681 Views)

@Mike?????  did you cross-post a reply?

 

Fernian,

 

Sorry If I was unclear.  I attempted to gloss over the various VISA Serial properties, how they work and how the VISA read is effected.  (And why your loop time is 10 seconds)

 

You are not usuing the correct VISA configuration

 

Looking here we see that the XBEE Pro module is using a VCP through a FTDI chipset into a UART that requieres hardare handshaking using RTS/CTS.  Drop a VISA Configure serial port in the front to set the flow control


"Should be" isn't "Is" -Jay
0 Kudos
Message 9 of 13
(5,672 Views)

According to Digi's XCTU program to configure the Xbee modems, the flow rate is set to none anyhow. But I changed it to Hardware (only other option being XON/XOFF). I added the  VISA Configure serial port in front of the Visa Open (is this redundant?) and set its flow to RTS/CTS. Soon I will be trying to send a command to another Xbee via Labview. I'm sure I'll be back for more.

 

 

And my final question for now was, what is controlling that 10 second loop? The Xbee chip or a VISA setting?

0 Kudos
Message 10 of 13
(5,658 Views)