08-16-2007 09:25 AM
08-16-2007 11:48 AM
Hi, Chris
Once again, {I'm blaming the 3 hour time difference between us} Kevin has beaten me to the punch. I completely agree with everything he's said. I can only apologize for anything the Basics courses taught that we are disagreeing with. I can guarantee that when I wrote and taught the classes that you would have gotten more thorough information with practical examples of all the points Kevin made. I can also recommend the books "LabVIEW for Everyone" by Jim Kring and "The LabVIEW Style Book" by Peter Blume. They both go into the descriptions of sequences and error handling in much more detail where your issues are concerned.
I also hope it doesn't sound like Kevin and I are being overly critical of your code. We were both new at LV at some point, too, and made all the same mistakes (at least I did). It took a while before I made the complete paradigm shift from conventional programming to graphical dataflow programming.
Stick with it; I swear this stuff works and works well.
08-16-2007 12:55 PM
Thanks, both of you!
Kevin, I remain awed by your participation. I'll try the VIs on the PXI system when I can.
Crystal, I'm using King's book (3rd ed.), and have found almost nothing about error flow sequencing. The only relevant line I've found so far is: "When you add error in and error out I/O terminals to your VIs, you allow calling VIs the opportunity to chain the error cluster wire to create dataflow dependencies between subVIs" on P. 295 in the chapter on Arrays and Clusters. This is minor but relevant, yet doesn't come close to Kevin's quite reasonable explanation. I looked through the entire chapter on Sequences and didn't find anything suggesting wiring errors instead. About dataflow, I find only "Its execution is based on the principle of dataflow, in which functions execute only after receving the necessary data" on P. 5 (the only index entry for "dataflow"). Where's the "much more detail"? I don't have Blume. I DO hope that if the error flow trick really is good practice, I'll start to see it as such!
>...sound like Kevin and I are being overly critical of your code... --- No, no, of course not. I think at this point you're only critical of me ignoring errors, in which you're perfectly correct, and the error flow sequencing, which for good or ill I still see as debatable. You have criticized some things which I shouldn't have to be doing, of course, but the whole discussion includes the question of why these seem to fix or change behavior when they shouldn't be needed at all.
>I swear this stuff works and works well. ---- I dunno, I dunno. I'm still waiting to experience that. Surely I'm trying hard enough, right?
08-16-2007 02:49 PM
Hi, Chris
Yes, I'm going to have to apologize again. Kring's book is a great reference, but it doesn't actually go into many details. That's probably a good thing because it's already over 1000 pages. It is a good place to start, but doesn't tell the whole story. Blume's book has an entire chapter devoted to Error Handling. He starts out by recommending you trap all errors by wiring all the error terminals. The he goes into how trapping isn't enough and how you *really* only need to trap certain errors such as any sort of I/O. What you have to do is find efficient ways to report errors and/or handle them in the method that works best. For instance, receiving the timeout on an early DAQmx VI pretty much obsoletes the rest of your diagram, so the program should probably immediately report that error and either attempt the DAQ operation again or just end depending upon whether you are actually monitoring the app or if it's running unattended. He recommends not using error dialogs if the app is unattended, but to programmatically prioritize the errors and either clear them out and try the operation again, or send the messages to an error log. You can even have the program e-mail the error log to an admin or page people should certain high-priority errors occur. Most of Chapter 4 is devoted to dataflow and showing how sequences are unnecessary in some situations versus others. He talks through about ten examples and you can see how the programs are much easier to read, understand, and debug based on different programming architectures.
You are definitely trying enough, in fact, you might be trying too hard. I've had periods of massive frustration over a seemingly simple problem and eventually they work themselves out. Dataflow is an extremely simple concept but changing the way you program from a sequential text-based way of thinking to a parallel dataflow way can be painful and difficult. It took me a long time while I've seen some people immediately get it after finishing their first application. The more you use LV on real-world problems, the more it will make sense. It really helps to use this forum as you did. Talking through problems/issues with other people who have been there and done that is extremely helpful.
Kevin, you completely rock! You are highly appreciated here!
Another good resource for LV programming is www.lavag.org. They have some great wiki articles on many topics.
Of course, I'm available as a resource any time. Just give me a holler if you want me to come out for a visit or anything. I plan to stop by the next time I'm back East just to meet you face to face and see what all you are working on.
08-17-2007 12:00 PM
Had a chance to try out my most recent vi's on a PCI-6259. At first I *did* see a timeout error -- but it turned out to be that I forget to use the "right" DIO line for the pulse. As soon as I set it to port1/line0, no more timeouts ever. (I've got the terminal block completely disconnected from my board for my testing. Using port1/line0 gives me an internal signal connection to PFI0, removing all dependence on external wiring.) Also due to my lack of external wiring, the other thing I needed to do was define the 100 kHz timebase as the edge count terminal using a DAQmx Channel property node. You can copy and paste from one of my earlier posted examples.
Could you test this way on your PXI? The code you post keeps reverting back to port0/line1 and using the default Source pin as the terminal for edge counting. I'm not convinced (yet) that your external wiring and connections can be eliminated as suspects. So could you remove the cable from the board to take all the external wiring out of the picture, then do the things I described above? My board ran for something like 12000 starts at 100 randomly-timed reads per start. That's over a million total counter reads with no timeouts. Yours should do this too. I'm still not sure you've ever 100% confirmed that you tried the USB board with all wiring disconnected.
I really do understand why you keep wanting to test with something more like your full-up real system. After all, if it works, you're all done. But in the long run, you'll benefit about 90% of the time by resisting that temptation. Break the problem down into small, non-interacting, easily-observed pieces. It always takes extra time to do this. But it usually takes *less* extra time than if you didn't. Right now the core issue is to force count values to get latched & buffered immediately whenever you happen to generate a True-False strobing pulse on a digital output. If you run an example that's been proven to work in the absence of all external wires, you'll be helping to zero in on the root cause.
-Kevin P.
08-17-2007 01:47 PM
Kevin, I'm trying the VIs you posted most recently.
>use the "right" DIO line for the pulse ... port1/line0 ---- Yes, I changed this.
>define the 100 kHz timebase ... Channel property node. You can copy and paste from one of my earlier posted examples --- Yes, I copied this from your "query numsamps" VI.
>Could you test this way on your PXI? --- Yes, I will do that next, with the cable disconnected, if the system is available. The PXI system = the full up hardware system = "Multi".
I did just test it on my USB system = my development system = "Laplace", after removing all the physical wires. It immediately gives the timeout error. I am posting that here as "...LaplaceUSB.vi". Do you see anything I missed?
>...not sure you've ever 100% confirmed that you tried the USB board with all wiring disconnected... --- No, I didn't try USB without wiring until minutes ago, but I have now, and it timed out immediately, as per above.
>I'm not convinced (yet) that your external wiring and connections can be eliminated as suspects. --- This is reasonable. I'll be doing internally-wired-only tests with the cables off for the time being.
>I really do understand why you keep wanting to test with something more like your full-up real system. --- Hah! I think you don't! I was using external physical wiring out of ignorance because I'm unfamiliar with the internal routing with PFI lines and felt more secure with the external physical wiring. I didn't have a useful feel yet for what sorts of things to try to do that way, for example it didn't occur to me to use Port 1 for the digital out so it can map to a PFI line to the source input. But I'm getting more comfortable with the PFI business now.
>core issue is to force count values to get latched & buffered immediately whenever you happen to generate a True-False strobing pulse on a digital output ---- Exactly. Exactly. Exactly.
08-17-2007 02:32 PM
Kevin, YOU GOT ONE!
Your posting which I edited per your advice and just reposted, now works on the PXI system (after "Laplace*" is replaced with "Multi*")! I watched it run 500 start loops.
This got me wondering about Distribution...Multi which was running before on PXI. You may recall I didn't trust it because I had to add an extra pulse before starting the loop and was worried there was an uncertainty of 1 in the vintage of the count results. A few days ago I posted "Then I discovered that about 15% of the time, it dies on the first iteration when starting, with a timeout, at random as far as I noticed. I thought to add a pulse on the digital line before the loop starts in the calling, test program Distribution....vi." when I introduced this change.
Maybe the state of the digital line was indeterminate in my Distribution, either electrically or depending on how I had driven it during a previous test... until I added the pulse, which also fixed the indeterminacy. Your recent posting specifically asserts the line low, which I didn't do before (looking back this seems very bad practice)! So I changed the older Distribution...Multi.vi to drive the line low twice, instead of high & low, and it still worked. The pulse I had concluded was fixing things wasn't really the difference that fixed things, but explicitly setting the state of the line may have been.
I also tried taking both those drives out, hoping to break it, but that did not break it (however proving this was the problem also relies on forcing the line to take an indeterminate state, and who knows what history may have been doing that - there's no fuzzy Boolean constants available in LV). Maybe I'll add something to randomly set the line high or low before the loop; I would expect that to break it.
So it's gonna run over the weekend while I tally diff's and starts.
I don't see anything worrisome or indeterminate about the VI now.
I am still curious why it didn't work on the development system, which is way easier to get on while maintaining file and Web access. There's a NI field engineer visiting next week, so maybe he can put his hands on it and figure something out.
And I think I have to add Duplicate Count Prevention to this, because my event rates can sometimes be much lower than my sampling rates, right?
Thanks!!
08-17-2007 04:07 PM
08-20-2007 07:57 AM
08-20-2007 11:40 AM
Kevin,
I'm running DAQmx version 8.1 on the PC that uses the USB system Laplace. I think the last update was about a year ago but couldn't be more than 2 years. The PC using PXi Multi very likely has a newer DAQmx. It is kept pretty nearly up to date. I think we installed new versions of all NI software there this summer.
On the PXI system I have written another testing VI that calls on ReadCountersOnce. It generates a known number of pulses in an inner loop using another, new digital output port, which is coupled by PFI into both counter source terminals, so buffering and events are both their own digital output bits. I have yet to get an incorrect count or timeout on either counter, in many reps, even with 0 as the number of pulses in isolated or consecutive counts. This seems to me to indicate that Duplicate Count Prevention is either in play or unneeded, though I did nothing to specify its use.
There's some tidying up I'd like to do, checking all my versions and collecting the most interesting VIs and fixing two off-point problems with this last VI and getting things together for Friday's visit. But it seems to me my problem is fixed, or rather nonexistant, for the full-up hardware system, and I could create a dummy counting VI for the development system if need be. Maybe I'll post some of this wrapup.
Kevin, thanks tremendously for helping figure this out! By chance would you be willing to pass me your email address? Mine's visible in my profile. In any case, I'm much in your debt - Thank you!