Simulink ADC Input Block
古いコメントを表示
I want to create a device driver block for custom embedded hardware with an STM32 MCU. I have already written some C functions that use the STM32Cube HAL to initialise the ADC in DMA mode (some kind of init function); average the ADC sampled ADC codes and calculate the measured voltage (some kind of step function); return the measured voltage for a given ADC channel (some kind of getter function).
I want the block to behave as follows:
- With target simulation in Simulink: the block has two inputs (input voltage, ADC reference voltage) and one output (measured voltage). The input voltage is converted into the respective code (like the real ADC would do) using the reference voltage and quantisation. The code is then converted back into a voltage measurement (like my C function would do) and emitted through the output.
- With target code generation: the block has no inputs (inputs are simply ignored) and one output (measured voltage). The generated code does nothing more than calling my C function (as described above) that returns the current measurement for the selected channel (function parameter, specified via block mask).
I've read about the legacy code tool, s-functions and device driver system objects. I although did not understand which method is currently recommended for my type of application. I did already accomplish similar tasks with the s-function builder but without the first requirement (simulation behaviour). My s-function builder blocks simply did nothing during simulation.
Which method would you recommend for my purpose. Can you point me to a page in the documentation where I can acquire more information and a coherent example is presented?
Have a good one!
Simon
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Embedded Coder Supported Hardware についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!