go_away

### Author Topic: How to seek candle while in the room for trinity firefigthing robot competition  (Read 2096 times)

0 Members and 1 Guest are viewing this topic.

#### abcsalem

• Beginner
• Posts: 5
##### How to seek candle while in the room for trinity firefigthing robot competition
« on: March 12, 2010, 03:34:46 PM »
I built a firefighting robot which can detect there is flame in the room, so I am all set for finding the room with the burning candle. I used UVTron for this using Handyboard as the main CPU.
My question is, how do I use my two photo diodes that they gave me to detect the candle light?
I have placed the photo diodes in a tube to shield them from room light. Has anyone had success and experience with this type of robot sensor for detecting the candle light, and have an example code to guide me on this.

#### little-c

• Robot Overlord
• Posts: 186
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #1 on: March 12, 2010, 05:01:46 PM »
your looking at a light seeking behaviour. a VERY basic behaviour is given below, if this makes sense, start developing code along these lines. I cant tell you values because they are very much dependant on the specific robot.

modify this simple behaviour.
R and L are right and left photodiodes RM and LM are the right and left motors

Code: [Select]
`if (R<L)RM >LMelse if (R>L)RM<LMelseRM=LM`
play with values and conditionals to make the robot behave better.

#### abcsalem

• Beginner
• Posts: 5
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #2 on: March 13, 2010, 02:31:00 PM »
Is there an actual code you can provide that would include motor settings, etc.
The "else" part would be very unlikely to get executed, since it is very hard to have both light values equal. An "else if" with condition of say light values are within 5-10 points of each other would be more likely to get executed. One lux (one candle light) is so low that it is very important to have the proper conditional statements with the right parameters.
Otherwise it won't work and that's where I am at, I am having problem setting up the right values for the the conditional statement and motor settings.

#### little-c

• Robot Overlord
• Posts: 186
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #3 on: March 13, 2010, 03:09:30 PM »
actual values are dependant on hardware tollerances and all sorts of random factors.

well done for picking up on the missing conditional statement.

genraly Id take the scale of your LDR output, divide the maximum diffrence into four, code the first three highest segments to have proportional steering response(max diffrence, max steer) and take the fourth as  the one side equals the other.

this should give seven diffrent conditionals, at which point you moddify the behavour to match the desired output.

play with motor values and nuber of conditionals(genraly an odd number) and resolution of conditionals.

if it reacts too violently, you might want to split the conditonal causing that reaction in half, or to lower the motor values.

#### abcsalem

• Beginner
• Posts: 5
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #4 on: March 13, 2010, 04:46:04 PM »
Can you explain what you mean by "divide the maximum difference by 4..."
Sorry, I am a newbie when it comes to building and programming a robot.
I definitely need more details, since I am unable to fill in the rest from your response.

#### little-c

• Robot Overlord
• Posts: 186
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #5 on: March 13, 2010, 05:07:21 PM »
when you stick the LDR right next to the candle, it reads a value(BTW, don't set the LDR on fire )
when its got a bit of tape over it, it reads a diffrent value.

the diffrence between these values is divided by four(arbatary, I start with four, it may need to be more or less)  this gives four blocks of values in which there can be a diffrence between the readings.

take the smallest value as equal, then take the remaining three values to generate diffrent turn speeds. direction been decided by which LDR has the higher value.

this is probably a naff program, so the responses need tuning, you change how quickly the robot turns, and the number of ranges the program uses to improve the behaviour.

#### abcsalem

• Beginner
• Posts: 5
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #6 on: March 13, 2010, 07:49:37 PM »
Forgive me for not understanding how this calculation is done. Like they say, "a picture worth a thousand words", an example would help me a great deal. My photo diodes values are 0-255. For ease of programming, I reversed them so that 0 means no light, and 255 means maximum light. My motor values are 0-100. The motor values 0-15
usually isn't enough to drive the robot. For simplicity I am using lower speed, e.g. I use motor(side, 20) for reduced speed, and motor(side, 30) for cruse speed. Side is port number for the left or right side motor. I have a routine to get photo diodes as:
getLeft()  and getRight. In your algorithm, if getLeft() returns 110, and getRight returns 50. The difference between these two numbers are 110 - 50 = 60. You are saying to divide 60 by 4 to get value of 15. Then how would I create 4 conditions from these numbers?

#### little-c

• Robot Overlord
• Posts: 186
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #7 on: March 14, 2010, 02:37:43 AM »
the LDR reads a value for the light when its right next to the candle. say X, 0 defines no light to exist.

so you use X/4 to give you the size of your bounds.
bounds would be

0-X/4; X/4-X/2; X/2-3X/4; 3X/4-X;

the side of the LDR that is higher dictates the direction of turn. this is easy to do by taking one side minus the other, and using the negative results to turn in the other direction.

the motor values you chose should make the robot turn with a suitable speed, normaly i start off with
same speed; one stoped one half speed; one stopped one full speed; one foward one back;

full speed defined as something sensible for the max speed of the robot.
you will need to refine it by changing the turn speeds, and possibly increasing the number of cases that it handles.

#### abcsalem

• Beginner
• Posts: 5
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #8 on: March 14, 2010, 10:39:03 PM »
thanks so much for trying to answer this post. The value I got from photodiodes when I put it next to candle is 14, and value I got when I covered the led was 255. From your 4 segments

X=14 and O=255

Putting it in the format you mentioned, I get:

O - X/4 = 255 - 3.5 = 251.5
X/4 - X/2 = 3.5 - 7 = -3.5
X/2 - 3X/4 = 7 - 10.5 = - 3.5
3X/4 - X = 10.5 - 14 = - 3.5

Is there a C source code that can present this better, I just don't see any easy solution to this.

#### little-c

• Robot Overlord
• Posts: 186
##### Re: How to seek candle while in the room for trinity firefigthing robot competition
« Reply #9 on: March 15, 2010, 01:32:19 AM »
this is just going wrong...

right, 14-255 gives 241

241/4 gives 60.25

so the ranges are -255 to -195; -195 to -135; -135 to -75; -75 to +75; 75 to 135; 135 to 195; 195 to 255;
which are in if else statements,

if (-255 to -195)

else if(-195 to -135)

this needs some refinement, but it does as a starting point.