Download SoundDemp.zip
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 MainVisu
.
The Jukebox will change its appearance every 600ms. One cycle goes through 13 different Jukebox
picture changes.
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 Sounds
to C:\temp
.
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'.
Mapping Table
Variable | Bit | Channel |
---|---|---|
ding | Bit0 | Byte0 |
cord | Bit1 | Byte0 |
chimes | Bit2 | Byte0 |
notify | Bit3 | Byte0 |
ringout | Bit4 | Byte0 |
tada | Bit5 | Byte0 |
_type | Bit6 | Byte0 |
newmail | Bit7 | Byte0 |
C | Bit0 | Byte1 |
Cis | Bit1 | Byte1 |
D | Bit2 | Byte1 |
Dis | Bit3 | Byte1 |
E | Bit4 | Byte1 |
F | Bit5 | Byte1 |
Fis | Bit6 | Byte1 |
G | Bit7 | Byte1 |
Gis | Bit0 | Byte2 |
A | Bit1 | Byte2 |
Ais | Bit2 | Byte2 |
H | Bit3 | Byte2 |
C_ | Bit4 | Byte2 |
Cis_ | Bit5 | Byte2 |
D_ | Bit6 | Byte2 |
Dis_ | Bit7 | Byte2 |
E_ | Bit0 | Byte3 |
F_ | Bit1 | Byte3 |
Fis_ | Bit2 | Byte3 |
G_ | Bit3 | Byte3 |
Gis_ | Bit4 | Byte3 |
A_ | Bit5 | Byte3 |
Ais_ | Bit6 | Byte3 |
H_ | Bit7 | Byte3 |
System requirements and restrictions | Info |
---|---|
Programming System | CODESYS Development System Version 3.5.14.0 or higher |
Runtime System | CODESYS Control Version 3.5.14.0 |
Additional Requirements | Adding the "IODrvSoundDemo.dll" as component to ~/GatewayPLC/CODESYSControl.cfg |
Required Accessories | Windows Vista or higher requires the Sound Demo to run on "CoDeSys Control Win V3" instead of "CoDeSys Control Win V3 SysTray" . Control WinV3 can be found in the Windows Start Menu. 64 Bit controls are not supported. |