LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Arduino resets when looping through flat sequence structure

Solved!
Go to solution

I have been using the abort button but I realize now why that's a problem, although I tried running the Arduino Close VI and that didn't seem to fix things (I just double clicked on the VI in the code, made sure the right COM port etc. was selected and ran the VI, maybe that's not the right way to do it). And yes the board is powered via the USB cable so I don't know how those lights are staying lit.

Regardless, it seems that by putting in Stop buttons rather than using the Abort command I don't run into this issue anymore. Although it looks like I need multiple stop buttons because I have multiple while loops nested with a sequence structure (like Sam's example above) so I need one for each loop unless I can figure out a clever way to connect them all to one main Stop switch.

I think that takes care of all of my major issues, but I'm gonna play around with it some more so I'll let you know if any new strange things come up.

Thanks you guys, you've been really helpful.

~Masaad

0 Kudos
Message 11 of 13
(1,292 Views)

masaad wrote:

(I just double clicked on the VI in the code, made sure the right COM port etc. was selected and ran the VI, maybe that's not the right way to do it)

That is the correct way to do it.  I forgot about that.  When you run it alone, it doesn't know which COM port to use, so you need to specify it on the front panel of the Close.vi.

Regardless, it seems that by putting in Stop buttons rather than using the Abort command I don't run into this issue anymore. Although it looks like I need multiple stop buttons because I have multiple while loops nested with a sequence structure (like Sam's example above) so I need one for each loop unless I can figure out a clever way to connect them all to one main Stop switch.

I think that takes care of all of my major issues, but I'm gonna play around with it some more so I'll let you know if any new strange things come up.

Thanks you guys, you've been really helpful.

~Masaad

From your original code, it appears that you already have a condition to stop the inner loops.  You should be able to continue doing that (but should also do as Sam suggested and OR that condition with the Arduino error wire.  If you might need to "abort" one of the inner loops (effectively abort, not literally), then you should look into the state machine architecture where each sequence frame would become a new state (eliminating the need for the inner while loops).  This will allow you the ability to check for the stop button more often and be able to stop the execution at any point.

Take a look at this document about the state machine architecture.

0 Kudos
Message 12 of 13
(1,292 Views)

I see. I don't know much about state machines, but looking through the documentation it does seem like it might be a better way to implement things for me. My code seems to be working okay for now, but I'll look into using state machine architecture and maybe that approach will help me to more easily handle some of the final few bugs.

0 Kudos
Message 13 of 13
(1,292 Views)