News:

  • April 30, 2026, 12:09:32 PM

Login with username, password and session length

Author Topic: $FirstScan in a program  (Read 16187 times)

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
$FirstScan in a program
« 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?

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: $FirstScan in a program
« Reply #1 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.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
Re: $FirstScan in a program
« Reply #2 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

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: $FirstScan in a program
« Reply #3 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.
« Last Edit: January 18, 2017, 12:59:19 PM by plcnut »
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: $FirstScan in a program
« Reply #4 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.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

davidbgtx

  • Hero Member
  • *****
  • Posts: 215
  • Host be the Most
Re: $FirstScan in a program
« Reply #5 on: January 18, 2017, 12:55:14 PM »
Wow, looks like they covered all the bases, thanks again

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: $FirstScan in a program
« Reply #6 on: January 18, 2017, 05:23:53 PM »
Wow, looks like they covered all the bases, thanks again

We're kinda obsessive like that. ;)
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

PLCGuy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 677
Re: $FirstScan in a program
« Reply #7 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.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: $FirstScan in a program
« Reply #8 on: January 20, 2017, 12:24:13 PM »
Not everyone uses stage.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6154
  • Yes Pinky, Do-more will control the world!
Re: $FirstScan in a program
« Reply #9 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.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: $FirstScan in a program
« Reply #10 on: January 20, 2017, 01:28:01 PM »
In the old days you used it to initialize the io modules.