MATLAB Answers

Pin toggle frequency in Simulink Real Time

7 views (last 30 days)
Peter Schouten
Peter Schouten on 19 Aug 2018
Commented: Peter Schouten on 27 Aug 2018
For a project I need to simulate a Hall-Effect sensor. A Hall-effect sensor generates a block pulse with fixed amplitude and variable frequency. For this project, I need to achieve an accurate frequency signal with a maximum of 7.5 kHz.
I use Simulink Real time to gerenate the digital signal, with a MCDAQ Dio 24 Digital output.I measure the output frequency with a scope to my laptop. I am using a very high end TargetPC (i7 CPU, 16GB DDR3 etc.)
I have multiple models that can generate such a signal. However, I am running into problems with signal accuracy. https://nl.mathworks.com/matlabcentral/fileexchange/35922-programmable-pulse-generator-using-simulink-s-basic-blocks
When running this model, I get the desired signal frequency, but the signal is oscillating around the input frequency. For example: Desired is 6 kHz, output is 5.8 kHz to 6.2 kHz. Average is good, but the fluctuating signal frequency is visible on the datalogger during testing. In the real world, no fluctuation occurs.
Furthermore, using this models to generate a pulse signal requires extreme sampling times of 0.0001 [s].
Having done a project like this with different hardware in the past, I have once succesfully generated extremely high frequency block pulses on a Olimexino STM32 using interrupts to generate this signal. This was all done with a custom simulink library.
It seems to be really hard for the hardware to generate a block signal by model calculation. There must be a simpler method.
What I really want: Is there a way in Simulink Real Time to toggle a digital output state with a certain input frequency? In simple words: Can I just tell a digital output: 'toggle with 7.5 kHz now, and now with 7.4 kHz etc.?
Any help is greatly appreciated.
Kind regards, Peter

  0 Comments

Sign in to comment.

Answers (1)

Diego Kuratli
Diego Kuratli on 26 Aug 2018
The MCDAQ is not supported by Simulink Real-Time and therefore I guess you are using a different product or third-party drivers?
In general, a x86 computer introduces some jitter. The Simulink Real-Time kernel and Speedgoat target machines are designed and optimized to reduce such unwanted behaviors.
Note that a generic digital output might not be appropriate for generating an accurate signals. Typically, the signal generator internal frequency requires to be much faster than the generated signal. There are solutions allowing generating high-speed and accurate signals, see: https://www.speedgoat.com/products-services/fpgas

  3 Comments

Peter Schouten
Peter Schouten on 27 Aug 2018
I am using MATLAB R2016B which still supports the MCDAQ hardware board. Therefor I am not using a Speedgoat Target machine.
Are there FPGA Chips available for this setup?
Thank you for time and consideration.
Diego Kuratli
Diego Kuratli on 27 Aug 2018
Which MCDAQ board are you using? Is the board installed on a target computer?
FPGA-based solutions are available for Speedgoat's target machines only.
Peter Schouten
Peter Schouten on 27 Aug 2018
I am using the MCDAQ DIO 24.
https://www.mccdaq.com/PDFs/Specs/PCI-DIO24-spec.pdf

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by