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.

Multiple Main Scans


Sam Jun 3, 2011 09:42 PM

Here you go Christopher.

-------------------------------------------
Public Counter1
Public Counter2

BeginProg
Do While TRUE
Scan (5,Sec,0,0)
'scan slow until an event happens
'in this case the event is counter1 >= 10
Counter1 = Counter1 + 1
If Counter1 >= 10 Then
'do something
Counter2 = 0 'like reset a counter
ExitScan 'exit this scan
EndIf
NextScan
Scan (1,Sec,0,0)
'now go fast until a new event happens
Counter2 = Counter2 + 1
If Counter2 >= 10 Then
'do something
Counter1 = 0 'like reset a counter
ExitScan 'exit this scan
EndIf
NextScan
Loop 'loop back to the top
EndProg

-----------------------------------------

You can use this concept inside and in conjunction with SlowSequences too.

Public Flag As Boolean
Public Counter1
Public Counter2
Public Counter3
Public Counter4
Public Counter5

BeginProg
Do While TRUE
Scan (5,Sec,0,0)
Counter1 = Counter1 + 1
If Counter1 >= 10 Then
Counter2 = 0
ExitScan
EndIf
NextScan
Scan (1,Sec,0,0)
Counter2 = Counter2 + 1
If Counter2 >= 10 Then
Counter1 = 0
ExitScan
EndIf
NextScan
Loop 'loop back to the top

SlowSequence
Do While true
Scan (1,Sec,3,0)
Counter3 = Counter3 + 1
If Flag Then ExitScan
NextScan
Scan (1,Sec,3,0)
Counter4 = Counter4 + 1
If (NOT Flag) Then ExitScan
NextScan
Loop
EndSequence

SlowSequence
Scan (1,Sec,3,0)
Counter5 = Counter5 + 1
NextScan
EndSequence

EndProg

* Last updated by: Sam on 6/3/2011 @ 8:26 PM *


Thein Jun 8, 2022 02:39 AM

Hi Sam,

I am working on a program with multiple main scans with vibrating wire instruction following your example program, but compilation failed. Could you please help check, whether this is a program error or compiler error.

'Multiple Main Scan Example
'Program Name  : MultipleScan_02.CR6
'---------------------------------------
SequentialMode
Public Flag As Boolean
Dim VW(6)
Public DG,T

BeginProg
  Do While True
    Scan (10,Sec,0,0)
      VibratingWire(VW(1),1,U1,450,6000,1,0.01,"",50,1.4051E-3,2.369E-4,1.019E-7)
      DG=(VW(1)^2)/1000
      T=VW(6)
      If DG <= 4000 Then 
       Flag = True
      ExitScan
      EndIf
    NextScan

    Scan (5,Sec,0,0)
      VibratingWire(VW(1),1,U1,450,6000,1,0.01,"",50,1.4051E-3,2.369E-4,1.019E-7)
      DG=(VW(1)^2)/1000
      T=VW(6)
      If DG > 4000 OR (NOT Flag) Then ExitScan
    NextScan
  Loop
EndProg

'----------------------------------------------------

[Version]C:\Campbellsci\Lib\Compilers\CR6Comp.exe VERSION:CR6.Std.12.00  DATE:04/27/2022
MultipleScan_02.CR6 -- Compile Failed!

line 22: __VW_VW_FILE already declared as a variable.
Error(s) detected in the program. Double-click an error above to navigate to it.

 Thanks in advance.

Best regards,
Thein

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