Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/diuPublic

Digital (Analog) Clock

License

NotificationsYou must be signed in to change notification settings

0x007E/diu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Version: 1.0 ReleaseBuildLicense CC By-NC-SA

DIU - Digital (Analog) Clock (Digitaluhr)

TheDIU project is based on a pcb with anATtiny1606 a RTCMCP7940 a USB/UART bridgeFT232RL and a set of74HC595 shift register. It can be used to display time and date on 84LEDs that are mounted in 3 circles to the top pcb. The clock itself can be setup over UART and a terminal software (e.g. TeraTerm).

ExperienceLevel
Soldering?%
Mechanical?%
Software?%

Downloads

TypeFileDescription
Schematicpdf /cadlabSchematic files
Boardpdf /cadlabBoard file
DrillpdfDrill file
Gerberzip /tarGerber/Drill files
Housing, PCBzip /tarHousing and PCB (STEP) files
Firmwarezip /tarFirmware for ATtiny1606

Hardware

There are two parts of the hardware. The pcb and the housing of theDIU. The pcb is created withKiCAD and the housing withFreeCAD. The software is programmed withMicrochip (Atmel) Studio. All files are built withgithub actions so that they are ready for a production environment. The housing is printed with a 3D-printer (Dremel 3D40).

PCB

The circuit board is populated on both sides (Top, Bottom). The best way for soldering theSMD components is within a vapor phase soldering system and for theTHT components with a standard soldering system. After placing and soldering the top parts, the board has to be cut off in the middle (white edge).

Top Layer

Top Layer

Bottom Layer

Bottom Layer

Mechanical

The housing has a tolerance of0.2mm on each side of the case. So the pcb should fit perfectly in the housing. The tolerance can be modified withFreeCAD in theParameter Spreadsheet. The corners of the circuit board need to be sanded a little.

Assembled

Assembled

Exploded

Exploded

Programming/Setup

TheDIU can be powerd with5V from USB or an external source through connectorJ1. OverUPDI (J3) theDIU can be programmed withavr-dude or anMicrochip (Atmel) ICE adapter. To setup theDIU it can be connected over USB to a computer and configured with a terminal (e.g.TeraTerm) software. The firmware for the clock can be downloaded from thedownload section.

FUSES

RegisterValue
WDTCFG0x00
BODCFG0x00
OSCCFG0x02
TCD0CFG0x00
SYSCFG00xF5
SYSCFG10x00
APPEND0x00
BOOTEND0x00

To setupRESET (PA0) it is necessary to change theSYSCFG0-FUSE of theATtiny1606. WARNING: To reset thePA0 pin toUPDI mode a12V impulse is necessary to program the FUSES again.

Firmware

The firmware of theDIU project can be downloaded and modified withMicrochip Studio. The software can be found in the./firmware directory and is splitted into different libraries. They can be found in the./firmware/lib` folder. Feel free to modify the firmware to your own needings.

Dataflow diagram

Dataflow

UART Setup

To configure theDIU through UART (USB/UART bridge) a connection over USB to a computer and a terminal software (e.g.Teraterm is necessary. To start the setup the following settings need to be configured in the terminal. Then hit a key during init process in the terminal.

NameValue
PORTCOM?
BAUD9600
DATABITS8
PARITYNONE
STOPBITS1
FLOWCTRLNONE

Connection setup

# +--------------------------------------------------+# |       ~------------------+                       |      +---------------------+# |      ~  ATTINY 1606      |                       |      |                     |# |     ~                  +-+-+                     |      | +-----------------+ |# |    ~               VCC | 1 |          +----------+      | | TeraTerm        | |# |      ~             PB0 | 2 |          |   U  +---+---+  | | ~~~~~~~~        | |# |        ~           PB1 | 3 |          |   S  |  USB  |--+ | ~~~~~           | |# |         ~    (TxD) PB2 | 4 +-----+    |   B  +---+---+  | | ~~~~~~~~~~~~    | |# |        ~     (RxD) PB3 | 5 +--+  |    |   /      |      | |                 | |# |       ~            GND | 6 |  |  |    |   U      |      | +-----------------+ |# |     ~                  +-+-+  |  |    |   A      |      |                     |# |    ~~~~~-----------------+    |  |  +-+-+ R      |      | Computer            |# |                               |  +--+TxD| T      |      |                     |# |  DDD   IIIIII UU  UU          +-----+RxD| +------+      +---------------------+# |  D  D    II   UU  UU                +-+-+ |5V/3V3|# |  D  D    II   UU  UU                  +----+-----+# |  DDD   IIIIII  UUUU                              |# +--------------------------------------------------+

Enter configuration menu

To enter into the configuration mode it is necessary to press akey during startup.

Press a Key

The configuration starts and a menu to setup theDIU appears.

# +------------------------------------------------+# | System Configuration                           |# +------------------------------------------------+# | [1] Time and Date                              |# | [2] Alarm                                      |# | [3] Alarm Tone                                 |# | [4] LED Intensity                              |# | [5] Oscillator                                 |# | [d] Discharge changes                          |# | [q] Exit configuration                         |# +------------------------------------------------+# Input:

TWI-Configuration

TheDIU itself uses aRTC (MCP7940) with a power reserve (battery) to store the time. Thefirmware is connecte to theRTC overTWI. The twi configuration is stored intwi.h and the rtc configuration inmcp7940.h file.

Connection betweenATtiny1606 andMCP7940

# +----------------------------------------------------------------------------------------------------+# |                               VCC VCC                                                              |# |                                ^   ^                                                               |# |                                |   |                                                               |# |                             R +++ +++ R                                                            |# |                             9 | | | | 1                                                            |# |       ~------------------+  9 | | | | 0                                J                           |# |      ~  ATTINY 1606      |    +++ +++ 0    +---------------------+     1    ~~~~~~                 |# |     ~                  +-+-+   |   |     +-+-+                 +-+-+   8   ~  3   ~                |# |    ~               VCC | X +---|---|-----+ 8 | VCC         BAT | 3 +--(X)-+   V    +------| GND    |# |    ~         (SCL) PB0 | 0 +---+---|-----+ 6 | SCL             +-+-+       ~  0   ~                |# |     ~        (SDA) PB1 | 1 +-------+-----+ 5 | SDA      M        |          ~~~~~~   C30           |# |       ~            PB2 | 2 |             +-+-+          C      +-+-+                 ||            |# |        ~           PB3 | 3 |           +-+ 5 | MFP      P   X! | 1 +----------+------||----| GND   |# |         ~          PB4 | 4 |          /  +-+-+          7      +-+-+         ---     ||            |# |         ~          PB5 | 5 |         /     |            9        |         +-----+                 |# |        ~           PB6 | 6 |        /    +-+-+          4        |         |  Y1 | 32.768 kHz      |# |       ~            GND | X +-------/-----+ 4 |          0        |         +-----+                 |# |      ~                 +-+-+      /      +-+-+                 +-+-+         ---     ||            |# |     ~                    |       /         |                X2 | 2 +----------+------||----| GND   |# |     ~                  +-+-+    /          |                   +-+-+                 ||            |# |      ~                 ~   ~   /           +---------------------+                   C31           |# |       ~                ~   ~  /                                                                    |# |        ~           PA7 | 7 +-+             DDD   IIIIII UU  UU                                     |# |         ~              +-+-+               D  D    II   UU  UU                                     |# |         ~                |                 D  D    II   UU  UU                                     |# |        ~-----------------+                 DDD   IIIIII  UUUU                                      |# +----------------------------------------------------------------------------------------------------+

TWI Parameter

To read and save parameters in thRTC overTWI the bus is configured with the following setup:

ParameterValueDescription
Speed400kHzBus clock speed

Detail can be foundhere

RTC-Commands

voidmcp7940_init(RTC_Modebattery);voidmcp7940_battery(RTC_Modemode);voidmcp7940_oscillator(RTC_Modemode);unsignedcharmcp7940_oscillator_value(void);voidmcp7940_oscillator_copy(Copy_Modemode);RTC_Statusmcp7940_powerfail_status(void);RTC_Statusmcp7940_oscillator_status(void);constchar*mcp7940_weekday_string(unsignedcharday);unsignedcharmcp7940_hour(RTC_Datadata);unsignedcharmcp7940_minute(RTC_Datadata);unsignedcharmcp7940_second(void);unsignedcharmcp7940_weekday(RTC_Datadata);unsignedcharmcp7940_day(RTC_Datadata);unsignedcharmcp7940_month(RTC_Datadata);unsignedcharmcp7940_year(void);unsignedcharmcp7940_leapyear(void);RTC_Statusmcp7940_setweekday(unsignedcharweekday);RTC_Statusmcp7940_settime(unsignedcharhour,unsignedcharminute,unsignedcharsecond);RTC_Statusmcp7940_setdate(unsignedcharday,unsignedcharmonth,unsignedcharyear);RTC_Statusmcp7940_setoscillator(unsignedchartrim);

SPI-Configuration

Thefirmware itself is driving the LEDs overSPI through eleven74HC595 shift registers. The spi configuration is stored in theclock.h andspi.h files.

Connection betweenATtiny1606 and74HC595

# +------------------------------------------------------------------------------------------------------+# |                                     +----------------------------... ~ ...------------------------+  |# |       ~------------------+         /            START(1)            ~             END(11)         |  |# |      ~  ATTINY 1606      |        /        +---------------+       ~         +---------------+    |  |# |     ~                  +-+-+     /       +-+-+  74HC595  +-+-+    ~        +-+-+  74HC595  +-+-+  |  |# |    ~               VCC | X +----/--------+ 16|    VCC    |16 |-.. ~ ....---+ 16|    VCC    |16 |  |  |# |    ~               PA0 | 0 |   /         +---+           +-+-+     ~       +---+           +-+-+  |  |# |     ~       (MOSI) PA1 | 1 +--/----------+ 14| SER    QH | 9 |--... ~ ...--+ 14| SER    QH | 9 +--+  |# |       ~     (MISO) PA2 | 2 +-+           +---+           +-+-+       ~     +---+           +-+-+     |# |        ~     (SCK) PA3 | 3 +-------------+ 11|   SRCLK   |11 |----... ~ ..-+ 11|   SRCLK   |11 |     |# |         ~     (SS) PA4 | 4 +-------------+ 12|    RCLK   |12 |----... ~ ..-+ 12|    RCLK   |12 |     |# |         ~  (CLEAR) PA5 | 5 +-------------+ 10|   SRCLR   |10 |---... ~ ...-+ 10|   SRCLR   |10 |     |# |        ~  (OUTPUT) PA6 | 6 +-------------+ 13|     OE    |13 |--... ~ ...--+ 13|     OE    |13 |     |# |       ~            GND | X +-------------+ 8 |    GND    | 8 |-... ~ ...---+ 8 |    GND    | 8 |     |# |     ~                  +-+-+             +-+-+           +-+-+    ~        +-+-+           +-+-+     |# |    ~~~~~-----------------+                 +--+~~~~~~~~~+--+      ~          +--+~~~~~~~~~+--+       |# |                                               |         |          ~            |         |          |# |  DDD   IIIIII UU  UU                         ---  LED  ---          ~          ---  LED  ---         |# |  D  D    II   UU  UU                         \ /       \ /           ~         \ /       \ /         |# |  D  D    II   UU  UU                          |         |             ~         |         |          |# |  DDD   IIIIII  UUUU                           |         |             ~         |         |          |# +------------------------------------------------------------------------------------------------------+

SPI Parameter

To control the LEDs through the shift registers overSPI the bus is configured with the following setup:

ParameterValueDescription
ClockF_CPU/4Bus clock speed is system speed divied by 4
DirectionMSBMSB needs to be transmitted first
PolarityRisingPolarity of clock is rising_/
PhaseRisingData is valid when clock is rising_/

Detail can be foundhere

SPI Frame

# SPI display transmission# _                                                SS                                                   _#  \__________________________________________________~~~______________________________________________/#                                                 SCK#     __    __    __    __    __    __    __    __       __    __    __    __    __    __    __    __# ___/1 \__/2 \__/3 \__/4 \__/5 \__/6 \__/7 \__/8 \__~~~/81\__/82\__/83\__/84\__/85\__/86\__/87\__/88\___#                                                 MOSI#    __    __    __    __    __    __    __    __       __    __    __    __    __    __    __    __# __/H \__/O \__/U \__/R \__/  \__/  \__/  \__/  \__~~~/M \__/I \__/N \__/  \__/L3\__/L2\__/L1\__/L0\____#   \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/     \__/  \__/  \__/  \__/  \__/  \__/  \__/  \__/#    [7                   :                    0]    [7                   :                    0]## L[3:0] ... LEDs on the backside of the pcb for signaling

Clock-Commands

voidclock_init(void);voidclock_output(CLOCK_Statusstatus);voidclock_clear(void);unsignedintclock_intensity(void);CLOCK_Errorclock_setintensity(unsignedintintensity);voidclock_copy_intensity(Copy_Modemode);CLOCK_Errorclock_settime(unsignedcharhour,unsignedcharminute,unsignedcharsecond,CLOCK_Status_LEDstatus);CLOCK_Errorclock_setdate(unsignedcharday,unsignedcharmonth,CLOCK_Status_LEDstatus);voidclock_setdata(unsigned longdata24,unsigned long longdata60,CLOCK_Status_LEDstatus);voidclock_saveintensity(void);

Additional Information

TypeLinkDescription
ATtiny1606pdfATtiny microcontroller
MPC7940pdfBattery-Backed I2C Real-Time Clock/Calendar with SRAM
FT232RLpdfUSB Full Speed to Serial UART IC, Includes Oscillator and EEPROM
74HC595pdf8-Bit Shift Registers With 3-State Output Registers
Atmel ICEpdfAtmel ICE datasheet
UPDIwebUPDI-Adapter with AVR-Dude
Microchip StudiowebDownload page for Microchip Studio
KiCADwebKiCAD project page
FreeCADwebFreeCAD project page
TeraTermwebTerminal software for UART

R. GAECHTER


[8]ページ先頭

©2009-2025 Movatter.jp