Vermes
Advanced Member level 4
It is a watch and thermometer constructed on AT91SAM7S64.
This project was made to learn something more about software support of:
- graphical display of the Nokia 3310
- incremental encoder
- DS18B20 thermometer system
Schema of this system is very simple. In fact it consists of elements of EVBsam7s runtime set schema, which are necessary to build and activate this system with attached display, thermometer system and encoder. After building this system, programming the microcontroller and activating the whole, the face of the watch appears on the display, hands point 12 o'clock and temperature value measured by DS18B20 is also displayed. Setting the correct time is done by turning the encoder (turning right – moves hands towards, turning left – opposite) – the same as in traditional hand watches.
The program of the watch was written in Rowley Crossworks for ARM v.1.7. The program works like this: the mocrocontroller counts interrupts induced each 500ms by TC0 timer. In the procedure of supporting the interrupt, tick variable takes the true value. Temperature can be read from the sensor each 500ms period (if the tick variable is false), while refreshing the displayed temperature value after the expiry of each 500ms period (the tick variable is then true). At the same time a value of the divisor is increased by 1. When the value of this variable is equal to 2 (another second passed), then the program accordingly increases by 1 the values of variables: rotation_second_hand, rotation_minute_hand and rotation_hour_hand.
New values of those variables are then used to calculate new coordinates of hand's ends. Those coordinates are used by glcd_line function, which draws the hands on the face of the watch. The calculations of coordinates of hands' ends are done by trigonometric functions and then rounded to integer values required by the above mentioned glcd_line function.
The handling of encoder was made with help of external interrupt IRQ1, which is called via falling edge of pulses occurring at once encoder output, plugged into the pin PA30. The procedure of handling this interrupt checks then logic level on the pin PA29 and dependent on that level, it sets correctly and zeroes variables: rotation_left and rotation_right, which in the next part of the program give the information about the direction of the encoder rotations. The information is then used to suitable decrease or increase the variables rotation_minute_hand and rotation_hour_hand and setting the variable rotating_second_hand on the value of 45 (so it points 12 o'clock during setting the time) and drawing the hands on this basis in new positions during a time setting.
The encoder working is showed in the picture (logic levels on the pins PA29 and PA30 and active the edge triggering IRQ1 interrupt).
Link to original thread (video + attachment) – Zegarek wskazówkowy i termometr na LCD graficznym Nokia3310