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