Please enable JavaScript to view this site.

How this block appears in a Simulink model?

system_time_block_1

What can be configured?

system_time_block_2

Configuration Parameter

Selectable Option/Value

Description

Mode

--Write to external RTC--UNIX timestamp--Custom

Time output format. Check port label to understand the output

Sample time

 

Select sample time

 

Note : Use "Custom" mode if the output need to be read because "Write to external RTC" mode is only to write to a RTC module.

 

INPUT/ OUTPUT Port

Port Name

Port Type

Date Type

Description

 

 

 

 

year

Scaler/Vector

uint8/int16

Year number(custom mode)

 

 

 

 

month

Scaler/Vector

uint8/int16

Number of the month, range 1 to 12(custom mode)

 

 

 

 

date

Scaler/Vector

uint8/int16

day of the month, range 1 to 31(custom mode)

day

Scaler/Vector

uint8

days since Sunday, range 0 to 6

hour

Scaler/Vector

uint8/int16

hours since midnight, range 0 to 23(custom mode)

 

 

 

 

minute

Scaler/Vector

uint8/int16

minutes after the hour, range 0 to 59(custom mode)

 

 

 

 

second

Scaler/Vector

uint8/int16

seconds after the minute, range 0 to 61*(custom mode)

 

 

 

 

UNIX

Scaler/Vector

uint32

UNIX time format

 

 

 

 

days since Sunday

Scaler/Vector

int16

days since Sunday, range 0 to 6

 

 

 

 

days since January 1

Scaler/Vector

int16

days since January 1, range 0 to 365

 

 

 

 

Note : Each output method have different output data type.

"Write to external RTC" : int16

"UNIX" : uint32

"Custom" : int16

Demo

Demo file : esp32_system_time_demo.slx

sntp_block_3

Inside of the if action subsystem.

sntp_block_4

Description

This demo use SNTP_block to update the ESP32 local time with the server. There it need to be connect to the WIFI first from the WIFI_block. Once it connect SNTP will synchronize the time with the server. Then System_time_block will get the internal time from the esp and give the output to a String_processing_block. It will process the string and print it for the user.

What should be happening?

Firstly it will connect to the server by using the WIFI block. When the WIFI connection is established it will update the local time. Please check the Serial Monitor for the more info (baud rate : 115200). It will log the current time there.

sntp_block_5

Copyright 2022 Aimagin Co.,Ltd. Rev.339