Raspberry Pi 2, get system clock with timeval

This Simulink model has an S-function builder block to access the linux system time via gettimeofday

343 descargas

Actualizado 16 Dec 2015

Ver licencia

This model uses Raspberry Pi library block to toggle the LED and a executes custom written S-function to access the targeted system time for comparison
to the running simulation time. This is helpful in quantifying soft-real-time performance.

The POSIX gettimeofday() function has resolution down to microseconds but windows and linux have good resolution to around
10ms and about 1ms, respecctively, depending.

The S-function builder auto-generates a .tlc file and generates a fully-inlined S-function that is helpful in targeting the Raspberry Pi device
(or any other Simulink Coder target).

getSystemClockTimeval.c works on the host PC and also the Raspberry Pi runnning Debian Wheezy linux. The simulink code computes the differnce between
the operating system's local time and the simulation time then logs that to a file. The write-to-file block works on the host or the targeted Raspberry Pi.

This Simulink model was tested and runs on R2015b on Windows 10 with the gcc MinGW 64-bit compiler.

To run this model on a PC with Matlab, double click the light blue initiailzation block to specify h_fixed=0.1 seconds, then open the s-function builder block, hit build, and upon successfully creating the s-function getSystemClockTimeval.c and associated .tlc file it will build getSystemClockTimeval.mexw64. You can then run the simulation on the host PC. It logs a matfile called myTestData.mat in the working directory.

To run this file on the Rasperry Pi 2 model B, double click the initialization block to assign h_fixed=0.1 seconds, then open the S-function builder, build the s-function and associated .tlc file, then close that dialogue box. Press ctrl-B to build and target the model to your properly configured Raspberry Pi 2 device.

Marc Compere, comperem@erau.edu
created : 16 December 2015
modified: 16 December 2015

Citar como

Marc Compere (2023). Raspberry Pi 2, get system clock with timeval (https://www.mathworks.com/matlabcentral/fileexchange/54546-raspberry-pi-2-get-system-clock-with-timeval), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2015b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Más información sobre Simulink Supported Hardware en Help Center y MATLAB Answers.

Inspiración para: Soft Real Time Block for Pacing Simulink Simulations

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión