The need is to develop a timer, faster, capable to control up to 16 UV fluorescent bulbs.
Up to 2 hours, 1 second precision, display to show the countdown and menu' management, digital encoder for input, pushbuttons/LEDs.
It can be done in thousands ways, but this time I'll try to put it together using Energia and a BIG help from Roberto.
Requirements
The requirements for the first prototype are quite simple:- set up a time between 1 seconds up to 2 hours
- cooling fan activated when lamps ON
- display to show status and settings
- display to show countdown
- LED or indication about the load (lamps) be ON
- LED OFF - lamps OFF
- LED ON - lamps ON
- LED Flashing - ending cycle - push again to reset the timer
- pushbutton to start/stop the timer
So a basic architecture is like this:
Schematic block
The controller is a MSP430F2553 chip.
The encoder is a mechanical digital encoder and the display is a I2C 16 x 2 LCD display (see the shopping list in the end of the article).
A Launchpad G with a MSP430G2553 is used to build the first prototype.
Note ! Originally the idea was to use a MSP430G2452, however some libraries fro I2C seems incompatible with that chipset, probably because the MSP430G2452 has a USI and not an USCI.
Because of that and the fact that the MSP430G2553 has 16Kbte flash, was at the base of the micro choice.
On this first prototype, the cooling fan, needed to keep cool the ballast, is in parallel to the lamps, so when they ON, the fan is ON as well.
Here the pins used, with the Energia notation for the pinmode function.
Pins used :
Pinmode #
|
I/O
|
Use
|
Direction
|
2
|
P1_0
|
Relay (LED on board)
|
Output
|
3
|
P1_1
|
Relay Fan
|
Output
|
4
|
P1_2
|
Pushbutton LED
|
Output
|
5
|
P1_3
|
Start/Stop pushbutton
|
Input
|
6
|
P1_4
|
Buzzer
|
Output
|
14
|
P1_6
|
I2C SCL
|
Output
|
15
|
P1_7
|
I2C SDA
|
--
|
18
|
P2_3
|
Encoder B
|
Input
|
19
|
P2_4
|
Encoder A
|
Input
|
13
|
P2_5
|
Pushbutton encoder
|
Input
|
Software
As mentioned the software is based on Energia, basically a sketch Arduino style.
The code for the timer is hosted on github : https://github.com/TheFwGuy/UVBoxTimer.git
It is a sketch for Energia and use these libraries:
When the timer is powered up, the code initialize the HW and then reads the saved time (if any).
Then the main state machine is set in IDLE and the Setting state machine is set in SET_SECONDS.
It is a sketch for Energia and use these libraries:
- LCD_protocol_terminal
- LCD_screen
- LiquidCrystal
- SD
When the timer is powered up, the code initialize the HW and then reads the saved time (if any).
Then the main state machine is set in IDLE and the Setting state machine is set in SET_SECONDS.
Main state machine
The main state machine is activated by the Start/Stop pushbutton.
There are 6 states:
- IDLE
Waiting to start.
When the Start/Stop button is pushed, the timer starts.
Managing the setting state machine happens ONLY on this state.
When the timer is running the encoder and encoder buttons are ignored.
The state change in START when button pushed. - START
Timer starting preparation.
The I/O and indicators are activated, the timer is initialized with the value set.
The state change in RUN. - RUN
Running timer.
The timer is running.
The Start/Stop button is monitored. If pressed goes to the STOP state.
When the timer expire, goes in ALR state. - ALR
Alarm state. The timer is expired.
In this state an audible notification is generated.
Goes in STOP state. - STOP
Flashing the Start/Stop button LED.
Monitoring the Start/Stop button.
When is pressed, the alarm tone is disabled, the flash LED is stopped and the state is set in END - END
Timer expired/ended.
Reset parameters and set state as IDLE.
Setting state machine
The setting state machine is working only in the IDLE Main state machine state.
When the timer starts is in the initial state SET_SECONDS.
There are two possible actions on the encoder:
- R - rotate
- P - push the button
Rotation scroll values and states, push the button select/change state.
States:
- SET_SECONDS
In this state the rotation of the encoder changes the value of the seconds, from 0 to 59.
Pushing the Encoder button, change the state in SET_MINUTES - SET_MINUTES
In this state the rotation of the encoder changes the value of the minutes, from 0 to 59.
Pushing the Encoder button, change the state in SET_HOURS - SET_HOURS
In this state the rotation of the encoder changes the value of the hours, from 0 to 2.
Pushing the Encoder button, change the state in SET_TIME - SET_SAVINGS
In this state the rotation of the encoder selects the answer, Yes (default) or No.
Pushing the Encoder button confirm the choice and change the state back in SET_SECONDS
In any state is possible to push the Start/Stop button.
It will be used the values set, up to the moment.
Schematic
This a quick and dirty schematic, quite simple.
Shopping list
Here a list of the major component used for the project.
- Timer - Pushbutton/LED https://www.adafruit.com/products/559
- Timer - processor
MSP430G2553
No comments:
Post a Comment