Saturday, October 8, 2011

Triac Dimmer

The inspiration for this project came from the idea of home automation. I wanted to be able to control incandescent lighting using a computer so that I could schedule on/off times and dim levels for each light fixture. Once a link to a computer is established, this project can be adapted for indoor/outdoor architectural lighting, daylight harvesting, and remote operation via the internet.

Features of the TRIAC Dimmer

  • Each module can independently control up to eight separate light channels.
  • Incorporates a CRC-8 error checking algorithm with message specific ACK/NACK responses.
  • The unit is addressable to allow a RS-485 bus implementation of up to 32 modules, allowing the user to control 256 modules per bus.
  • The brightness level incorporates 200 steps, to allow one-half percent brightness change be step.
  • Reporting of current Light Levels and Dim Rates per channel upon request.
  • Storing of up to 10 Light Scenes (Light Level and Dim Rate Combination).
  • A “Fade Rate” is associated with each channel to allow either a gradual or abrupt change in brightness from one setting to another. This “Fade Rate” can be changed at any time.
  • A Windows™ DLL is used to communicate to the device and makes interfacing to a GUI straightforward.
  • Implemented on a AT90s2313 (2K Flash).

Low Level Command Structure

Message Acknowledged:



The Acknowledge message contains the header (0x10), ACK byte (0x06), Sequence Number of ACK'd message (SQ) and a filler byte (0x00).

A message acknowledge is sent once either the receiver or transmitter receives a valid message. A valid message is one where the CRC is valid, and the sequence number is in the correct order.

Message Not Acknowledged:



The Not-Acknowledge message contains the header (0x10), NACK byte (0x15), Sequence Number of NACK'd message (SQ) and a status byte (ST).

A message not acknowledge can be sent in the following situations:

The CRC is not correct, in which case the status (ST) is set to 01
The Sequence Number (SQ) is not in the proper order (missed a message), in which case the status (ST) is set to 02. If the status is set to 02, both transmitter and receiver will reset their sequence numbers to 0 (re-sync).
A duplicate message is received (determined by the sequence number), in which case the status is set to 03.

Message Format:



The message format contains the header (0x10), Message Byte (0xFF), Sequence Number (SQ), Command Byte (CMD), Recipient Address (ADD), Number of bytes in the message (DB), Data Bytes D1..Dn, and the cyclic redundancy check (CRC).

Once a message is transmitted, the originator will wait for a reply (i.e. ACK or NACK). If an ACK is received, then depending on the type of message that was sent, the transmitter will either wait for the receiver to return data, or will proceed to send the next command. If the receiver is required to send back data to the transmitter, the address field is set to 0xFF (reserved).

If either a NACK is sent due to an invalid CRC, or no response is received within the preset response time, the transmitter will repeat the message and again will wait for an ACK. The transmitter will attempt to send a given message three times, after which it will report a communication fault.

A broadcast message can be sent by setting the address to 0x00 (reserved). A broadcast message is the only exception as the receiver(s) are not required to respond.

Command Set


SETLIGHTLEVEL: Sets the light level for all units, or the unit with specific address (ADD) or specific channel of a unit with address (ADD).

GETLIGHTLEVEL: Gets the light level for a specific unit with address (ADD).

SETFADERATE: Sets the fade rate for all units, or the unit with specific address (ADD) or specific channel of a unit with address (ADD).

GETFADERATE: Gets the fade rate setting for a specific unit with address (ADD).

SAVESCENE: Stores the current light level and fade rate of all units (or specific unit of address ADD) to location D1.

RECALLSCENE: Recalls the scene stored at location D1 for all units (or specific unit of address ADD).

GETDYNAMICLEVEL: Gets the current light level for a specific unit of address (ADD). This is used mainly for the GUI interface to see the light levels changing dynamically.

Here are a few pictures of a single unit with only four of the possible eight channels enabled:


Here is a picture of the Visual Basic interface created with the Windows™ DLL:


October 14th, 1999

No comments:

Post a Comment