RaspberryPi4 audio issues (GPIO, XCP and simulink)

4 visualizzazioni (ultimi 30 giorni)
I'm doing a project to be able to control parameters of various audio effects using potentiometers connected to a GPIO of the rasberry4.
I have the model with full simulink (working with an external card on I2S) and I need to connect encoders to the GPIOs. The fact is that when I import them into the project, the audio disappears and I only have periodic "bursts" at the output.
At the same time, I can't get more than two encoders (in another model) without getting the XCP communication error. Does anyone know how I can get more bandwidth for this protocol?
Thank you so much

Risposte (1)

Sanchari
Sanchari il 10 Feb 2024
Hello Arnau,
It seems you are encountering two issues: audio output disruption when interfacing encoders with a Raspberry Pi 4's GPIOs in a Simulink model, and bandwidth limitations when using more than two encoders due to XCP (Universal Measurement and Calibration Protocol) communication errors.
Here are some steps to help you troubleshoot and potentially resolve these issues:
Audio Output Disruption
These might be due to resource contention or timing issues. To resolve, consider:
  1. Check CPU Load: Encoding operations and audio processing can be CPU-intensive. Use tools like ‘htop’ or ‘top’ in the Raspberry Pi terminal to monitor CPU usage.
  2. Task Prioritization: Ensure that audio processing tasks have higher priority than GPIO reading tasks. In Simulink, you can adjust task priorities in the model configuration parameters.
  3. Optimize Encoder Reading: Ensure that the code reading the encoders is optimized and not blocking other processes. Consider using interrupt-driven GPIO reading instead of polling if not already doing so.
  4. Reduce Sampling Rate: If the encoders are being sampled too frequently, this could interfere with audio processing. Try reducing the sampling rate of the encoders.
  5. Power Supply: Insufficient power supply can lead to erratic behaviour. Make sure your Raspberry Pi has a stable and sufficient power source.
XCP Communication Error
XCP is designed to work well with high-speed data transfers, but it has its limits, especially on hardware with limited resources like the Raspberry Pi. Here are some suggestions to increase the bandwidth for XCP communication:
  1. Increase XCP Data Rate: If possible, increase the XCP data rate. This might be limited by the Raspberry Pi's hardware capabilities or the settings in your Simulink model.
  2. Optimize Data Transmission: Only send necessary data over XCP. For example, instead of sending raw encoder counts, you could send higher-level information or send data less frequently.
  3. Increase XCP Bandwidth: If possible, configure the XCP settings to increase the bandwidth. This might involve changing the CAN bus speed or using a different transport layer that provides higher bandwidth.
  4. Dedicated XCP Channel: If you're using XCP over Ethernet, ensure that the network is not congested with other traffic. Ideally, use a dedicated network interface for XCP communication.
  5. Check for Software Updates: Ensure you have the latest updates for MATLAB, Simulink, and the 5G Toolbox, as performance improvements are often included in software updates.
  6. Streamline Data Acquisition: Streamline the acquisition of data from the encoders to ensure that it is as efficient as possible, reducing the processing load on the Raspberry Pi.
  7. Diagnostics and Monitoring: Use diagnostic tools to monitor the XCP traffic and identify bottlenecks or errors that may be contributing to the communication issues.
If these suggestions do not resolve the issues, you may need to consider using a dedicated microcontroller to handle the encoder inputs or offloading some processing tasks to external hardware to free up resources on the Raspberry Pi for audio processing.
Consider going through the following links for further clarification and knowledge regarding:
  1. Play high quality audio from Raspberry Pi using I2S-based DAC (mathWorks Documentation): https://www.mathworks.com/help/supportpkg/raspberrypi/ug/play-high-quality-audio-from-raspberry-pi-using-i2s-based-dac.html?searchHighlight=Raspberry%20Pi%20audio&s_tid=srchtitle_support_results_9_Raspberry%20Pi%20audio
  2. Raspberry Pi hardware resource Manager (File Exchange): https://www.mathworks.com/matlabcentral/fileexchange/72205-raspberry-pi-hardware-resource-manager?s_tid=srchtitle_support_results_1_Raspberry%20Pi%20audio
  3. Prototyping Audio Processing Applications on a Raspberry Pi (MathWorks Documentation): https://www.mathworks.com/support/search.html/videos/prototyping-audio-processing-applications-on-a-raspberry-pi-1504895874469.html?fq%5B%5D=asset_type_name:video&fq%5B%5D=category:coder/index&page=1
  4. Implement Parametric Audio Equalizer Using Raspberry Pi (MathWorks Documentation): https://www.mathworks.com/help/supportpkg/raspberrypi/ref/parametric-audio-equalizer.html?searchHighlight=Raspberry%20Pi%20audio&s_tid=srchtitle_support_results_6_Raspberry%20Pi%20audio
Hope this information helps!
  1 Commento
Arnau Mañosa
Arnau Mañosa il 10 Feb 2024
Hello!
First of all, thank you for your response and the possible solutions you suggest. The truth is, I stopped working on this project about two years ago. It was a university project, and I did not continue its development. Nevertheless, I do believe that the proposals you make regarding XCP flows would yield good results. I will try to test it out someday.
Thanks again.

Accedi per commentare.

Categorie

Scopri di più su Code Generation and Deployment in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by