Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

SubScan vs. Do/Loop differences?


crs Mar 30, 2018 04:10 PM

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)

 


JDavis Mar 30, 2018 04:27 PM

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.


crs Mar 30, 2018 08:19 PM

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?


JDavis Mar 30, 2018 08:44 PM

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.

Log in or register to post/reply in the forum.