Is it necessary to use SubScan/EndSubScan loops in a CR1000 program for collecting measurements from a multiplexer, or could I instead just use Do/ Loop construct? Does SubScan offer anything more than the convenience of not having to set up the looping conditions?
More specifically, what is the advantage of do this…
PortSet (6,1) Delay (0,150,msec) i = 1 SubScan (0,usec,16) PulsePort (5,10000) Therm107 (T(i),3,1,1,0,_60Hz,1.8,32) i = i + 3 NextSubScan PortSet (6,0) Delay (0,150,msec)
Rather than this…
PortSet (6,1) Delay (0,150,msec) i = 1 Do PulsePort (5,10000) Therm107 (T(i),3,1,1,0,_60Hz,1.8,32) i = i + 3 Loop Until i > 48 PortSet (6,0) Delay (0,150,msec)
It makes a difference if you want to make your program run in pipeline mode. Subscan is run in the measurement task. A Do loop is run in the processing task.
With measurement instructions, it is better to place them in a Subscan. That lets the pipeline to put that whole block in the measurement task. However, if you are not trying to run things fast, the negative consequence of being in sequential mode is rather small.
Thanks for that. Where can I learn more about sequential vs. pipleine modes, including which instructions use each, and the pros/cons in different situations?
Section 7.6.3.12 on Execution and Task Priority in the CR1000 manual explains Pipeline versus Sequential modes. The help in CRBasic for individual instructions generally tells you which task the instruction runs in.