Tutorial RevPiTimer (Compact)

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

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:

#TimerSwitch onSwitch off
DayTimeDayTime
1Mon – Fri07:00Mon – Fri17:00
2Sa10:00Sa10:15
  • Open your web browser.
  • Enter the IP address of your RevPi Compact 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 Compact.
  • Click on “Login”

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

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. Here is an example with RevPi Core.
  • 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..

TimerVariabelMeaning
1T1_ON_active_dayActivate bit field: on days and active or inactive
1T1_ON_hourSwitch on hours 00 to 24
1T1_ON_minuteSwitch on minutes 00 to 59
1T1_OFF_active_daySwitch off bit field: on days and active or inactive
1T1_OFF_hourSwitch off hours 00 to 24
1T1_OFF_minuteSwitch off minutes 00 to 59
2T2_ON_active_dayActivate bit field: on days and active or inactive
2T1_ON_hourSwitch on hours 00 to 24
2T1_ON_minuteSwitch on minutes 00 to 59
2T1_OFF_active_daySwitch off bit field: on days and active or inactive
2T1_OFF_hourSwitch off hours 00 to 24
2T1_OFF_minuteSwitch off minutes 00 to 59
16T16_ON_active_dayActivate bit field: on days and active or inactive

 

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

T1_ON_active_day and T1_OFF_active_day

Bit76543210
ValueactiveSonSatFriThuWedTueMon

For our example we have to enter the following values:

Timer1

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

Bit76543210
ValueactiveSunSatFriThuWedTueMon
Mon-Fri10011111

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:

VariabelValue
T1_ON_active_day159
T1_ON_hour7
T1_ON_minute0
T1_OFF_active_day159
T1_OFF_hour17
T1_OFF_minute0

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

Bit76543210
ValueactiveSunSatFriThuWedTueMon
10100000

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:

VariabelValue
T2_ON_active_day160
T2_ON_hour10
T2_ON_minute0
T2_OFF_active_day160
T2_OFF_hour10
T2_OFF_minute15

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

Bit76543210
TimerNrTimer8Timer7Timer6Timer5Timer4Timer3Timer2Timer1
Bit15141312111098
TimerNrTimer16Timer15Timer14Timer13Timer12Timer11Timer10Timer9

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