Serving up the RealTime() Instruction with a Side of Alias Declarations

byJanet Albers| Updated: 10/07/2015 | Comments: 2

Search the Blog


订阅博客

Set up your preferences for receiving email notifications when new blog articles are posted that match your areas of interest.


区域 /申请

产品分类

Activity

Corporate / News

输入你的电子邮箱地址:



Suggest an Article

Is there a topic you would like to learn more about? Let us know. Please be as specific as possible.

将这个领域空白

dinner plate with a serving of RealTime() instruction and Alias declaration

CRBASIC提供完整的说明菜单,可帮助您编写或编辑数据记录程序程序。本文提供了使用The Data Logger操作的主要课程RealTime()instruction with a side dish of making your program easier to read with别名declarations.

The RealTime() Instruction

TheRealTime()指令从数据记录时钟获取年度,月,每日,小时,分钟,第二,每天的微秒,每天和一年的一天,并将结果存储在阵列中。如果您想安排数据记录器以在特定的时间间隔或特定日期执行操作,这将很有用。例如,您可以使用RealTime()instruction to schedule an action every Tuesday or once a month.

In theRealTime()instruction example below, a Boolean variable is set to "True" on the fifth day of every month. You might use this to test an alarm or run a calibration routine.

RealTime() program example

别名Declarations

In the above example, did you notice the instruction “IfrTime(3) = 5 Thenstate= True”? This instruction would be more readable as "If Day of Month (DOM) is True.” You can use the别名declaration to assign the second name of “DOM” to “rTime(3)”这样:

  • 别名rTime(3) = DOM

Now, in the above example, we can use "If DOM = 5 Thenstate= True."

别名declarations are particularly useful when using arrays, such as with theRealTime()指令,所以您可以很容易地identify individual variables using unique names.

别名ed versus non-aliased variables

A Helpful Resource

Did you know that you can copy and paste the别名declarations for theRealTime()instruction from the RealTime Example in the CRBasic Editor Help? Follow these steps to access this resource:

  1. HighlightRealTimein the instruction list of the CRBasic Editor.
  2. Click theHelpbutton above the instruction list.
  3. 在打开的窗口中,单击Examplelink, which opens a smaller window with an example program that uses the别名declarations.

    CRBASIC编辑器中的别名声明示例

  4. Highlight and copy (Ctrl+C) the applicable别名declarations, and paste (Ctrl+V) them into your program.

Recommended for You:For more information about variable arrays and别名声明,观看”CRBasic | Advanced Programming” video.


Hungry for more information about theRealTime()instruction or别名declarations?Post your comment or question below.


Share This Article



About the Author

珍妮特·阿尔伯斯Janet Albers holds the title of Technical Communications Manager; the sign above her office door says, "Coach." She'll share tips, simplify concepts, and guide you to a successful project. She's been at Campbell Scientific, Inc. longer than the CR1000, but not quite as long as the CR10X. After work hours, Janet enjoys the outdoors with her boys and dogs.

查看该作者的所有文章。


注释

Cristian|08/24/2017 at 04:03 PM

Hi Janet,

For a propagation chamber, I need to set different conditions for each day (starting a random day). Basically a different set point of humidity for each day*. I have been looking for a "time" intruction to do this but without luck so far.

*example

If DAY=1 then if Humidity <90% then PorSet (1,1)...

If DAY=2 then if Humidity <80% then PorSet (1,1)...

And so on...

Could you please help me with this?

Thanks very much.

Cristian

jra|08/25/2017在02:07 pm

Try the Timer() instruction. Something like:

Public ElapsedTime, DayOfTest, startflag As Boolean

如果startflag = true,则
ElapsedTime = Timer (1,Hr,0) 'start timer
startflag = false
EndIf

ElapsedTime = Timer (1,Hr,4) 'read timer

If ElapsedTime > 0 AND ElapsedTime <= 24 Then DayOfTest = 1
If ElapsedTime > 24 AND ElapsedTime <= 48 Then DayOfTest = 2
If ElapsedTime > 48 AND ElapsedTime <= 72 Then DayOfTest = 3

Pleaselog in or register评论。

We're active on social media!
Stay informed with our latest updates by following us on these platforms:

Baidu