A project example for VR Stamp :
A voice controlled LED light show
Train your board with your voice, then control the LED animation by saying commands !
This project is fitted to the mikroC RSC-4x compiler small memory model : no mikroC licence is needed, just to show the power of the demo version !
This project example shows how to build a voice controlled application, involving the following products or technologies :
In this page, a short tutorial will help you to install mikroC RSC-4x compiler.
We will see then, how to produce synthetized speech and add it to a VRStamp project with QS4.
But if you are already familiar with these tools, you can directly jump to the mikroC project example section.
How to install mikroC RSC-4X Compiler
mikroC Compiler and Sensory tools installation :
Download and install the last release of mikroC RSC-4x compiler from mikroE web site :
Download and install the last release of Phyton Project-SE development kit from Phyton web site :
Download and install in a different folder, an old version of Phyton Project-SE (released before june 2006) development kit from a web archive, for example :
then copy the MCASE.EXE binary file from the old
for example (dos command, depending on your installation paths) :
copy C:\Phyton\Proj-se\1_10_05\MCCSE\BIN\MCASE.EXE C:\Phyton\Proj-se\1_10_09\MCCSE\BIN
Download and install the last release of Sensory Fluentchip libraries and QuickSynthesis 4 toolkit :
mikroC IDE configurations
Open mikroC RSC-4x compiler
mikroC needs to know where to find Phyton assembler and linker.
Go to Tools -> Preferences -> Options -> Project -> Cross Tools, and point to the latest Phyton tools directory as follow :
Creating a new VR Stamp Project
Open mikroC RSC-4x compiler
Go to Project -> New Project :
mikroC needs to know where to find the binary objects to link to your project (as FluentChip libraries, speech, sounds...), and the locations of the include files.
Go to Tools -> Options -> Project -> Search Path
add in the Path list the path to your project and the path to the Sensory FluentChip library, as well as other paths where to find other binary objects if needed ;
add in the Include Path list the path to the Sensory FluentChip includes, as well as other paths where to find other includes if needed.
This should look like this :
Note : update Sensory path names with latest release number. Screen capture has been made with Fluentchip V2.0.14, but now the latest release is 3.0.7 so your path should be something like C:\Sensory\FC3_0_7\...
then click OK when finished.
To build the project, mikroC needs to know all of its parts.
Go to Project -> Add to Project to add :
Adding SPEECH to your projects with QS4
QS4 (QuickSynthesis 4) is a Sensory tool that turns sounds files into a linkable module, you can add them to your VRStamp project just like a library.
Here is a very fast and easy way to add a robot voice to your VRStamp project :
Open Windows Control Panel, switch to "Classic View", launch "Voice", you will get Microsoft voice synthetizer :
Playing with Microsoft Sam's voice : you will get a robotic synthetized voice
When you are ready, record the voice with your preferred audio software tool : I recommend you to use GoldWave, you can try it for free.
Then save synthetized speech into distinct files, launch QS4, create a new project and add the files by clicking on the green cross :
Apply SXL compression to all files : Edit -> Select All Files, Edit -> Edit Compression Details, select SXL 8K (lowest bit rate, less ROM consumption).
Then build the linkable module by clicking on the "Build" icon. You will get an alert box about the zero-state version of the Fluentchip library, but don't panic : it is normal.
MikroC RSC-4x Project Example
Here is the project ready to download :
full mikroC project folder, 1.97 Mo
Download the ZIP file, unzip it to a new folder, then open the project with mikroC RSC-4X compiler.
A ready to flash .HEX file is packaged in the zipped file.
Instructions for use
This program learns and recognize four speaker-dependant keywords.
To train a keyword, press its button : the corresponding LED will start to blink. The program prompts to say the keyword twice, if the training is successful the LED is on, otherwise the LED is off.
The first keyword changes the animation style. There is a set of five animations for demonstration purpose.
The second keyword slows the animation : the time between each step is increased.
The third keyword speeds the animation : the time between each step is reduced.
The fourth keyword stops the animation, and gives back control to the buttons.
The program can say fourteen different phrases (prompt, error messages...) depending on context, please pop up the volume of the on-board speaker system.
The READY LED is on if all keywords are trained, you can then press the START button to start the LED light show : recognition mode is enabled.
The keywords templates and program status are stored to the VRStamp built-in EEPROM, the program restarts at power-up in the same status he was before power down.
If you want to clear the templates and status, press the START button at power-up.
This picture is a summary of the set of Easy-VR Stamp board commands and controls of this project :
This video capture is a short demonstration of the training phase and the voice recognition mode :
C Source Code
This is the mikroC RSC-4X source code, as it is in the ZIP archive.
Please use the zipped archive to get a ready-to-build project.
After power-up :
#define BASE_TMPLT (long)sizeof(CONF_STRUCT) // template offset, leave place for configuration structure in EEPROM
#define MAX_SPEED 8
CONF_STRUCT confStruct ; // configuration structure
PARAMETERPASS res ; // parameters passing structure, needed by Fluentchip functions
uchar cnt ; // status LEDs duty cycle counter
cnt++ ; // increment duty cycle counter
irq = ~T3_IRQ ; // clear tm3 irq flag
if(clear) // clear before saving ?
for(i = 0 ; i < sizeof(CONF_STRUCT) ; i++) // write all bytes
for(i = 0 ; i < sizeof(CONF_STRUCT) ; i++) // read all bytes
_PutTmpltListBase(firstTmplt) ; // define template start
switch(_MakeTmpltWs(SETUP_TIMEOUT, 2, 2)) // record keyword, first time
confStruct.dc[slot] = 11 ; // change LED blinking duty cycle
switch(_MakeTmpltWs(SETUP_TIMEOUT, 2, 2)) // record keyword again
switch(_TrainSd(slot, SD_DEF_LEVEL, 12, &res)) // compare & average templates
default: // record is not successful
default: // first record is not successful
if(err) // if an error occured
_PlaySnd(SND_thank_you, (long)&SNDTBL_LEDLIGHTSHOW, SX_FULL_VOL) ; // play the sound "thank you"
if(confStruct.learnFlags == 0x0f) // check for all keywords to be ready
writeConfig(0) ; // save to EEPROM
confStruct.dc[STATUS_LED] = 7 ; // blink status LED
_PlaySnd(SND_listening, (long)&SNDTBL_LEDLIGHTSHOW, SX_FULL_VOL) ; // play "listening" sound
_PutTmpltListBase(firstTmplt); // define template start
switch(ret) // test return code
_PlaySnd(SND_ok, (long)&SNDTBL_LEDLIGHTSHOW, SX_FULL_VOL) ; // play "ok" sound
writeConfig(0) ; // store configuration to EEPROM
SHOW_PORT = 0 ; // turn off LEDS animation
confStruct.dc[STATUS_LED] = 255 ; // turn on status LED
p1ctla = 0xff ; // full port 1 as output
p2ctla = 0xff ; // full port 2 as output
firstTmplt = BASE_TMPLT ; // template offset is constant because we are using external EEPROM
_InitCollection() ; // initialize system for audio block collection
_PlaySnd(SND_welcome, (long)&SNDTBL_LEDLIGHTSHOW, SX_FULL_VOL) ; // play the "welcome" sound
for(;;) // forever loop
switch(btn) // test button
MikroC project files
Here are the files dependencies (mikroC screen capture) :
ledLightShow.c is the C source code above.
config.mca is a very important assembly file : it contains hardware specific definitions, read it carefully.
qs4\LEDLIGHTSHOW.MCO is the linkable object module generated by QuickSynthesis 4 project build : it contains the compressed sounds. Note that the C source code includes a qs4/ledLightShow.h definitions file, automatically generated by QS4 too.
fc4128zws.mcl is the zero wait state library for RSC4128 MCU. Note that zero wait state library is needed, because we have selected the SXL audio compression mode in QS4 for minimum ROM requirement.
mem24xxx-400khz.mcl is the memory driver for VRStamp built-in serial EEPROM : all FluentChip recording, training and recognizing functions will use the serial EEPROM as main storage. It is a little bit slower at run-time, but voice templates are not lost a power down.
If you have any questions or comments about this example, don't hesitate to open a topic in my forum.