Unable to play music while the Activity Bot Roaming(Solved by Andy Lindsey)
msiriwardena
Posts: 301
The activity Bot with XBee S2C is programmed to roam and it works.
I am trying to play music while roaming.
I have placed the wav blocks in many places in the program and no music
and most of the time the bot does no move.
Since the wav block "Play file" starts 2 new cogs, should play music.
I can play music using the wav blocks and not while roaming.
I saw the "Whitt's" video in it the " voice turning Etc. " stops when
the robot moves.
I want the bot to play music and roam at the same time.
I have placed the program in the public projects - Named:"XBee S2C RF controlled Receiver Activity Bot"
I will place the "XBeeX2C Transmitter activity Bot" in the public projects.
I would like some advice,
Thank you,
Siri
I am trying to play music while roaming.
I have placed the wav blocks in many places in the program and no music
and most of the time the bot does no move.
Since the wav block "Play file" starts 2 new cogs, should play music.
I can play music using the wav blocks and not while roaming.
I saw the "Whitt's" video in it the " voice turning Etc. " stops when
the robot moves.
I want the bot to play music and roam at the same time.
I have placed the program in the public projects - Named:"XBee S2C RF controlled Receiver Activity Bot"
I will place the "XBeeX2C Transmitter activity Bot" in the public projects.
I would like some advice,
Thank you,
Siri
Comments
Siri
Have you tried "Download SimpleIde Files" and reviewing the C program to see how the wav code is being used? I find that a good way to debug placement of blocks or calling functions.
Tom
I added the wav blocks to many places in the program.
Attached is the program with wav blocks. I even tried adding a "empty Frever" block.
Thanks for your help.
Siri
2 wav blocks and pause. 1.set volume and play file wave blocks
and a pause placed anywhere in the screen.- see screen shot.
I do not know whether it is by design or not.
If you delete the pause, music will not play.
The problem begins when you add this set up to your program.
Siri
PS: I found out ,it plays music and bot roaming without navigation.
The bot just goes straight a head. No fun.
siri
Looking at the blocks you posted I think that the initial cog is calling the wav function which then requires the pause to play the wav. No other commands can happen in the cog until the pause finishes.
Try defining the wav as a function in a new cog like in the image below. Even though wav opens new cogs, you will have to call it in a new cog so that the original can keep doing other stuff. The problem will be if you run out of cogs (XBEE, abot commands, wav cogs, etc.) I think you will probably use 6 cogs.
Hope this works (I don't have the hardware to try it out at this time).
Tom
*In BlocklyProp, we refer to the extra processors as processors, but in Spin/ASM we call them cogs.
Ken Gracey
The project has a public link "XBee RF controlled Receiver Activity Bot"
and tried what you suggested and no music or any movement from the
bot and XBee is receiving the transmitted signals "The blue LED blinks"
but no response.
The IDE files are attached.
Ken - As I counted the number of "cogs - I am little more verse with spin"
The number comes to 5/6 the most.
Thanks for the help.
Siri
In "main" try putting an infinite loop after I think that the way it is currently written, "main" starts the other cogs, but then the program ends. Keep it running with a repeat forever block.
Tom
I placed an empty " forever block" at end after "drive_speed(64,64)" and
no music or any movement from the bot.
Siri
Could you please post a link to your project? I found one that has a similar name, but it doesn't look like what you have been talking about above.
In the meantime, I took a look at the zipped C code, and noticed that it is launching the dowav function into a new processor. That could be one of the causes of the unusual behavior. When your code plays a wav file, it automatically lunches another processor, and then the wav code runs in the background while your main code can move on. When you try to do that from another processor, the block does not allocate enough stack space for the wav player. Even if it could, I'm pretty sure the memory penalty would also cause trouble.
Andy
I've had this exact type of failure, too. Please see this code as an example http://learn.parallax.com/tutorials/language/blocklyprop/spooky-doll-project/adding-sound-and-movement, Siri. When creating this project I also tried to put the wav file playback in a New Processor block, which does not work.
Ken Gracey
Andy,
Will the ActivityBot be able to accept commands from the XBEE and change movement (moving continuously) while the wav is playing?
Thanks
Tom
I tried without using a new processor and nothing happens.
@twm47099 - The activity bot receives the commands(blue LED flickers) but robot will
not react to the commands.
The attached code(IDE) will only play music for ashort while(due to the pause in wavefunction)
siri
P.S. BlocklyProp examples with equivalent code in next post.
If you prefer BlocklyProp advice, you can make the project public. and share the link. To do this, in your project, click the menu in the upper-right below the project name and select Edit Project Details. Click the Public button, and then click Save.
I recommend combining in small pieces. As in, test each of these individually first, and then combine them.
For example, this would test to make sure the WAV file plays.
...and this would test a simple ActivityBot maneuver.
Next, you can try them together, like this:
Other things to try in the C code you posted:
On line 28 of the C code, try adding while(1);
Try adding drive_speed(0, 0); as the very first call in the main function.
Here are BlocklyProp examples of the same tests:
Make sure to check the comments in Test WAV Play with ActivityBot Forward.
Test Wav Play with ActivityBot Forward add XBee
One thing I would suggest trying in C is moving that line out of main and putting it as the first line of receiver(). I've written a few programs using a bluetooth receiver in its own cog and always did the fdserial_open in the bluetooth cog.
I altered the program as you suggested putting
the initialization of the Xbee in the Receiver function.
The program only played the whole song and
will not react to any Xbee commands from the transmitter.
Siri
I made public link to the project as you suggested'
I will try the other suggestions a little later
and let you know the results.
Thanks for helping me.
Siri
All I see that's public under your name is this one:
http://blockly.parallax.com/blockly/editor/blocklyc.jsp?project=87887
The one I think I should be looking at is this:
http://blockly.parallax.com/blockly/editor/blocklyc.jsp?project=84127
Is that the correct project? If so, it is still not shared.
The project #84127 is mine.
I will try sharing again.
Siri
PS :http://blockly.parallax.com/blockly/projectlink?id=84127&key=c4bf128b-c5dd-4ec8-99d5-a73376f66847 - this the link.
I have taken the WAV blocks off .The project as is (with out -wav is responding to XBee commands from the Transmitter.
Exactly as I wanted.
Siri
When I play the C file to test the wav player, error pop up
"unable to connect to port"
But when I play the Blocks :1.wav.volume(10)
2.wav play file(loveher)
3.pause(90000)
The full song is plays.
Siri
ps; I will try your C file few more times.
After I added the Line after mount "wav_volume(10)"
The song played.
So test wav passed.
Tested maneuver it passed too.
Maneuver and sound both together - passed too
Siri
when I add "while(1);" 28th line in C code and when drive_speed(0, 0) - nothing happens.
Regards,
Siri
I have placed the Function "dowave" at all the positions in the program:
1.At the beginning before initializing the Activity bo
2.After initializing activity bot
3.Before and after the "function receiver"
4.Placed it even in the "receiver function"
As far as I can see no matter where I place the "do wav " nothing happens.
will not play music or bot responds to transmitted commands.
I don't know whether the observation that when the "do wav" function in the
"function receiver" RED LED glows on the XBee.
Other observation is that Robot moves and play music without the Xbee.
I am out of any ideas.
I hope you will find a solution.
Thank you.
Siri
I am writing a version of the test code that receives XBee values without using the simplextext library's dprint function. If that works, there might be enough room for all to work together.
IMPORTANT: I may have inadvertently changed the wiring. Or not, please check your boards. On my ActivityBot (receiver) and my Activity Board connected to the computer (transmitter), both have P9 connected to DO and P8 connected to DI.
Load Receiver XBee WAV ActivityBot.c into your ActivityBot and set PWR to 2. (Don't worry if nothing happens.)
Connect the transmitting Activity Board to the computer and run Transmitter to XBee WAV ActivityBot.c. Then, follow the prompts in the terminal. You will enter left speed, right speed, and play state. When you press Enter after that third value, the ActivityBot should set wheel speeds and play the tune.
ActivityBot Code (Receiver)
Code for Activity Board Connected to Computer (Transmitter)
Your code works but it defeat my goal to
have a mobile transmitter not attached to the computer.
I sincerely thank you effort to solve my issue.
Siri
Next step is converting it to something you can continue to work with. To that end, do you prefer to develop this in BlocklyProp or C?