
Originally Posted by
Kenjones1935
The code in my little cars is, in fact, very little. It only deals with distance. It does not calculate rates of speed, of approach, of turn. It does not calculate angles. It does no mapping.
Maybe my 16F887 based kit is not up to that task. I am not sure and I do not know how to find out. Maybe I could architect better in C, but it has been literally twenty five years since..... and I used to have a very extensive (corporate supplied) library.
Suggestions?
Ken
Hello Ken.
Sure, there are more powerful chips to use. There are also more powerful languages. But, the question is, what are you going to be doing, and do you really need to change chips, and or languages? So far, the use you have made the chip perform, is probably the equivalent of an old man walking with a walker. You have not taxed your current environment whatsoever! Sure, a lot more could be done, but I think, if it was done right, the most required might be an 18F device.
Currently, your PIC18F887 can handle 5 million assembly instructions per second. Your hardware (servo) can handle at maximum, 50 instructions per second (pulse width control at 50 hertz, or 20ms frames). So, with every chance to change your direction, your program can perform 100,000 assembly instructions. A lot of PBP code can fit into 100,000 instructions. That can basically go through every available code location (14k program space) on the chip seven times, during the 20ms it has to make a decision.
Seeing as you are hardly putting a dent in the 14k, shouldn't you at least try to do something more, before saying you don't think the chip can handle it?
Let's take a look at the items you mention:
Speed : This is relatively easy to do and will hardly take any code. Put a sensor on a wheel and away you go!
Approach of turn: You have all the distances measured, why not use them to in your control for turning. Calculate at what point in time will you be x length to the wall, and at this time turn, instead of saying "if my measurement is less than 4 feet, etc etc. Since you are only taking front measurements every 60ms?? or so, you might well be beyond the 4 feet by the time you measure.
Calculate angles: Cool idea. But with what sensors are you going to determine that? And how? PBP has SIN, COS, Hypotenuse and ATAN built in. Sure these are rough calculations, but I don't know that with your current sensors you will need (or be able to use) anything more advanced. Add a magnetometer http://www.sparkfun.com/products/9371 , and perhaps this could get more complex. If it does need to be more precise, there is a PBP compatible CORDIC include file to calculate SIN, COS, ATAN, Hypotenuse. See http://www.picbasic.co.uk/forum/showthread.php?t=10528 . On an 18F, you can do this 9,000 times per second while still using PBP in our program.
As for mapping, with your current set up, I would go out on a limb, and say that is impossible with any language. To map, you need to know where you are. You will need more sensors! A GPS (and a large outdoor "track"), or magnetometer, or light sensors that find at least a reference beacon, or barcode like strips on the floor, just to figure out where it is. Lots of ways to do it, some better than others.
So, from what you have vaguely mentioned, I see no barrier using your current chip, or using PBP. Can you be more specific about what function libraries you are talking about? What ever language you choose, you are going to have to decide how you are going to perform these functions, and what sensors you are going to use to do them.
Last edited by ScaleRobotics; - 21st January 2011 at 17:49.
http://www.scalerobotics.com
Bookmarks