Remember, that program will stop at command until the sound is played. Its better to make 2nd Task for sound playing with using some buffer or mark at GLOBAL VARIABLE.
IFsoundStateTHENSysProcess***ExecuteCommand('aplay /theway/tomusic/sound.wav', ADR(cmdResult)); soundState:= FALSE; END_IF // Delete that "***", I have to add it because forum filtering it
Maybe you have to add library:
SysTypes Interfaces
SysProcess
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Edit: I got it working. Now that I have an account I can see the screenshot mentioned above. Just an addition, I had to click on the "display advanced libraries" in the Add Library window.
I am interested in getting this code to work on my Raspberry Pi 3 using CODESYS V3.5 SP10 P2 +. I have SysTypes Interfaces (3.5.2.0) and SysProcess (3.5.7.0) installed. I'm very new to CODESYS and Raspberry Pi.
In declaring the variable cmdResult, there is an error "Identifier 'RTS_EIC_result' not defined". I also tried
cmdResult:POINTERTORTS_IEC_result;
but I get the same error.
Also, regarding the SysProcessExecuteCommand (minus the ) I have the same "Identifier not defined" error. Is there an "Import" that I'm missing?
jvondrus hat geschrieben:
Hello:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
is there someone who can explain me how to play an audio file in Codesys through LD.
I have added a file (.WAV) with Filezilla, or it is also possible to add a audio file in Codesys by right-clicking on application and add file.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you dor your replay, very helpfull.
Let me start from the beginning.
I open a new project > standard project > PLC PRG in LD > Add library's SysProcess and SysTypes 2 Interfaces.
Add POU > Funktion block > in open in ST > Then add the code like in the screenshot
Make a prg like in the screenshot.
Add the file in the device like in the screenshot.
Buils the program with no fault.
If i put the software in simulation and build te program i get a fault like in the screenshot.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I want to play AUDIO files with my RPI2. What do I have to do in Codesys? My idea is to play AUDIO files when some digital bit is ON.
regards
more posts ...
Hello:
Enable commands at /etc/CODESYScontrol.... (do not remember right name), add to settings:
OR more safety:
In Codesys program add variable:
And use command for play the sound (for aplay command):
Remember, that program will stop at command until the sound is played. Its better to make 2nd Task for sound playing with using some buffer or mark at GLOBAL VARIABLE.
Maybe you have to add library:
SysTypes Interfaces
SysProcess
Thank you! This worked fine.
Hallo jvondrus,
How can I add this library?
Thanks, your help!
regards
Hi,
see screenshot just type in what you know from the library - name of an FB or name of the Lib
BR
Edwin
Hello,
I am currently testing a video file with:
Video_1: STRING: = 'sudo omxplayer -o both /home/pi/media/test.mp4';
The file is also played via the "omxplayer".
Works perfect,
But how can I finish playing that prematurely?
In the terminal I press "q"
is that possible?
Thank you very much
mfg mike
Edit: I got it working. Now that I have an account I can see the screenshot mentioned above. Just an addition, I had to click on the "display advanced libraries" in the Add Library window.
I am interested in getting this code to work on my Raspberry Pi 3 using CODESYS V3.5 SP10 P2 +. I have SysTypes Interfaces (3.5.2.0) and SysProcess (3.5.7.0) installed. I'm very new to CODESYS and Raspberry Pi.
In declaring the variable cmdResult, there is an error "Identifier 'RTS_EIC_result' not defined". I also tried
but I get the same error.
Also, regarding the SysProcessExecuteCommand (minus the ) I have the same "Identifier not defined" error. Is there an "Import" that I'm missing?
I also have the same error RTS_IEC_RESULT Module not found, does anyone knows how to solve this problem.
Thank you best regards
is there someone who can explain me how to play an audio file in Codesys through LD.
I have added a file (.WAV) with Filezilla, or it is also possible to add a audio file in Codesys by right-clicking on application and add file.
Hi,
to play sound:
l viewtopic.php?f=23&t=6247&p=22144#p22144 l
another example is playing Sound on the webvisu Client also intresting
l viewtopic.php?f=23&t=6247&p=22144#p23781 l
BR
Edwin
Thank you dor your replay, very helpfull.
Let me start from the beginning.
I open a new project > standard project > PLC PRG in LD > Add library's SysProcess and SysTypes 2 Interfaces.
Add POU > Funktion block > in open in ST > Then add the code like in the screenshot
Make a prg like in the screenshot.
Add the file in the device like in the screenshot.
Buils the program with no fault.
If i put the software in simulation and build te program i get a fault like in the screenshot.
Someone can give sample project for Raspi play audio.
Thank you
@eschwellinger linked to one I believe, here's the link.
Last edit: Morberis 2020-08-27
how to change sound file
Last edit: toatan-th 2021-08-05