Ni.com is currently experiencing issues that may cause some pages to fail.
Support teams are actively working on the resolution.
Ni.com is currently experiencing issues that may cause some pages to fail.
Support teams are actively working on the resolution.
06-29-2010 05:38 AM
Ok folks,
what do you think about this? Is this better?
one more question, you will see the standby state, where it basically waits till it gets either the start or the save command. I have programmed it now with a while loop and a case loop. But if I want to implement a third button, the STOP for instance then my system doesn't work anymore :). There should be a better way to do this.
Thanks
06-29-2010 06:00 AM - edited 06-29-2010 06:01 AM
Hi Kristof,
here's a slightly changed version:
- using shift register for "data"
- only one loop (!)
- no local variables
- loop count changed to I32
Never compare floating point numbers for (un)equality - things tend to fail
06-29-2010 06:02 AM - edited 06-29-2010 06:04 AM
If you could save that to 8.5.1, that would be awesome!
06-29-2010 06:07 AM
06-29-2010 06:32 AM - edited 06-29-2010 06:40 AM
Hmmm you guys will not understand me in dutch i guess...
so, anyway, I noticed by trying your VI that the data is not plotted in real-time, but after the whole for loop is done... is there a work around using shift registers or should I just use the locals then?
thanks for the other modifications!
06-29-2010 06:40 AM - edited 06-29-2010 06:43 AM
06-29-2010 06:41 AM
edited it, sorry about that, it's what you get after 24h working 🙂
06-29-2010 09:18 PM
Guys, thanks a lot for your help. I think it can still be improved, but this is already way better than before. The whole state machine thing is indeed a nice feature to use.
Kristof
06-30-2010 02:26 AM
The state machine is still a horrible mess and full of unnecessary code and very dangerous programming steps.
06-30-2010 02:53 AM
@altenbach wrote:
The state machine is still a horrible mess and full of unnecessary code and very dangerous programming steps.
look at the positive side man, i've come a long way and I am brand new !
- You have case structures where each case contains the same code. Why?
no idea 🙂
- You are doing equal comparisons on DBL, a very bad idea! The smallest differences can make the comparison fails. Since you increment fractional values, it is very likely that an equal will never match. Use integers! (or e.g. "greater or equal" when using DBL) Integer is probably preferred. You can calculate the number of integer steps from the control values. (not implemented)
yes i know, i removed them already
- Don't place controls before the loop, the can never be read again during the same run.
ok
- Don't use inner loops. A single outer loop can handle everything. No locals needed.
you are actually the first one to really solve my initial problem, I used For loops, but they don't give out their values until finished, so they didn't allow real time plotting unless you use a local, but your way makes the for loop disappear (why do they even exist, same with sequences???)
- You cannot write complex data to a spreadsheet directly, it will get coerced to DBL and you'll lose the imaginary part.
yes i had to break it up again
- ...
- ...
Here's a quick draft that could possibly give you some ideas. Many improvements are possible (and necessary!). I would probably use an event structure in order to have the VI react to user input at any time.
Thanks alot!
Kristof