Tutorial RevPiTimer

In this tutorial we want to configure a virtual timer for the RevPi Core.

In PiCtory you will find the virtual device “RevPiTimer”. The “RevPiTimer” is a timer clock that switches on and off to the minute on a weekly basis. There are 16 switching times available for each RevPiTimer. However, you can also use several RevPiTimers if 16 switching times are not sufficient.

We set the following switching times:

#Timer Switch on Switch off
Day Time Day Time
1 Mon – Fri 07:00 Mon – Fri 17:00
2 Sa 10:00 Sa 10:15

 

  • Open your web browser.
  • Enter the IP address of your RevPi Core in the address box of your browser.

The log-in window opens.

pictory-anmelden
  • Login with the user name “admin”.
  • Enter your password. You will find the sticker on the side of your RevPi Core.
  • Click on “Login”

You can now see the current status of your RevPi Core.

Apps tab screenshot
  • Click “Apps” tab.
  • Click the start button behind the entry “PiCtory” to start PiCtory.

PiCtory opens.

  • Open the folder “Virtual Devices” in the device catalog and select “RevPiTimer”
  • Drag and drop it onto the Configuration Board.

PiCtory Configuration
  • Click “File>Save” to save the configuration.

Save configuration
  • Click “Tools>Reset Driver”. This activates the changes for the adapter.

Driver reset

Programming the timer

Each timer consists of a switch-on and a switch-off time..

Timer Variabel Meaning
1 T1_ON_active_day Einschalten Bitfeld: an Tagen und aktiv oder inaktiv
1 T1_ON_hour Einschalten Stunden 00 bis 24
1 T1_ON_minute Einschalten Minuten 00 bis 59
1 T1_OFF_active_day Ausschalten Bitfeld: an Tagen und aktiv oder inaktiv
1 T1_OFF_hour Ausschalten Stunden 00 bis 24
1 T1_OFF_minute Ausschalten Minuten 00 bis 59
2 T2_ON_active_day Einschalten Bitfeld: an Tagen und aktiv oder inaktiv
2 T1_ON_hour Einschalten Stunden 00 bis 24
2 T1_ON_minute Einschalten Minuten 00 bis 59
2 T1_OFF_active_day Ausschalten Bitfeld: an Tagen und aktiv oder inaktiv
2 T1_OFF_hour Ausschalten Stunden 00 bis 24
2 T1_OFF_minute Ausschalten Minuten 00 bis 59
16 T16_ON_active_day Einschalten Bitfeld: an Tagen und aktiv oder inaktiv

 

The bit field for the days and the active switching is coded as follows

T1_ON_active_day and T1_OFF_active_day

Bit 7 6 5 4 3 2 1 0
Value active Son Sat Fri Thu Wed Tue Mon

For our example we have to enter the following values:

Timer1

Days: Mon – Fri + active, Time: 7:00 to 17:00 o’clock

Bit 7 6 5 4 3 2 1 0
Value active Sun Sat Fri Thu Wed Tue Mon
Mon-Fri 1 0 0 1 1 1 1 1

This results in the binary value “10011111”. This corresponds to the decimal value “159”. This value must be written to the process image later on.

Therefore, following values have to be written into the process image for Timer1:

Variabel Value
T1_ON_active_day 159
T1_ON_hour 7
T1_ON_minute 0
T1_OFF_active_day 159
T1_OFF_hour 17
T1_OFF_minute 0

You can do this with the tool “piTest”, for example. .

Open the command line and write following commands:

piTest –w T1_ON_active_day,159

piTest –w T1_ON_hour,7

piTest –w T1_ON_minute,0

piTest –w T1_OFF_active_day,159

piTest –w T1_OFF_hour,17

piTest –w T1_OFF_minute,0

Timer2

Days: Saturady + active, Time: 10:00 to 10:15 o’clock

Bit 7 6 5 4 3 2 1 0
Value active Sun Sat Fri Thu Wed Tue Mon
1 0 1 0 0 0 0 0

This results in the binary value “10100000”. This corresponds to the decimal value “160”.

Therefore, following values have to be written into the process image for Timer2:

Variabel Value
T2_ON_active_day 160
T2_ON_hour 10
T2_ON_minute 0
T2_OFF_active_day 160
T2_OFF_hour 10
T2_OFF_minute 15

Open the command line and write following commands:

piTest –w T2_ON_active_day,160

piTest –w T2_ON_hour,10

piTest –w T2_ON_minute,0

piTest –w T2_OFF_active_day,160

piTest –w T2_OFF_hour,10

piTest –w T2_OFF_minute,15

Query timer events

The variable “TimerStatus” indicates whether a timer event is currently active. This is a bit field with 16 bits.

If the bit is set, the timer is on. If the bit is not set, the timer is off.

TimerStatus

Bit 7 6 5 4 3 2 1 0
TimerNr Timer8 Timer7 Timer6 Timer5 Timer4 Timer3 Timer2 Timer1
Bit 15 14 13 12 11 10 9 8
TimerNr Timer16 Timer15 Timer14 Timer13 Timer12 Timer11 Timer10 Timer9

To write a program that responds to Timer1, you can do the following, for example:

Find out where the Timer1 bit is located in the process image:

piTest -v TimerStatus

variable name: TimerStatus

offset: 11

length: 16

bit: 0

There you go!It is in byte 11, first bit!

Query this bit:

piTest -g 11,0

Get bit 0 at offset 11. Value 0

If you only want to output the value without text, so that you can process it in a script, you can simply query it like this:

piTest –q -g 11,0

0

Set Timer inactive

Switching the timer inactive means that the switching times are not overwritten but also not executed.

If you want to disable a timer you can do this by deleting the respective “Active” bit in the variable “T1_ON_active_day” and “T1_OFF_active_day”.

Find out where our variables are in the process image:

piTest -v T1_ON_active_day

variable name: T1_ON_active_day

offset: 13

length: 8

bit: 0

piTest -v T1_OFF_active_day

variable name: T1_OFF_active_day

offset: 16

length: 8

bit: 0

The offsets are therefore as follows:

T1_ON_active_day: 13

T1_OFF_active_day: 16

Set switch-on and switch-off time inactive:

piTest -s 16,7,0

Set bit 7 on byte at offset 16. Value 0

piTest -s 13,7,0

Set bit 7 on byte at offset 13. Value 0

Variants

You only want to define a switch-on time but no switch-off time? No problem! Set the “active bit” only at switch-on time and omit it at switch-off time.

In the example for Timer1 you can change it like this:

piTest -s 16,7,1

Set bit 7 on byte at offset 16. Value 1

piTest -s 13,7,0

Set bit 7 on byte at offset 13. Value 0