toothache

[RA] Perpetual calendar based on Renesas R7FA2E1A72DFL

 
Overview

Perpetual calendar based on Renesas R7FA2E1A72DFL

Based on the perpetual calendar of Renesas R7FA2E1A72DFL, the clock uses the internal rtc of the microcontroller and supports lunar calendar display, temperature and humidity detection, brightness detection, external Bluetooth chip for timing, temperature and humidity broadcast and other operations. The microcontroller drives 64 ws2812s, lights up LEDs at specific locations, and displays clock and date information.

If you are interested, you can join the Q group

28304718.png

source of inspiration

https://hackaday.io/project/57535-dulles-clock
https://hackaday.io/project/169194-8x8-rgb-ledmatrix-desktop-word-clock
https://hackaday.io/project/163848- japanese-word-clock
https://hackaday.io/project/3305-word-clock
https://www.youtube.com/watch?v=fYtS_n_GhCY&t=856s

The computer sets the time via Bluetooth

VID_20220510_135753.gif
VID_20220509_233541.gif

Exterior

VID_20220510_152636.gif
image.png

origin

image.png
Renesas


Thanks to Lichuang and Renesas for hosting this event, and special thanks to the official technical support and event operators in the group.
image.png
Thanks for the mutual help.

element

describe model
MCU R7FA2E1A72DFL
Temperature Sensor GXHT30 (same as SHT30)
Bluetooth CH571k
led WS2812B

Main control: R7FA2E1A72DFL

48M Arm Cortex M23 core
16k ram, 64k rom
1 32-bit timer (GPT0), 6 16-bit timers (GPT4-9), 2 low-power timers
1 dedicated spi, 1 dedicated i2c
4 sci, configurable as uart, spi, i2c
12-bit adc
RTC
touch
true random number generator, hardware AES, ECC acceleration.

Appearance design

Sandwich structure, bottom layer control circuit and LED, middle layer 3D printed grille, top layer thin PCB window as display panel.

top layer

image.png

The bottom plate of PCB is made of glass fiber reinforced resin matrix composite material, which is actually translucent. However, copper, as a metal, can block light very well.
The yellow part is windowed and translucent, directly exposing the PCB substrate. The black part is solder mask + copper laying, which has good light isolation.
In eda, windows are accurately opened according to the outline of Chinese characters, so that the characters can be displayed clearly.

middle frame

image.png
The middle frame was printed using Lichuang EDA professional printmaking. real. Don't look at the circuit inside, it may be old, just look at the outer shell design. The link is here: Shell Engineering Link
ws2812 emits light in all directions, so that in addition to the words directly above it will be illuminated, the surrounding circle will also be dimly illuminated, so with this middle frame, the internal grid prevents the horizontal direction of the light spread.
But even so, when the LED brightness increases, there will still be some light leakage, especially red light.
You can increase the spacing between LEDs and add vias around the text to block the spread of light, but this will affect the look and feel and make the surface less smooth.

Ground floor

For the circuit part, mounting holes are reserved.
image.png

assembly

image.png
Sequence01_1.gif

The assembly design on this side is quite satisfactory. Reserve a pad on the back of the top layer, solder the copper pillar to the pad, leave a gap for the copper pillar in the middle frame, and screw the screws through the bottom layer to the copper pillar.
image.png
This way there are no fixed devices visible on the front or sides, only four screws on the back.

Lichuangeda: How to write the words on the top layer

In general, Illustrator performs typesetting, exports dxf outlines, imports them into eda, and establishes window areas through outlines.
However, the actual situation is a bit more complicated.
Eda currently cannot correctly identify nested contours. For example, if you import a ring, Eda will think it is a large circle within a small circle, rather than a ring.
Fortunately, some fonts (including but not limited to 楷体_GB2312) are based on stroke units, and each stroke is a simple closed shape. Creating outlines with this import is fine.
For details, please refer to the attached ai project.
image.png
For icons, my approach is to disassemble the icon into multiple simple closed images and then import them. Put several shapes together according to their relative positions. For example, the Bluetooth icon is imported after being split into two parts, so that each stroke of the two parts is a closed shape.
image.png

circuit

Trigger from the power supply, first reset the fuse F1, and then pass 5v through all ws2812. There is another channel that is stepped down to 3.3v through ldo to power other devices. The circuit integrates a buzzer, photoresistor (adc measurement), temperature and humidity sensor (i2c communication), Bluetooth chip (serial communication), and two sets of WS2812 to control his signals through spi simulation.

development environment

The e2 studio, a dedicated version of the RA series, integrates fsp internally. Download link
image.png

software code

Mainly github , gitee updates may not be timely. It is still under development and some features are not available.

Function state
rtc initialization timing Available
Time and date lunar calendar display Available
Temperature and humidity reading Available
brightness adc reading Available
windows computer timing software via bluetooth Available
Android timing app via Bluetooth To be developed
Temperature and humidity Bluetooth reading broadcast To be developed
Brightness control based on ambient light To be developed
Alarm clock To be developed
animation To be developed
    ├─adc    adc读取光敏电阻
    ├─ble     蓝牙通讯
    ├─buzzer    pwm驱动无源蜂鸣器
    ├─color    hsv色域转换
    ├─debug    调试串口
    ├─fcal    农历转换
    ├─GXHT30   温湿度传感器驱动
    ├─rtc    实时时钟  日期计算
    ├─timer   屏幕刷新信号
    └─ws2812  led驱动
main.cpp 主要逻辑
utils.h  工具类

Third-party software packages

https://github.com/FlyingFishBird/fcal (fork adapted to microcontroller https://github.com/liux-pro/fcal)
https://github.com/NordicSemiconductor/Android-BLE-Library
https://github .com/DerekGn/WinRtBle

Technical reference

There are basically four sources of reference materials for software design

  1. The IDE will come with fsp documentation, which contains documentation and sample code for all functions.
  2. There are a large number of official routines and download links from the official website .
  3. The official ra ecological studio.
  4. Official forum search.
    The RA series has not been around for a long time, and the ecosystem is still under construction. Foreign resources are richer than those in China, and the forums are relatively active. If you have any questions, you can try searching in English. It works wonders.

Debugging output function design

Maybe I'm a newbie, and I can't get through the official printf redirection.
Refer to https://www.ibm.com/docs/en/zos/2.1.0?topic=functions-vsprintf-format-print-data-buffer
for packaging by printf.
See the debug folder for details

spi driver ws2812

Send specific data packets through spi to simulate the timing required by ws2812. The relevant code is under ws2812.
https://www.elecfans.com/d/comp-4843843-136335947323087548416.html
http://bbs.mydigit.cn/read.php?tid=2622343

Pitfalls of Renesas spi driver ws2812

This is a sinkhole
. When Renesas's sci spi channel 2 9 sends a signal on mosi,
mosi will be pulled up for a few microseconds before each transmission, and then the signal will be sent normally.
During normal spi communication, there is no problem because there is clk signal.
But if you control ws2812, these few microseconds will destroy the signal, causing the first bit to flip,
causing the highest bit of the signal received by the first LED of the light strip to always be 1.
The weird thing is that sci channel 2 will do this, dedicated spi doesn't have this problem.
Someone also pointed out this problem on the official forum. He said that sci channel 9 also has this problem.
Reference: https://renesasrulz.com/embedded-system-platform/synergy/f/forum/19774/r_sci_spi-simple-spi-the-rising -edge-of-the-first-pulse-occurs-much-earlier-than-expected?ReplySortBy=CreatedDate&ReplySortOrder=Ascending
official routine uses sci0, so it "happens" not to encounter this problem.
We can only temporarily send a few more 0xff before sending, to keep this pulse signal away from the real signal. I hope Renesas can solve the problem.
If the official wants to verify, they can directly use sci2 to drive ws2812. Look at the first light, which can never be turned off.

Gamut conversion

WS2812 performs color mixing based on rgb. However, the description of color by rgb is not intuitive, while the description of color by the hsv color gamut is very intuitive for humans.
h stands for red, orange, yellow, green, blue, purple. s represents the saturation of the color and v represents the brightness. The reference link below provides a fast gamut conversion algorithm.
image.png
Reference: https://www.vagrearg.org/content/hsvrgb

Piezoelectric passive buzzer

This kind of passive buzzer cannot be driven by adding a triode and PWM, so it needs to be connected in parallel with a resistor. Thanks to the friends of customer editor @19395A
Reference: https://baijiahao.baidu.com/s?id=1678346404000645198&wfr=spider&for=pc

Pitfalls of random number generation

Renesas comes with a true random number generator. The current fsp (3.6) has a bug and the library cannot be compiled under c++.
Renesas accepted my repair code and this is no longer a problem in the new version of fsp
. Reference: https://github.com/renesas/fsp/pull/195

time setting

Use Bluetooth to broadcast a timestamp to initialize RTC. Currently, it is possible to send Bluetooth broadcast to adjust RTC time under Windows. The basic principle is to send a Bluetooth broadcast and fill in the manufacturer information with a timestamp. After receiving the broadcast, ch571k sends it to the Renesas microcontroller through the serial port, and then adjusts the time.

bluetooth code

The routine based on master-slave integration can be modified to receive the broadcast from a specific manufacturer, extract valid data and send it out through the serial port. Receive data and put the data into the broadcast. Connection is not supported yet, only broadcast communication is supported.
See attachment ch571k.zip

windows host computer

Call Bluetooth on the computer through winrt, obtain the current timestamp, assemble a specific data packet and send it out. The Bluetooth chip will accept this broadcast and send it to Renesas to complete the timing.
SuperClockWindows.7z

unimagined road

  1. Where there are screens, there are badapples.
  2. The screen displays computer CPU usage and temperature, etc.
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-08-03 12:11:06

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号