My SimpleBot
I just installed SimpleIDE 0-9-45 and the latest abdrive library, I noticed a couple of things, sonyremote.h is missing, and I am getting some unexpected things with the SD usage.
I thought that at one time that if you did not have an SD card inserted and tried to write to it, the program had a hang up, now it seems that the program does not care if you have an SD card inserted or not, it just continues on.
The actual writing to the SD card, in this program, is not what I am expecting. The program below I expect to see a 'START' and 'STOP' on separate lines, but all I see is 'STOP', on the same line, in the statAB0.txt file.
I am not sure what is going on, was there some changes made to the SD support program that we should be aware of?
Ray
I thought that at one time that if you did not have an SD card inserted and tried to write to it, the program had a hang up, now it seems that the program does not care if you have an SD card inserted or not, it just continues on.
The actual writing to the SD card, in this program, is not what I am expecting. The program below I expect to see a 'START' and 'STOP' on separate lines, but all I see is 'STOP', on the same line, in the statAB0.txt file.
I am not sure what is going on, was there some changes made to the SD support program that we should be aware of?
Ray
/* SimpleBot.c Semi-autonomous ActivityBot. November 21, 2013 */ #include "simpletools.h" #include "abdrive.h" #include "sonyremote.h" #include "simpletext.h" ///////////////////////////////////////////////////////////////////////////// volatile unsigned int IRpin = 8; static volatile int speedLeft = 0; static volatile int speedRight = 0; static volatile int speedLeftOld = 0; static volatile int speedRightOld = 0; serial *xbee; FILE *sp; /* Function prototype */ int IR_remote(int irPin); void ab_nav(void); void statAB0(int status); ///////////////////////////////////////////////////////////////////////////// int main() { // Add startup code here. /* SD socket pins. */ int DO = 22, CLK = 23, DI = 24, CS = 25; /* Mount SD card. */ sd_mount(DO, CLK, DI, CS); pause(50); /* Open serial port. */ /* Rx Tx MODE BAUD */ xbee = fdserial_open(7, 6, 0, 9600); pause(50); int key = -1; /* Start the diagnostic data log. */ statAB0(1); while(1) { // Add main loop code here. key = IR_remote(IRpin); ab_nav(); } } ///////////////////////////////////////////////////////////////////////////// void ab_nav(void) { if(speedLeftOld != speedLeft || speedRightOld != speedRight) { drive_speed(speedLeft, speedRight); speedLeftOld = speedLeft; speedRightOld = speedRight; } pause(20); } ///////////////////////////////////////////////////////////////////////////// /* IR remote control */ int IR_remote(int irPin) { int key; ir_tLimit(50); key = ir_key(irPin); /* PWR key to stop bot. */ if(key == PWR) { speedLeft = 0; speedRight = 0; } /* CH_UP key to go forward. */ if(key == CH_UP) { speedLeft = 32; speedRight = 32; } /* CH_DN key to go backward. */ if(key == CH_DN) { speedLeft = -32; speedRight = -32; } /* VOL_UP key to turn right on center. */ if(key == VOL_UP) { speedLeft = 10; speedRight = -10; } /* VOL_DN key to turn left on center. */ if(key == VOL_DN) { speedLeft = -10; speedRight = 10; } /* 0 key to prepare for SimpleBot POWER OFF. */ if(key == 0) { statAB0(0); } return key; } ///////////////////////////////////////////////////////////////////////////// /* SimpleBot diagnostic data log. */ void statAB0(int status) { high(26); char start[] = {'S','T','A','R','T'}; char stop[] = {'S','T','O','P'}; char cr[] = {'\n'}; sp = fopen("statAB0.txt","a"); pause(50); if(status == 1) { fwrite(cr, 1, 1, sp); pause(50); fwrite(start, 1, 5, sp); pause(50); low(26); } else { fwrite(cr, 1, 1, sp); pause(50); fwrite(stop, 1, 4, sp); pause(50); fclose(sp); pause(50); high(27); high(26); while(1); // Stop access to SimpleBot. } }
Comments
Most of the sd functions return 0 if success or an error code. It's up to your code to check. For an example, take a look at:
...Documents\SimpleIDE\Learn\Examples\Devices\Memory\SD with Tests.side
Andy
Ray
Close and reopen a file to change the write behavior from "w" to "a".
Ray
The functions do not require the floating point library the way sprintf and scanf do, but they work about the same.
For the get_Time() and get_Date(), I created a Python script that runs on my Raspberry Pi (RPi). Since the RPi runs 24/7, and I use Putty to quickly start up the script, I find this to be a very good solution. This will probably be expanded to help out other ActivityBot/Boards in the future.
So, again, I am open to suggestions and help.
Ray
Ray
The first step in your debugging process should be to isolate the problem. Start by testing if the problem is in getTicks or the sd writing process. One way to go about this would be to comment sd writing stuff and display the values with print. To continue the debugging, let's say the values display correctly. Next, try displaying the strings you created with print (and %s), to see what they look like. You can use the result of this to determine the string manipulation or SD writing process needs attention.
Another thing, you can use sprint with %d to write a decimal value to a string too; it's not just for float.
Andy
Ray
Ray
Ray
I am a student from St Lawrence College in Kingston Ontario
We are trying to keep the robot moving but we are having
a problem with the demand of the servos
We have only a 2 volt threshold to play with where the
robot will continue to move
with a full charge 11 volts ~ the robot will work to
9 volts and then the battry has to be charged
Is the problem the type of servo drives that we are using for
the wheels? any suggestions
Steve
seves@kingston.net
This looks like it might be a different topic. If so, please start a new thread. If you are using the material in learn.parallax.com, start the thread in this (Learn) forum. If this is different robot hardware (not ActivityBot), the Robotics forum would probably be a better home for the post. Please also be more specific about what kind of servo and other hardware you are using.
Andy
I ran this on my ActivityBt and got the following:
So, seems that the code is working basically as expected... Ray, Is your bot wired differently than the ActivityBot learn examples? Calibrated the encoders?
dgately
Ray
Ray
This is the actual data recording: This the data analysis:
Ray
This is not enough information to go on. What are the symptoms you are correcting when you recalibrate? You have the ability to display calibration settings and stream data to XBee. If they really need to be recalibrated, the XBee data should show the inability of one wheel to keep up with another, or significant drift between drive_getTicks and drive_getTicksCalc, or movement with speed(0, 0), things like that. Please substantiate with data and test code.
Andy
Again, not enough data. It would help to have zipped test code attached to the post along with a brief description of what the application is trying to do in your post.
Also, I suggested a test procedure yesterday for narrowing down the problem. What are the results from those tests?
For my bot, it did turn out to be precise, calibrated on the ground and then run on the ground with the USB cable connected, but I wouldn't worry if it were a tick or two off.
The main point here is that we tested drive_getTicks and see that it is correctly displaying negative values.
Now that that has been ruled out, we need to pick the next thing to focus on. Assuming you are using sprint to make the conversions from int to string, you could use print("myIntString = %s" myIntString) to test the output of sprint.
Continue focusing on one thing at a time, and narrow down the problem that way. It's the most important way to find bugs in your code, and also to find a question that coders are willing to look at and give advice. Large application programs are less approachable, so when you have a small test program that produces unexpected output, it will attract interest and advice.
Ray
Now, what about the signs of the tick counts remaining positive. Is that resolved?
Andy
Ray
With no load, my lions measure 7.7 V at the terminals, but at the barrel jack, it's 7.4 V. I'm assuming there's a diode at work there. With Propeller system load, battery voltage at the terminals is more or less unchanged, but barrel jack voltage drops to 7.2 V. So, like yourself, I'm seeing about 1/2 a volt difference.
Take a look at its schematic.
http://www.parallax.com/sites/default/files/downloads/28988-Li-ion-Boe-Bot-Power-Pack-A-Schematic.pdf
There's D6 in series, a fuse, and a couple transistors. I could see that adding up to 1/2 a volt.
Andy
Ray
The hardware:
SimpleBot is an ActivityBot which is a stock build using the Learn tutorial and the pamphlet that came with the product, the only deviation from the stock build is the insertion of the li-ion battery pack. I do not have the dexterity or patience to do a stock implementation, so I have a well insulated "loose fit" that takes care of my problem. I have installed an XBee Pro series 1 module, an SD card, a ping device with support circuitry, an IR detector with support circuitry, and the battery voltage circuitry. Plus I have just enough room left to install a Parallax compass module, which will be done in the next prototype phase.
The software:
First I have to mention that I have a Raspberry Pi(RPi) that is running a real time/date server, which uses an XBee to broadcast the data. The SimpleBot program basically is IR remote controlled, which broadcasts commands to the RPi to get the real time/date data. The program has an init process and a shutdown procedure, plus a learn segment. The program starts up by opening up some files, one of which is statAB0.txt, broadcasts to the RPi for real time/date, does a battery voltage reading and records the data. The shutdown procedure is by pressing '0' which again requests a real time/date, and gets another battery voltage reading, then goes into no access mode, you have to power down.
The learn mode basically uses the 'start' and 'mute' buttons to do a data recording/logging of the ActivityBot movements. The immediate use for this is it eliminates, or it least reduces the need for a tape measure and a protractor. I will probably have to implement a small interpreter so you will be able to play back the program that you will have developed from the learn mode session.
This is just a brief overview of which way I am heading with this, today I will probably do some code scrubbing, add some more comments, and do some real trial runs using surface contact. I will try to post the program tomorrow, if I have not infused my body with to much serotonin and pumpkin pie.
Ray
I am graduating your Rasberry Pi / XBee / TV remote/ ActivityBot Project from the Learn forum to the Projects forum. As you'll see from the descriptions of the two forums, Projects is a much better fit:
- Project forum: "Post your in-process and completed projects here, made from Parallax products. We encourage you to provide a schematic, code, and an explanation."
- Learn forum "Learners of all ages discuss Parallax tutorials, such as the Propeller C Learning System, Stamps in Class, PE Kit Labs, Shield-Bot, etc."
We really appreciate your posts and the interesting projects that you publish. They are awesome, especially this one! I just want to try to make sure they are in the right places.
Andy