SHC Power Switch

Power Switch

Purpose

An SHC power switch circuit can be used to switch a low or high voltage. It can be controlled remotely by SHC commands via the base station as well as manually by a switch or a toggle button.

A special feature is its timer function. Using the function, the switch changes its state (e.g. from Off to On) after reception and automatically changes it back after the given amount of time, independent from an existing connection to the base station. This makes sure it switches again even if radio transmission is not possible from whatever reason. As a use case, think about a water pump for plants which automatically switches off after 30 seconds.

Besides a power socket, you could also use the circuit to control other home appliances by connecting their buttons to the relay.

Functions, Behavior

The status can be retrieved with a "Get" or changed with a "Set" or "SetGet". The current state is broadcasted every 30 minutes and some seconds after a change with a "Status". The firmware version is sent about once a day.

Optional Physical Switch

With an additional switch which is connected to an IO pin, the relais state can be calculated as a combination of the state requested by one of the supported messages (e.g. DigitalPin) and the status of the switch. Additionally, the change of the switch state to 'on' or 'off' can be considered with a delay. This means that the resulting relais state is also changed only when the switch stays in that state at least as long as the delay time. The behaviour can be configured in the e2p.

Currently, only one switch is supported on PB7. If you need more, let me know. I'll extend the functionality then.

Use Cases
  • Override the normally automatic switching of a relais (by your SHC control logic) with a physical switch temporarily ("forced on" / "forced off").
  • Intelligent kitchen hood control that switches it off in case a wood-burning stove is on and the window in the kitchen is not open. This is needed in Germany when the kitchen hood extracts the air to the outside. An environment sensor can be used to detect the temperature and therefore status of the stove. A window sensor connected to the power switch can detect if the window is open.
  • Control of the operating time of a robotic lawn mower by interrupting the power supply in the times the mower shall not work. By using a reed contact to detect the mower being in the changing station and using switch mode and switch delay values in the e2p, it is ensured that the mower is charged at least some time after it enters the charging station.
Calculation Logic

In general, the status according digital pin/port command (CMD) and the switch (SW) can be combined by 'and', 'or' or 'xor'. Additionally the switch can be active open or active close and therefore can be inverted ('not'). The resulting settings are as follows:

  • CMD (default): Relais is set according received messages, switch is ignored / not connected.
  • SW: Relais is set according the connected switch only.
  • not SW: Relais is set according the connected switch only (with inverted logic).
  • CMD and SW: Relais is on only if requested by command and the switch is on.
  • CMD and not SW: Relais is on only if requested by command and the switch is off (inverted logic).
  • CMD or SW: Relais is on if requested by command or when switch is on.
  • CMD or not SW: Relais is on if requested by command or when switch is off (inverted logic).
  • CMD xor SW: Relais is on if request by command and switch state differ.
  • CMD xor not SW: Relais is on if request by command and switch state differ (inverted logic).

The other theoretically possible combinations don't make sense, because the relais would never be switched or the status as requested by a message would be inverted only.

Supported Messages

  • Generic_Version_Status
  • GPIO_DigitalPort_Set
  • GPIO_DigitalPort_SetGet
  • GPIO_DigitalPort_Ack
  • GPIO_DigitalPort_AckStatus
  • GPIO_DigitalPortTimeout_Set
  • GPIO_DigitalPortTimeout_SetGet
  • GPIO_DigitalPortTimeout_Ack
  • GPIO_DigitalPortTimeout_AckStatus
  • GPIO_DigitalPin_Set
  • GPIO_DigitalPin_SetGet
  • GPIO_DigitalPinTimeout_Set
  • GPIO_DigitalPinTimeout_SetGet

E2P Device Configuration

OffsetBlockContentTypeSizeDescription
0Hardware
Values for hardware setup, which have no special meaning to SHC device concepts + the DeviceType, which decides about the existence of further blocks.
DeviceTypeEnumValue1 BytesThe device can check with this value if the EEPROM data is meant for the actual type of device. If not, the device goes into an error mode.
Values: 0 = BaseStation, 20 = EnvSensor, 40 = PowerSwitch, 45 = Controller, 50 = RGBDimmer, 60 = Dimmer, 70 = SoilMoistureMeter, 80 = Thermostat, 90 = TeaMaker
8OsccalModeIntValue1 BytesThis value is used to change the speed of the internal oscillator. 0 = don't use OSCCAL calibration (e.g. external crystal oszillator is used). -128 = OSCCAL measure mode: the LED blinks every 60s, so the user can measure the original speed. -127..+127 = The speed is adjusted by the given amount in per mill (e.g. 10 means to speed up the device by +1%).
MinVal: -128, MaxVal: 127, Default: 0
16Reserved6 Bytesn/a
64Generic
This block contains SHC configuration data which every device has.
DeviceIDUIntValue12 BitsThe DeviceID identifies the specific unit in the SHC network. It is used to address the device and in messages the device sends. Every device has to have a different DeviceID.
MinVal: 0, MaxVal: 4095
76Reserved4 Bitsn/a
80PacketCounterUIntValue3 BytesThe PacketCounter is counted up throughout the whole lifetime of the device and is used to make the encrypted packets differently from each other every time.
MinVal: 0, MaxVal: 16777215
104Reserved19 Bytesn/a
256AesKeyByteArray32 BytesThis key is used to encrypt packets before sending and also used as primary key to decrypt packets. Special devices may have additional keys in their device specific block.
512PowerSwitch
This block contains the specific configuration data that only Power Switch devices need.
BaseStationPacketCounterUIntValue3 BytesThis is the last remembered packet counter of a command from the base station. Packets with the same or lower number are ignored.
MinVal: 0, MaxVal: 16777215
536TransceiverWatchdogTimeoutUIntValue1 BytesReset RFM12B module if no data is received until timeout is reached. Use this function if your specific transceiver hangs sometimes. Value is in deca seconds. Suggested setting is 48 (for 8 minutes). Set 0 to disable.
MinVal: 0, MaxVal: 255, Default: 48
544StatusCycleUIntValue1 BytesThis is the number of minutes after which the status should be resent, so in case of a lost message it can be received again. Set 0 to disable.
MinVal: 0, MaxVal: 255, Default: 30
552SupportedSwitchesUIntValue1 BytesThis is the number of connected switches.
MinVal: 1, MaxVal: 3
560CMDStateBoolValue[8]1 Bytes x 8This field stores the switch state(s) which were requested by one of the supported 'set'/'setget' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!
624CMDTimeoutUIntValue[8]2 Bytes x 8This field stores the timeout value(s) which were requested by one of the supported 'set'/'setget' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!
MinVal: 0, MaxVal: 65767
752SwitchModeEnumValue[8]1 Bytes x 8The mode decides how the optional manual switches are used in combination to the digital pin/port commands to set the relais status. In general, the status according digital pin/port command (CMD) and the switch (SW) can be combined by 'and', 'or' or 'xor'. Additionally the switch can be active open or active close and therefore can be inverted ('not'). 'CMD' and '(not) SW' mean that only the command or switch are considered. The default value is to ignore the optional manual switch.
Values: 0 = CMD, 1 = SW, 2 = not SW, 3 = CMD and SW, 4 = CMD and not SW, 5 = CMD or SW, 6 = CMD or not SW, 7 = CMD xor SW, 8 = CMD xor not SW, Default: 0
816SwitchOnDelayUIntValue[8]2 Bytes x 8This field contains for the 8 switches the times in seconds after which the change of a switch to state "ON" is considered to affect the relais state. If the switch changes to "OFF" again within the delay time, it is cleared and no change of the relais state will happen. If the relais state is changed via command within the delay time, the relais state will consider the old switch state until the delay time is over. After restart (power loss), the delay will not be considered, so the switch state is considered immediately.
MinVal: 0, MaxVal: 65535, Default: 0
944SwitchOffDelayUIntValue[8]2 Bytes x 8This field contains for the 8 switches the times in seconds after which the change of a switch to state "OFF" is considered to affect the relais state. The behaviour is equivalent to SwitchOnDelay.
MinVal: 0, MaxVal: 65535, Default: 0
1072Reserved890 Bytesn/a

Hardware Overview

PCBPower Switch 1 PCB (Conventional THTThrough hole technology This is the conventional technique to stick pins of components through the PCB and solder them. This is easy to build up, unlinke using SMD components., non-SMD)
50 x 50 mm
MicrocontrollerATMega 328A-PU (28-pin PDIP)
Clock Source8 MHz internal R/C oscillator
Special Components Voltage regulator: voltage regulator 3,3V (TS 2950)
Relay: to connect to the device you want to switch.
RFM Transceiver ModeTX + RX
UARTonly debug TX
Power5V with internal 3.3V regulator

Schematic

Layout

Download

Assembly Instructions

Look into the Wiki for assembly instructions for this device. It would be appreciated if you correct or enhance the description whenever you find potential for improvement.

This device uses high voltage. Build and use it at your own risk! Be careful when applying the operating voltage! If you are not familiar with handling high voltages or not allowed to build or use this kind of devices, don't do so.