This is another beautiful semi-transparent glass mosaic design made by my wife Mieke, combined with electronics and mechanics to create a moving sunrise and sunset using surface mounted LEDs that are moving up and down behind the glass mosaic.
The glass mosaic pieces are glued onto 4mm thick plexiglass, so the LED light will shine through the plexiglass and the mosaic pieces. Because the glass mosaic is semi-transparent, the light of the LEDs gets diffused when distance between the SMD LEDs and the glass mosaic is more than about 0.5 cm.
The challenge in this project was to make or find mechanics (stepper motor, gearbox, belt with pulley) that was thin enough to fit within a total height of about 3.5mm.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: System Diagram
The project is driven by 2 small 8-pin Microchip PIC12F683 microcontrollers that are running at their internal 8MHz clock :
- one PIC12F683 microcontroller is used to control the LEDs and is located on the sun-PCB that holds the SMD LEDs for the sun body and sun rays.
The sun gets a SUN ON/OFF signal from the stepper motor controller that read the home and end-switches. When the home or end switch becomes active, the stepper motor controller instructs the sun to start either the sunrise or sunset lighting sequence, via this SUN ON/OFF signal.
- one PIC12F683 microcontroller is used to control a bipolar stepper motor, that moves a pivoting arm holding the sun-PCB. To give the stepper motor enough torque, a small gear system and a pulley with belt is used.
The stepper motor controller controls the bipolar stepper motor using a dedicated current limited stepper motor driver that is configured for1/16 microstepping so the motor moves very slow,
The stepper.motor controller polls the home and end switches and reverses the motor when one of the switches becomes active. At the same time it instructs the sun to either start the sunrise or the sunset.
The "sun" is made with a 25 yellow LEDs and 25 red LEDs that are positioned around 2 circles that form the body of the sun.
Another 8 yellow LEDs form the sun-rays.
All LEDs are surface mount (SMD) types and are assembled on a PCB,
The PCB is mounted on a pivoting arm that is moved by a stepper motor using a gear box and a belt with pulleys.
Step 3: Sun Controller
The LEDs are controlled by software PWM using 3 digital outputs, buffered by medium power transistors capable of sourcing enough current for the LEDs:
- 1 digital output for the red LEDs of the sun body,
- 1 digital output for the yellow LEDs of the sun body and
- 1 digital output for the yellow sun rays.
The software PWM is compensated using a lookup table with an exponential curve, so the LED brightness changes linearly. This compensation is because the human eye has a logarithmic brightness perception.
At power on, the stepper motor moves the pivoting-arm back to the home position. When the home position is reached, the arm pushes against the home microswitch and closes the switch.
The switch is polled by the stepper motor controller and when the switch is detected as closed, the stepper motor controller reverses the motor. Simultaneous the stepper controller tells the LED controller to restart the sunrise lighting sequence via the SUN ON/OFF signal.
This sunrise lighting sequence starts with the red LEDs at low intensity to simulate the start of a sunrise.
While the sun rises, the intensity of the red LEDs is increased.
At a certain moment, the yellow LEDs are also illuminated at low intensity.
Then the intensity of the yellow LEDs is gradually increased, while the intensity of the red LEDs is gradually decreased.
This results in a red sun, that changes over an orange into a yellow sun.
When the sun is further up, the intensity of the sun rays is gradually increased and when the rays are at maximum intensity, the rays are randomly switched on and off very fast. This creates a flickering effect.
When the sun is fully up, the pivoting arm pushes against the end switch, causing the switch to close. The switch is continuously polled by the stepper motor controller and when the controller detects that the end switch is closed, it reverses the motor. Simultaneous the stepper motor controller tells the sun controller to start the sunset lighting sequence, via the SUN ON/OFF signal.
The sunset lighting sequence is the reversed sunrise lighting sequence.
When the pivoting arm reached the home switch again, the whole sequence is repeated again.
So the sun keeps rising and setting continuously.
One sunrise or sunset takes about 4 minutes.
Step 4: Stepper Motor Controller
The stepper motor is a small bipolar stepper motor that is connected to a Pololu DRV882 microstepping bipolar stepper motor driver with adjustable current limiting.
The stepper driver is capable of delivering about 1,5A per phase without using a heat sink for the stepper chip. This is more than enough for the small stepper driver that we are using for this project.
The stepper motor is connected to a gearbox that drives a belt via pulleys to increase the torque.
The stepper motor driver is configured for 1/16 microstepping so it can move very slowly.
The stepper motor driver is controlled by the stepper motor controller via the MOTOR STEP and MOTOR DIR signals. This way the stepper motor controller can move the stepper motor in the desired direction with the desired amount of steps.
To move the stepper motor by an amount of steps, the MOTOR STEP signal needs to be pulsed with as many pulses as the amount of microsteps that we want the motor to move.
The MOTOR DIR signal is used to change the direction of the motor.
With the MOTOR DIR low, the motor will f.e. step clockwise and with the MOTOR DIR high, the motor will step counter clockwise.
The home and end microswitches are normally open switches that switch to ground.
The internal pull ups of the PIC12F683 GPiO port are activated, so the home and end switch signals are +5V when the switch is open and 0V when the switch is closed.
The SUN ON/OFF signal is set to 0 by the stepper motor controller when the home or end switch is reached and is set to 1 when the home or end switch is released again.
The sun controller continuously polls this SUN ON/OFF signal to check whether to start the sunrise or sunset lighting sequence.
During building the project, i decided to use only 1x 7805 voltage regulator to power both the stepper motor controller AND the sun controller, because the power needed for the stepper motor was less than i expected.
I increased the heatsink for the for the 7805, so it is capable of driving both controllers without getting hot.
The total maximum power consumption, with the red and yellow LEDs at maximum intensity and the stepper motor running, is about 600mA.
Step 5: Build Pictures
For more information, see the comment boxes in the pictures
Step 6: Firmware for the PIC12F683 Sun Controller
This is the firmware for the Microchip PIC12F683 sun controller.
Step 7: Firmware for the PIC12F683 Stepper Motor Controller
This is the firmware for the Microchip PIC12F683 stepper motor controller.