Society of Robots - Robot Forum
Software => Software => Topic started by: airman00 on March 09, 2008, 06:24:01 PM
-
In the color recognition tutorial of admins ( which I used on my 3 in 1 bot) , I saw this code
where 108 is the reading taken
95 is the number for gray
112 is the number for white
now using our numbers:
grey floor = (108 - 95)/95 * 100 = 13.7% different
white line = (108 - 112)/112 * 100= 3.6% different
compare: white line < grey floor
therefore the sensor sees a white line
This pseudo code will not work on PICBASIC :
(108 - 112)/112 * 100= 3.6% different
Because 108-112 will give you a negative number ( which is unusable )
and when you divide by 112, you would get a number less than one ( also unusable)
So to fix that , I did this pseudo code
If reading < 112 then (112-reading) *100 / 112
If reading > 112 then (reading - 112) *100 / 112
112-reading gets rid of any possibility for negative numbers and by doing *100 first , instead of /112 first, that gets rid of numbers less than one.
Do all microcontrollers have an inability to deal with negative numbers and numbers less than 1?
Just thought I'd share,
Eric
-
Stop using PIC BASIC, give BoostC a try, that way you can use signed chars and integers.
http://www.sourceboost.com/
I was so happy with it, I actually paid for the no-limit version. It was still $30 cheaper than PIC BASIC
-
Stop using PIC BASIC, give BoostC a try, that way you can use signed chars and integers.
http://www.sourceboost.com/
I was so happy with it, I actually paid for the no-limit version. It was still $30 cheaper than PIC BASIC
I'll give it a try
but are there any books out there explaining how to use BoostC?
-
I got a license for the Hitech PICC compiler from a friend , so i'll give that a shot
there seems to be a lot of samples for that compiler, so that's always good
which PIC chip do you prefer frank?
-
Stop using PIC BASIC, give BoostC a try, that way you can use signed chars and integers.
http://www.sourceboost.com/
I was so happy with it, I actually paid for the no-limit version. It was still $30 cheaper than PIC BASIC
I'll give it a try
but are there any books out there explaining how to use BoostC?
BoostC was actually my first C language, the help file PDF in there explained absolutely everything.
I got a license for the Hitech PICC compiler from a friend , so i'll give that a shot
there seems to be a lot of samples for that compiler, so that's always good
which PIC chip do you prefer frank?
Depends on what I need to use, but the PIC16F690 is good for experimenting because it packs a lot of features (4 timers etc) into a small package, good for learning.
Other than that, it really depends on what you need to do.
But hey, what the hell, they're free anyways!