Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: davidbgtx on January 18, 2017, 12:30:25 PM

Title: $FirstScan in a program
Post by: davidbgtx on January 18, 2017, 12:30:25 PM
If I use $FirstScan in a program will it ever be true? Does the program start on the 2nd scan, then I could set $ScanCount less than 2?
Title: Re: $FirstScan in a program
Post by: plcnut on January 18, 2017, 12:36:41 PM
The program starts at scan 1. The ST0 contact will be closed on that first scan only.
Title: Re: $FirstScan in a program
Post by: davidbgtx on January 18, 2017, 12:42:35 PM
Thanks, just wasn't sure if it scanned all the way through main and on 2nd scan enabled any programs
Title: Re: $FirstScan in a program
Post by: plcnut on January 18, 2017, 12:48:38 PM
If you enable a program block on the first scan, and then use ST0 inside that program block, then ST0 will be active inside that program for one scan.

There is also the a bit called MyProgramBlock.FirstRun that will be active for 1 scan the first time any block is run for the first time after a boot-up. Then there is another one called .FirstScan that is on for one scan after a RUN command.
Title: Re: $FirstScan in a program
Post by: plcnut on January 18, 2017, 12:50:41 PM
For clarity, you can right-click inside your project browser and select Sort>>By execution order, and see the order in which each of your blocks will execute.
Title: Re: $FirstScan in a program
Post by: davidbgtx on January 18, 2017, 12:55:14 PM
Wow, looks like they covered all the bases, thanks again
Title: Re: $FirstScan in a program
Post by: BobO on January 18, 2017, 05:23:53 PM
Wow, looks like they covered all the bases, thanks again

We're kinda obsessive like that. ;)
Title: Re: $FirstScan in a program
Post by: PLCGuy on January 20, 2017, 12:21:22 PM
Reading so much about first scan. Can someone give a quick lesson why you use it? If I need something to run only once, that is in a stage, when it gets to the end of the stage it jumps out and I am good to go.

I never needed to use it. For instance in my stage program my first stage is my initializing stage. there is where the program starts and if e-stop is active the program jumps to this stage. In this stage is where I do my stage resets, bit resets and set anything the program will need to run, make sure things are in order. When e-stop is restored, it jumps out to the appropriate stage for starting. Sits here until a command is given.
Title: Re: $FirstScan in a program
Post by: Controls Guy on January 20, 2017, 12:24:13 PM
Not everyone uses stage.
Title: Re: $FirstScan in a program
Post by: BobO on January 20, 2017, 12:56:28 PM
Reading so much about first scan. Can someone give a quick lesson why you use it? If I need something to run only once, that is in a stage, when it gets to the end of the stage it jumps out and I am good to go.

I never needed to use it. For instance in my stage program my first stage is my initializing stage. there is where the program starts and if e-stop is active the program jumps to this stage. In this stage is where I do my stage resets, bit resets and set anything the program will need to run, make sure things are in order. When e-stop is restored, it jumps out to the appropriate stage for starting. Sits here until a command is given.

Do-more was designed to meet you where you are, with heavy emphasis on making the DL to Do-more transition easier. I have described our approach as "respecting the legacy while embracing the future". There are many people who use straight ladder all in $Main. Others use modularity, but not Stage. My personal preference is heavy modularity with Stage, and generally speaking I don't use $FirstScan, but many people do.
Title: Re: $FirstScan in a program
Post by: Garyhlucas on January 20, 2017, 01:28:01 PM
In the old days you used it to initialize the io modules.