Sorry for the answer delay Murat. I will see if I can show you the model because is a university project and I dont know if my team allows it. If yes I will contact you ;) thanks
I want to have output sounds by GPIO but I think that will be impossible due to my sample time of 48000. I test the ports with a simple square at that frequency wave and a oscilloscope, and the PINS coul not output a steady frequency. :\
Another thing that I do not understand was the input audio block. If the raspberry does not have input sound ports how simulink have an input sound block? I think that for beginners the documentation could be better...
I figure it out the problem about the sound. I fix it and the sound is now quite nice :D However, through other outputs the sound could be better? Like HDMI?
Another point, in my model I have 3 sounds outputs. I wanna that this 3 data sets go to the GPIO pins to control each one individualy. I try a simple model including a sine wave, a relay, a data conversion to boolean and a GPIO pin. No problem, I sent the model to raspberry.
When I test with my model an error occured and said to contact Mathworks. The error was: "Unexpected or internal error encountered in "in CGIR: b:\matlab\src\cg_ir\util_cg\cg_sanity_checker.cpp line 411: sanityCheckLValue: expression producing non-pointer type used in L-value context
". Please report this to MathWorks if you can cause it to recur".
Erro print from my workspace: https://feupload.fe.up.pt/get/nHLDjoC8w5137mK
My output is a vector with 32 samples from -1 to 1. I use the following blocks to peform the conversion to GPIO pin: relay, data conversion to boolean and a unbuffer. Could you help me Murat? :\
this sample rate, in fact little fast, is the output of a much complex system that I have been working. I simply passed to raspberry and after some time the sound simply stop. I had not thought about the sample rate but it solves my problem regarding the sound stop and noisy! And thanks for the tip of speed/work improvement :D
Yes you are correct, the range is 2^15. I put it wrong.
Now I need to improve the sound quality. In my system I work always with a sample time of 48000 so I cannot improve more to obatin more precision on the output wave. The wave is also a combination of many frequencies. Another option could be improve inside the raspberry. With the conversion to 16 bits, the sound quality, which is normal, is not so good. So I search for a while and I can use the sound either by, 3.5mm jack, HDMI or a output sound card via USB. Using another port is possible to have better sound quality or the ALSA block and its 16bits limit me to the sound that I have now? I wanna try if I can have a similar sound like I listen when I run my model on my PC.
Murat Belge thank you for the response. I really need help on this :X
I put some other blocks on the model to ajust the signal for the ALSA block, the 2xN matrix int16 type.
it is better if you download the model. Thus I avoid get you wrong about what I tried. Link for download: https://feupload.fe.up.pt/get/To2nmpnz87UDsQ3
The output sound from raspberry comes from 3.5mm jack to a normal speakers (TEAC powermax 80/2). I can tell you that the sound goes noisy in less than 1 minute (I tested again before write this comment)
I do not have too much feedback on raspbeery to deal with this and I don't know if the problem is mine or some other thing inside the firmware.