This example explains the mapping of device outputs. For illustration purposes it uses a sound card as a device and a program that allows the user to play some music.
Attention: 64 Bit controls are not supported.
When executing the MainVisu, the user will see a piano with the range of two octaves. A note will be played, as long as the user presses the mouse button on a key.
If the mouse is released the sound will immediately stop. With a click on "Jukebox", it is possible to switch to the Jukebox mode. Three songs can be played there.
The Jukebox mode comes with a play, pause and stop function. The user will also be able
to change back to the piano mode.
Main_PRG: This contains the main logic of this example. It constantly changes
between seven different states.
STATE.MUTE: All output bits will be set to FALSE and no sound will be played if the
program changes to this mode. The animation of the jukebox will be stopped as well.
STATE.FUER_ELISE: In this state the song "Für Elise" ( English: For Elise) will be
played on the jukebox. It consists of 150 song components.
STATE.HAENSCHEN_KLEIN: In this state the song "Hänschen klein" ( English: Little Johnny)
will be played on the jukebox. It consists of 32 song components.
STATE.MERRY_XMAS: In this state the song "We wish you a merry Christmas" will be
played on the jukebox. It consists of 37 song components.
STATE.PIANO: The Piano Mode gets activated in this mode. The
MainVisu will present
a piano to the user.
STATE.JUKE: The Jukebox Mode gets activated in this mode. The
MainVisu will present
a jukebox to the user.
STATE.WAITING: In this state nothing happens. The program simply cycles through `
this state until a state change gets triggered.
JUKEBOX (FB): The JukeBox FB controls the blinking animation of the JukeBox in the
The Jukebox will change its appearance every 600ms. One cycle goes through 13 different Jukebox
SoundCard: The path to the sound files can be changed in the
"Internal Configuration" tab.
Also additional songs can be added here.
In order to make this example work, the CODESYS Control CFG file has to be extended.
Change in your CODESYS installation folder to 'GatewayPLC/'.
Open the file 'CODESYSControl.cfg' and add a new component as 'IODrvSoundDemo'. See the first screenshot below. Additionally, copy the file
IoDrvSoundDemo.dll from the package (in 'SoundCard') into the same folder.
Then copy the included folder
In CODESYS go to
Tools -> Device Repository... -> Install. Now select the file
IoDrvSoundDemo.devdesc.xml, which is included into the package in the folder 'SoundCard'.
|System requirements and restrictions||Info|
|Programming System||CODESYS Development System Version 126.96.36.199 or higher|
|Runtime System||CODESYS Control Version 188.8.131.52|
|Additional Requirements||Adding the "IODrvSoundDemo.dll" as component to
|Required Accessories||Windows Vista or higher requires the Sound Demo to run on