Difference between revisions of "HANcoder/Examples/Adding a customized block"

From OpenMBD
Jump to: navigation, search
 
(18 intermediate revisions by the same user not shown)
Line 1: Line 1:
This is a step-by-step guide for creating a custom block in MatLAB/Simulink and how to call custom functions written in the C programming language.<br>
+
This is a step-by-step guide for creating a custom block in MatLAB/Simulink and how to use custom functions written in C-code.<br>
This guide assumes that [[downloads/HANcoder|HANcoder]] has been downloaded and installed successfully.<br>
+
This guide assumes that [[downloads/HANcoder|HANcoder]] Beta V1.0 has been downloaded and installed successfully.<br>
 
<br>
 
<br>
The guide is based on an example: a Signal Tower. The signal tower consists of four layers with two RGB LEDs per layer. Each color can be assigned a value between 0 and 255.<br>
+
The guide shows the implementation of an example project: a signal tower for the Olimexino STM32.<br>
The resulting custom block will look like this:
+
The signal tower consists of four layers with two RGB LEDs per layer. Each layer can be assigned 16777216 colors (256 brightness levels for each LED).<br>
[[File:sigal_tower_block_final_result.png]]
+
The signal tower is constructed with eight WS2812B RGB LEDs. These LEDs are are connected in cascade and use a single serial transmission line.<br>
 
+
The timing required for generating the serial signal is implemented in C-code by using the SPI bus of the STM32 microcontroller. As the STM32 on the Olimexino features two SPI channels (SPI1 and SPI2), the SPI channel can be selected as a block parameter.<br>
* Part 1: [[Matlab/Simulink files]]
+
<br>
 +
The resulting block in Simulink is depicted below:<br>
 +
[[File:signal_tower_block_final_result.png]]
 +
<br>
 +
<br>
 +
The files that have been added or updated with respect to HANcoder Beta V1.0 can be downloaded [[:File:HANcoder-STM32-Target-v1.0-Signal-Tower.zip]].<br>
 +
The following parts provide a detailed description of these files and additional changes that need to be made.<br>
 +
* Part 1: [[C source code]]
 +
* Part 2: [[Matlab/Simulink files]]
 
* Part 3: [[Creating a block in Simulink]]
 
* Part 3: [[Creating a block in Simulink]]
* Part 2: [[C source files]]
 
 
* Part 4: [[Updating the build environment]]
 
* Part 4: [[Updating the build environment]]
 
* Part 5: [[Testing the project]]
 
* Part 5: [[Testing the project]]

Latest revision as of 11:00, 22 March 2019

This is a step-by-step guide for creating a custom block in MatLAB/Simulink and how to use custom functions written in C-code.
This guide assumes that HANcoder Beta V1.0 has been downloaded and installed successfully.

The guide shows the implementation of an example project: a signal tower for the Olimexino STM32.
The signal tower consists of four layers with two RGB LEDs per layer. Each layer can be assigned 16777216 colors (256 brightness levels for each LED).
The signal tower is constructed with eight WS2812B RGB LEDs. These LEDs are are connected in cascade and use a single serial transmission line.
The timing required for generating the serial signal is implemented in C-code by using the SPI bus of the STM32 microcontroller. As the STM32 on the Olimexino features two SPI channels (SPI1 and SPI2), the SPI channel can be selected as a block parameter.

The resulting block in Simulink is depicted below:
Signal tower block final result.png

The files that have been added or updated with respect to HANcoder Beta V1.0 can be downloaded File:HANcoder-STM32-Target-v1.0-Signal-Tower.zip.
The following parts provide a detailed description of these files and additional changes that need to be made.