Newbie still learning


krm

Recommended Posts

I am using daqfactory to automate and control a saltwater aquarium setup. I am working out how to read inputs from relevant sensors. I need help in creating a sequence to switch on 3 seperate banks of lighting at set times of day for set periods, can anyone help please? :blink:

Link to comment
Share on other sites

Good question. I've attached a sample (requires 5.78+) that can be reused to do just about any group of things at certain times of day. This should be quite useful in many applications. The code is easily ported to existing documents. Just copy the DoTasks sequence and the initialization code from the StartUp sequence.

Most of the work is done in the DoTasks sequence. This sequence works on 6 arrays, one for the start time, one for the length to run for, one for the action to perform at start, one for the action to perform when done, and two internal use. The StartUp sequence initializes them with a loop to toggle a digital every minute, but there is commented code to show how you would probably set it up. Just copy and paste each group of 6 assignments for each task.

A few things to review after you've played with it:

1) The ToDoTime and ToDoLength can actually take DAQFactory time. The date part is stripped and just the time of day / duration is used. Units are seconds.

2) If you use hms notation (i.e. 3h to specify 3am or 3 hours), make sure you always include the h. Don't do 30m for 30 minutes. You have to do 0h30m for 30 minutes.

3) ToDoAction and ToDoReverse are strings that contain the commands you want executed. These commands should be just a single line of script since they are used in an execute() function call in DoTasks.

4) ToDoStarted and ToDoDone are flags used internally to tell DoTasks when a task has been started and when it is complete. At the end of the day, these are all reset to 0 so the task execute again.

5) Tasks can be anything and the order doesn't really matter. Just remember that every time you paste the 6 lines of script that assign each task that you change the number inside the [] so they increment. The commented sample shows two tasks, [0] and [1]. If you wanted to add another you'd make it [2].

6) The "switch occurs at" part is simply because I inserted the execution time of StartUp into ToDoTime to test the Time of Day extraction. If you hard code your times like the commented code (i.e. 3h), the switch will occur at the 0 second, unless of course you specify otherwise.

Feel free to post with any questions.

TimeOfDay.ctl

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.