I do it for example on a Wago Touchpanel 600 that way:
(Play sound)
IF xTest OR PLC_PRG.xAlarm THEN //SysProcess.SysProcessExecuteCommand('aplay /var/opt/codesys/alarm1.wav', ADR(Result)); SysProcess.SysProcessExecuteCommand('aplay /var/opt/codesys/PlcLogic/Application/alarm1.wav', ADR(Result)); xTest := FALSE; END_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Of course with:
"amixer cset numid=3 50%"
I can change the volume. This is working only if the sound is played in the command line on the Raspi (via Putty) with the command:
"aplay /home/pi/mb/post.wav"
But when the command is done via Codesys with:
"SysProcessExecuteCommand('aplay /home/pi/mb/post.wav', ADR(cmdResult));"
the volume set before seems ignored and the sound is played at the maximum volume...
What can I do...?
Thx
Yann
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
To have a good sound quality I would like to use the Amp2 from HifiBerry:
https://www.hifiberry.com/shop/boards/hifiberry-amp2/
Is it possible to control it from Codesys? If yes how?
Many thanks in advance for your replies.
Yann
Last edit: yann2021 2023-06-21
I do it for example on a Wago Touchpanel 600 that way:
(Play sound)
Hello,
Many thanks for your answer. What exactly "ADR(Result)" do? How should I declare it?
Yann
You define a Result in your PLC code, to monitor wether the SysProcess.SysProcessExecuteCommand returns a succes or fail.
Hello,
Many thanks, it's working but now how can I adjust the volume ?
google for 'amixer' cmd under linux
Hello,
Of course with:
"amixer cset numid=3 50%"
I can change the volume. This is working only if the sound is played in the command line on the Raspi (via Putty) with the command:
"aplay /home/pi/mb/post.wav"
But when the command is done via Codesys with:
"SysProcessExecuteCommand('aplay /home/pi/mb/post.wav', ADR(cmdResult));"
the volume set before seems ignored and the sound is played at the maximum volume...
What can I do...?
Thx
Yann
if you call the amixer command via CODESYS?
Hello,
I tryed this:
But it's not working... the sound is played but the volume is still at maximum...
Hello,
Any other hints...?