Skip to content

Commit

Permalink
updating content
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccreary committed Jan 8, 2025
1 parent 221e2c2 commit 13d4e07
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
Binary file added docs/img/rtc-ds3231-aliexpress.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 24 additions & 13 deletions docs/kits/tm1637/running-clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,58 +64,69 @@ if __name__ == '__main__':
run_clock()
```

## Core Concepts

Let's break down the key concepts students need to understand:

1. **Real-Time Clock (RTC)**
### 1. Real-Time Clock (RTC)

- The RTC is a hardware component that keeps track of time
- It continues running even when the microcontroller is reset
- Time is stored as a tuple: (year, month, day, weekday, hours, minutes, seconds, subseconds)
- Students should understand why RTCs are important for accurate timekeeping

2. **Time Formats**
### 2. Time Formats

- 24-hour vs 12-hour time conversion
- Why we need to handle special cases (midnight = 0 hours → 12, noon = 12 stays 12)
- The concept of AM/PM

3. **Display Multiplexing**
### 3. Display Multiplexing

- How LED displays show multiple digits (though the TM1637 handles this internally)
- Why we need a brief sleep to prevent display flicker
- How brightness control works with PWM (Pulse Width Modulation)

4. **State Management**
### 4. State Management
- Tracking the colon state for blinking
- Maintaining previous second value to detect changes
- Why we use global variables in this context

5. **Program Structure**
### 5. Program Structure
- Main loop design
- Function organization
- Error handling (not shown but important in real applications)

Common challenges students might encounter:
## Common challenges

Here are some challenges students might encounter:

### 1. Time Drift

1. **Time Drift**
- The RTC might drift slightly over time
- In real applications, you'd want to sync with an NTP server periodically

2. **Power Management**
### 2. Power Management

- Display brightness affects power consumption
- Consider dimming display in low light conditions
- Think about battery life in portable applications

3. **User Interface**
### 3. User Interface

- Adding buttons to set the time
- Handling time zone changes
- Adding features like alarms or timers

Extensions students could try:
## Extensions

Here are some additional projects that students could try:

1. Add a temperature display that alternates with the time
2. Implement automatic brightness control using a light sensor
3. Add alarm functionality with a buzzer
4. Create a menu system for setting the time
5. Add a battery backup system

Would you like me to elaborate on any of these concepts or provide example code for any of the extensions?

For reference, this code builds on the concepts shown in your clock-driver.py file, but simplifies the implementation thanks to the TM1637's built-in controller. The course-description.md suggests this would fit well in the early stages of your course, particularly during the "Understanding" phase where students explore how timing functions and hardware work together.
For reference, this code builds on the concepts shown in our
```clock-driver.py``` file, but simplifies the implementation thanks to the TM1637's built-in controller.
39 changes: 25 additions & 14 deletions docs/setup/02-purchasing-parts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ We use eBay for purchasing all our breadboards.
Many of our projects use the 1/2 size 400-tie breadboards. This is usually
sufficient for simple projects.



## MicroControllers

Because all or examples run MicroPython, your microcontroller will also need to run MicroPython.
Expand Down Expand Up @@ -58,26 +56,39 @@ We like the 2.42" inch OLED displays since they are bright and have a wide viewi

## Smartwatch Displays

## Real-Time Clock Boards
## Real-Time Clocks

Learning how to use a real-time clock (RTC) is a core part of building
digital clocks. So almost all our kits include an RTC. Here is
a description of the two main options for RTCs.

### The DS1307
![](../img/rtc-ds1307-front-back.jpg)

Although this board is old, it is a simple and low-cost part that is easy to use.
Most of the development boards come with their own crystal and an I2C interface.
Although the DS1307 is has been around for a long time, it is still a simple low-cost part that is easy to use. The DS1307 is still perfectly suitable for many basic timekeeping applications and for learning how to use a
Most of the development boards come with their own crystal and an I2C interface. Most of our clock kits have now been upgraded to the newer more accurate DS3231 which we can also purchase for under $1.

### The DS3231

![](../img/rtc-ds3231-front-back.jpg)

The DS3231 is one of the most commonly used real-time clock (RTC) modules paired with microcontrollers like the Raspberry Pi Pico. It's popular because it:

1. Has high accuracy (temperature-compensated crystal oscillator)
2. Maintains accuracy over a wide temperature range
3. Has built-in temperature compensation
4. Uses the I2C interface, which is easy to implement
5. Includes a battery backup option
6. Is relatively inexpensive
1. Has high accuracy (temperature-compensated crystal oscillator) +/- 2 seconds per month
2. Maintains accuracy over a wide temperature range suitable for indoor and outdoor use
3. Uses the I2C interface, which is easy to implement
4. Includes a 3V lithium coin-cell battery backup option which allows it to remember the time and alarm settings even when the power is off
6. Is relatively inexpensive (under $1 each)
7. Has extensive library support across different platforms

The second most common is probably the DS1307, which is an older and simpler version. While less accurate than the DS3231, it's even less expensive and still perfectly suitable for many basic timekeeping applications.
8. You can also use it to display the temperature
9. Includes the ability to store 4K in EEPROM for information such as when alarms and timers should go off

For microcontrollers in particular, the DS3231 tends to be favored because its accuracy doesn't depend on the microcontroller's clock, and it maintains accurate time even when the main microcontroller is reset or loses power.

Since this is quite specific technical information and while I believe this is accurate, you may want to verify these details, particularly regarding current market availability and relative popularity.
Here is an example of a DS3231 listing on eBay for under $1:

![](../img/rtc-ds3231-ebay.png)

AliExpress currently has the DS3231 boards listed for $0.73 each.

![](../img/rtc-ds3231-aliexpress.png)

0 comments on commit 13d4e07

Please sign in to comment.