I have made a HPF digital filter using MATLAB, and I have confirmed the result of its output with Simulink and it is working well. I am using the HPF filter in an Arduino duo to see the result in oscilloscope, but the oscilloscope’s output is weird square waves and not a sine wave (the input is from function generator and I tried changing the frequency in Hz and the cutoff is 1750). So I want to know what is the solution to this problem?
Also LPF shows me the oscillation in very low frequencies my cutoff is 1000 but it start oscillating at 100. So what’s the issue for this?
Post your Arduino code (in code tags).
I believe that the Matlab generates code which uses single or double precision variables. I'm fairly sure the Due does not have floating point hardware, in which case it will execute very slowly and probably can't keep up with the incoming data.
If this is the problem, you might get the code to execute fast enough if you can convert it to using 16-bit integers - but that's not a trivial task.
Another solution would be to use a faster microprocessor like a Teensy 4.1 (600MHz and has single and double precision floating point hardware).
[edit] But the Teensy 4.1 does not have a DAC so it might not work in your situation.
Pete