From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-18-2013 03:20 PM
Hello all,
I could use some help with code I'm about to write. I have been working with communications over Ethernet with Arduinos and things go well ~80% of the time. The other 20% I'm receiving a timeout error. My current method for timeout checking is a butchered version of the LIFA code (originally USB communications) that I got working (Reference current_method.png ). I have been thinking about redoing that code because it doesn't make sense to me. From my understanding, it writes the data, then reads data being sent back, and if they aren't the same, continues reading the data. However, the Arduino only sends the response once. So, say I missed that response, I'm not going to see a new response sent. (Note, the original code has a wait for bytes at port property in the read visa area).
Therefore, I'd like to create a system in which LV would send a command, wait a bit, and then read. If the number of bytes being read isn't the same as the number that I am expecting, I want it to flush the buffer and retry up to 10 times.
The first part I believe I have being sent correctly (Reference LVhelp.png). My problem is with seeing if it is false, then redo the loop. I was originally thinking about using a feedback node and put a case structure where if false, then loop again.
Any tips?
04-18-2013 03:50 PM - edited 04-18-2013 03:52 PM
Hi uke,
I was originally thinking about using a feedback node and put a case structure where if false, then loop again.
When I have to tackle a problem like yours I think of a While Loop set to continue as long as FALSE condition is given (or as is worded by LabVIEW: stop on TRUE)...
What's the sense of reading zero bytes?
What's the sense of the wait function when you still have to wait for bytes to receive?
04-19-2013 08:24 AM - edited 04-19-2013 08:54 AM
Thanks for the response.
I just whipped that up the VI really quick to help illustrate my idea. In all actuality, bytes to be read would be a control and not a 0.
Is there a way I can increment a number to hit 10 and then stop for a while loop? I have been toying with that idea now but I am nusure how to get it to increment. I believe I want to use a shift register.
If this works, the only thing I have left to do is create an error that says time out.
Matt
Edit:
I believe I got a proper VI working. The attached LVhelp.png file is the actual code I'm going to impliment.
04-19-2013 09:09 AM
So the code works better, but I'm still running into a problem. When I start to get a timeout, the main problem is that I lose connection to my Arduino.
can I use a case structure with shift register on the error to check for feedback if the connection is lost?
My general confusion is with using a loop to give me feedback from the previous iteration. My belief is that a shift register will take the variables previous loop value and use it for the current loop, such as the time out variable. Where the first loop its 0, then 1, then 2, etc. Is this the correct way to think of a shift register?
Matt