Showing posts with label RobotC. Show all posts
Showing posts with label RobotC. Show all posts

Monday, December 20, 2010

Kudos To The Developers of RobotC

I have been grumbling about the only real downfall of RobotC for a while and that was the fact that they didn't make it easy to communicate via Bluetooth to more than one NXT. I have six of those bad boys and it makes it very difficult to build a robot of any size if they can't communicate effectively. I had exhausted all of my normal avenues for a solution and still nothing. I have gone so far as to create an effective way to communicate with the PF LED and a light sensor JUST so I could communicate with more than one other NXT, but that has its limitations as well.


When I contacted the developers on the RobotC forum, the reply that I constantly got was "You can do it, but it's too slow to use BT with more than one slave." I didn't think that this was an acceptable answer, who are they to tell me what is too slow? They have no idea how I am going to use it.

In the latest releases of RobotC, they had actually taken away some of the "easy" BT communication commands, and I became even more frustrated. A lot of my previous code no longer works without a rewrite. Ugh! But I knew that BT still worked, I was just going to have to "relearn" how to do it.

So I got into it more with the "Help" files and Sample files that are available. I say that with some sarcasm because the Help files are limited, VERY limited. After a full weekend of scratching my head and cussin', I discovered that RobotC actually has pretty stout Bluetooth capabilities, and best of all, I can now communicate with three other NXTs, and I can use all ten mailboxes on each of them (even though their sample files and Help files don't tell you that you can). Yes, yes it is slow, and I am perfectly fine with that as long as I know it going into my project. It's just another design constraint that I have to deal with. There are a few commands that are extremely fast and I will judge each function case by case.

Anyway, Thank you RobotC developers for making the capabilities available, even though you really don't tell us how to do it.

Friday, July 9, 2010

Ringtone Converter for RobotC

If you like to play music on your NXT, if you use RobotC and have access to Microsoft Excel, have I got a deal for you!

I have created an Excel spreadsheet that will very easily convert RTTTL (Ring Tone Text Transfer Language) ringtones into RobotC code with very little effort. RTTTL ringtones are the original ringtones that were just beeps and tones.

The Excel file contains over 300 ringtones ready to convert just by selecting which one you want and then putting the code into your file. You can also add your own ringtones that you may already have or have found on the ‘net. I have found thousands of free ringtones. It will only work with RTTTL format files and RobotC.

Some of the files need considerable tempo adjusting to sound right, so I have added a way to adjust the tempo of the music.

Here is a sample of the output of the file: (yes, this code works, try it out!)

nxtDisplayCenteredTextLine(0, "Star Wars");
PlayTone(695, 14); while(bSoundActive);
PlayTone(695, 14); while(bSoundActive);
PlayTone(695, 14); while(bSoundActive);
PlayTone(929, 83); while(bSoundActive);
PlayTone(1401, 83); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1188, 14); while(bSoundActive);
PlayTone(1054, 14); while(bSoundActive);
PlayTone(1841, 83); while(bSoundActive);
PlayTone(1401, 41); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1188, 14); while(bSoundActive);
PlayTone(1054, 14); while(bSoundActive);
PlayTone(1841, 83); while(bSoundActive);
PlayTone(1401, 41); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1188, 14); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1054, 55); while(bSoundActive);
wait1Msec(280);
PlayTone(695, 14); while(bSoundActive);
PlayTone(695, 14); while(bSoundActive);
PlayTone(695, 14); while(bSoundActive);
PlayTone(929, 83); while(bSoundActive);
PlayTone(1401, 83); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1188, 14); while(bSoundActive);
PlayTone(1054, 14); while(bSoundActive);
PlayTone(1841, 83); while(bSoundActive);
PlayTone(1401, 41); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1188, 14); while(bSoundActive);
PlayTone(1054, 14); while(bSoundActive);
PlayTone(1841, 83); while(bSoundActive);
PlayTone(1401, 41); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1188, 14); while(bSoundActive);
PlayTone(1251, 14); while(bSoundActive);
PlayTone(1054, 55); while(bSoundActive);
I don’t have a site for downloading, so all you’ll have to do is send me an email at Tinkernology_at_yahoo_dot_com requesting the converter and I will reply with the Excel file along with a RobotC file I created with 42 songs already converted and ready to play for your use. That’s almost 10 minutes of music ready to play.

And if you are an Excel Junkie like me, you will enjoy tearing this file apart. I spent many hours working on it.

Rock On!

Friday, February 26, 2010

RobotC Page

I just noticed, I am getting some sweet show-off time over at the RobotC page right now.  On the homepage, the DominoBot video is up in the corner.  Plus over at the "Cool RobotC Projects" page, they are showing my Flexpicker, the DominoBot and a blurb about MARVIN.


Sunday, February 21, 2010

RobotC Sample Music program

A topic came up over at the RobotC forums about how to play music in RobotC. I spent some time messing with it a few months ago, so I spent some time researching it again. Please keep in mind I haven’t played a musical instrument or read sheet music since I quit band in 6th grade back in 1979.

First thing I did was to find some very easy and free sheet music with familiar tunes. I found this place, but I am certain there are plenty of places to find music. Then I did some research on the notes and such and I reverted to the reliable Wikipedia. Then I spent some time in NXT-G figuring out which tones go with which note.

I then created this cheat sheet which I keep by my side as I am translating the sheet music to variables in the RobotC array.

So here is what I came up with. A sample program to start with when I find new sheet music that I want to convert to RobotC music. Here is a link to the sheet music I used.

// Frequency (note)
// Example: A_3 is A in the third octave
// Ash_3 is A# in the third octave
int C_3 = 261;
int Csh_3 = 275;
int D_3 = 293;
int Dsh_3 = 310;
int E_3 = 329;
int F_3 = 348;
int Fsh_3 = 370;
int G_3 = 392;
int Gsh_3 = 412;
int A_3 = 440;
int Ash_3 = 466;
int B_3 = 496;
int C_4 = 524;
int Csh_4 = 555;
int D_4 = 590;
int Dsh_4 = 621;
int E_4 = 656;
int F_4 = 695;
int Fsh_4 = 738;
int G_4 = 788;
int Gsh_4 = 830;
int A_4 = 877;
int Ash_4 = 929;
int B_4 = 987;
int C_5 = 1054;
int Csh_5 = 1104;
int D_5 = 1188;
int Dsh_5 = 1251;
int E_5 = 1322;
int F_5 = 1401;
int Fsh_5 = 1488;
int G_5 = 1590;
int Gsh_5 = 1646;
int A_5 = 1770;
int Ash_5 = 1841;
int B_5 = 1995;
//Duration
int Dwhole = 200;
int Whole = 100;
int Half = 50;
int Quarter = 25;
int Eighth = 13;
int Sixteenth = 6;

int Notes[][]= //currently “Ode to Joy”, Change these notes for a new song
{
{F_4, Quarter},
{F_4, Quarter},
{G_4, Quarter},
{A_4, Quarter},
{A_4, Quarter},
{G_4, Quarter},
{F_4, Quarter},
{E_4, Quarter},
{D_4, Quarter},
{D_4, Quarter},
{E_4, Quarter},
{F_4, Quarter},
{F_4, Quarter},
{E_4, Eighth},
{E_4, Half},
{F_4, Quarter},
{F_4, Quarter},
{G_4, Quarter},
{A_4, Quarter},
{A_4, Quarter},
{G_4, Quarter},
{F_4, Quarter},
{E_4, Quarter},
{D_4, Quarter},
{D_4, Quarter},
{E_4, Quarter},
{F_4, Quarter},
{E_4, Quarter},
{D_4, Eighth},
{D_4, Half},
{E_4, Quarter},
{E_4, Quarter},
{F_4, Quarter},
{D_4, Quarter},
{E_4, Quarter},
{F_4, Eighth},
{G_4, Eighth},
{F_4, Quarter},
{D_4, Quarter},
{E_4, Quarter},
{F_4, Eighth},
{G_4, Eighth},
{F_4, Quarter},
{E_4, Quarter},
{D_4, Quarter},
{E_4, Quarter},
{G_3, Half},
{F_4, Quarter},
{F_4, Quarter},
{G_4, Quarter},
{A_4, Quarter},
{A_4, Quarter},
{G_4, Quarter},
{F_4, Quarter},
{E_4, Quarter},
{D_4, Quarter},
{D_4, Quarter},
{E_4, Quarter},
{F_4, Quarter},
{E_4, Quarter},
{D_4, Eighth},
{D_4, Half},
};

task main
{
for (int i=0; i<62; i++) //change the "62" to the new number of notes in the piece
{
PlayTone(Notes[i][0], Notes[i][1]);
while(bSoundActive);
wait1Msec(20);
}
}
Have Fun!

Friday, February 19, 2010

RobotC Freebie

Ode to Joy in RobotC

int Notes[][]=
{
{695, 25},
{695, 25},
{788, 25},
{877, 25},
{877, 25},
{788, 25},
{695, 25},
{656, 25},
{590, 25},
{590, 25},
{656, 25},
{695, 25},
{695, 25},
{656, 13},
{656, 50},
{695, 25},
{695, 25},
{788, 25},
{877, 25},
{877, 25},
{788, 25},
{695, 25},
{656, 25},
{590, 25},
{590, 25},
{656, 25},
{695, 25},
{656, 25},
{590, 13},
{590, 50},
{656, 25},
{656, 25},
{695, 25},
{590, 25},
{656, 25},
{695, 13},
{788, 13},
{695, 25},
{590, 25},
{656, 25},
{695, 13},
{788, 13},
{695, 25},
{656, 25},
{590, 25},
{656, 25},
{440, 50},
{695, 25},
{695, 25},
{788, 25},
{877, 25},
{877, 25},
{788, 25},
{695, 25},
{656, 25},
{590, 25},
{590, 25},
{656, 25},
{695, 25},
{656, 25},
{590, 13},
{590, 50},
};

task main
{
for (int i=0; i<62; i++)
{
PlayTone(Notes[i][0], Notes[i][1]);
while(bSoundActive);
}
}

Sunday, December 13, 2009

RobotC Cool Projects

The guys over at RobotC have created a page where they showcase some cool projects that have been programmed in RobotC.  One of them looks vaguely familiar to me..


Sunday, November 29, 2009

RobotC 2.0 Now Available.

After what seemed to be decades, the programmers of RobotC have announced they have finally released version 2.0. If you know anything about the program, it has been updated in the 1.xxxx realm many times and sometimes created more problems than were fixed. If you have paid the $30 for a previous version, the license is still valid and upgrading is free. If you want to try RobotC, you can download it and use a fully functional version for 30 days before you are required to pay the $30 license fee.

RobotC is my preferred programming environment when I need more power than can be found in NXT-G. I always recommend it, but the only real drawback I can say is that they don’t support Bluetooth communications between more than 2 NXTs. I am getting ready to download and install it, so I can’t really speak too much about the upgrade. In the past I have been pretty happy with updates, so moving up to 2.0 should be pretty easy and rewarding.

The upgrade can be done through this link.

From the RobotC website.

ROBOTC, a C-Based programming language for robotics
ROBOTC is the premiere language for educational robotics. It is a C Programming Language with an Easy-to-Use Development environment. It supports several different robotics platforms, including popular platforms such as the LEGO MINDSTORMS NXT and Innovation FIRST VEX. Download its blazing fast, High Performance Firmware to your robot. Using its Interactive Run-Time Debugger, you can easily pinpoint the problems in your programs. Try it out today by going to the Downloads section and choosing your platform.