Hi everyone,
I'm working on a real-time inverter control system using Simulink and the Arduino Hardware Support Package. The setup includes a hysteresis current controller implemented in Simulink. I'm using current sensors (LEM LES 6-NP) whose analog voltage outputs are connected to the analog inputs of an Arduino Due. The signals are compared with reference current waveforms, and based on the hysteresis logic, Simulink generates PWM signals that control the transistors of an IPM inverter module.
The system works as expected in general, but I'm facing two key issues:
- Sampling time limitation – The best real-time performance I can get is with a step size of 1/2500 s. Going below that causes Simulink to fall out of real-time, introducing delays.
- Low ADC accuracy – The analog-to-digital conversion on the Arduino Due is quite noisy and not very precise. Because of this, I can't set a narrow hysteresis band (e.g., 0.01). I have to use a wider band (0.05 or more), otherwise, due to noise, the transistors switch incorrectly. At low frequencies, the current waveform is acceptable, but at higher frequencies (e.g., 50 Hz), the waveform degrades due to insufficient sampling and poor resolution.
I’d like to improve the sinusoidal current tracking and I believe the key issue is the ADC quality. I have a Raspberry Pi 4B available and I’m considering adding an external ADC module to it, with the intention of using existing Simulink support packages.
My questions:
- Would the Raspberry Pi 4B be a better platform for this kind of real-time application, in terms of ADC quality and achievable step size?
- Can anyone recommend a compatible ADC module (preferably with Simulink support out-of-the-box) that could provide higher resolution and better noise performance?
- Has anyone had success implementing hysteresis control or other fast current control strategies using Raspberry Pi + external ADC in Simulink?
- Or is Raspberry Pi simply not suitable for this kind of high-speed control task (due to OS latency, limited real-time precision, PWM generation etc.) and should I be looking into a different platform like an FPGA or a real-time microcontroller instead?
I’m attaching a screenshot of the Simulink model and a sample of the output current waveform (10, 25 Hz) for reference.
Thanks in advance for your help!