Hi Need help with IR SENSOR.

prajesh828

New Member
Here is my program. I want to see if my ir sensors are working or not.

Code:
#rem

***********************************************************************
                                                                          *
 *     DESCRIPTION                                                        *
 ************************************************************************ *
 * This program Tests the robot whiskers and moves to the appropriate navigation subrouotine.
 * RIGHT FORWARD IS PIN   , BACKWARD PIN   
 * LEFT FORWARD IS PIN    , BACKWARD PIN  
 * RIGHT SPEED PWM  
 * LEFT  SPEED PWM  
#endrem
        symbol swR = C.4     'Define input pin Left whisker
        symbol swL = C.6     'Define input pin Right whisker
         
#rem
 ***********************************************************************
 *
 *     Define output pin usage
 ***********************************************************************
#endrem
        symbol  PIEZO   =  B.1  	' AUDIO OUTPUT TO PIEZO SPEAKER
        symbol  ledr    =  B.0   	' Left LED
        symbol  ledl 	=  B.2 	' Right LED
        
#rem

***********************************************************************
 *
 *     Define variables                                                  *
 **********************************************************************
#endrem
        
      '  symbol	time	= b7
      '  symbol	whiskers	= b8
                              
#rem
 ***********************************************************************
 *
 *     Program Initialisation 
 ************************************************************************

 The program starts execution here when the processor is powered up, is
 reset, and after the program has been downloaded.

 The output pins are immediately cleared to stop the motors, and then the 
 program issues two low frequency beeps on thepiezo transducer to indicate 
it has initialised, and then waits 5S to allow the other processors to be
initialised ( and power to be applied to the motors if switched off ).
#endrem

 
tune B.1, 6,($40,$40,$45,$44,$45,$40,$02)


main:
	forward a pwmout C.1, 99, 200
	forward b pwmout C.2, 99, 198
	irin A.3,b0
	irin A.0,b1
	debug


	if b0>180 and b1>180 then go
	if b0>180 and b1<180 then left
	if b0<180 and b1>180 then right
	if b0<180 and b1<180 then rukhja

goto main

go:
	high ledl
	forward a
	forward b
	high ledr
	
goto main

left:
	high ledr
	forward a
	backward b
	low ledl
goto main

right:
	
	high ledl
	forward b
	backward a
	low ledr
goto main

rukhja:
	low ledl
	halt a
	halt b
	low ledr
goto main

i have attached my files what m using.
Used 28x2 on picaxe. Now Should i use readadc A.0 or irin? It should clear the maze of line. Line is black line while rest is white. So confused.
A.0 and A.3 are my sensor pins.
 

Attachments

tony_g

Senior Member
datasheet just opens as 3 blank pages when i try to view it.
irin is as i understand from manuals for ir remote use. guessing they are like photo reflective sensors of sorts i would try readadc.
 

Pauldesign

Senior Member
Hi Prajesh,

Almost a year now i last play with that and i can't instantly help you and before i could read and assist you, perhaps someone will get it done for you.

All, i'll say is:

- Start simple with the basic infra code found on the latest PICAXE datasheets (that' we know works).

- Use the code to ensure your IR Tx/Rx sensors are working.

- You can easily detect the IR sensors working activity using your cell phone/laptop camera. (normally, it will appear purple or violet if working)

If that's ok then the problem lies in your code and I hope somebody will assist you with that before your submission.

Good luck.
 

John West

Senior Member
Very good idea about the cell-phone camera. I'll have to try mine and see if it does IR, or if they actually spent the money for an IR filter or coating. Not likely in a $30 cell-phone. IR monitoring may be its saving grace, as it's a lousy cell-phone with a pathetic camera.
 

hippy

Technical Support
Staff member
Used 28x2 on picaxe. Now Should i use readadc A.0 or irin? It should clear the maze of line. Line is black line while rest is white.
As they are line sensors it seems unlikely they'd be receiving Sony IR commands so it's unlikely to be IRIN and more likely to be READADC. Without details on the sensor it's hard to say.
 

westaust55

Moderator
Is the to do with the "Alert Bot 2.1" thread you (incorrectly) previously started in the completed projects area?

Is it in fact the Rev Ed BOT120 as mentioned in that thread?
http://www.picaxe.com/Hardware/Robot-Kits/PICAXE-20X2-Microbot/
http://www.picaxe.com/docs/bot120.pdf

are the sensors from the BOT121 sensor kit for the BOT120?
http://www.picaxe.com/docs/bot121.pdf

we need a link to the specific devices you are using to understand how they work before folks here can provide specific help for you.
 

inglewoodpete

Senior Member
datasheet just opens as 3 blank pages when i try to view it.
irin is as i understand from manuals for ir remote use. guessing they are like photo reflective sensors of sorts i would try readadc.
I get 3 blank pages too.

The sensor is usually an IR demodulator module. If yours is the typical one, the sets its open collector output to low when a 38kHz IR signal is detected. You need a pull-up resistor on the output, so that the module can pull the line low when it receives a 38kHz IR signal (bandwidth is fairly broad so you can usually detect anything between 36kHz and 40kHz).

The output is digital, so set the input of the PICAXE as a digital input: ADC is no good. You can use the IRIN command if the transmitter is using the SONY SIRC protocol.
 

hippy

Technical Support
Staff member
Is it in fact the Rev Ed BOT120 as mentioned in that thread?

... we need a link to the specific devices you are using to understand how they work before folks here can provide specific help for you.
Absolutely. There seems to be some confusion over what you are attempting to do, which sensor modules you have, where they are connected and how they should be used.

Each line tracker module for the BOT120 Microbot provides an analogue output which is read using READAC. There is also an IR Receiver board which can receive IR commands from a handheld remote control that can be read with IRIN.
 

prajesh828

New Member
Sorry about it. I'll provide jpeg format now.I have attached 2 files and rest of the pictures via url.

http://www.hvwtech.com/products/1049/PICAXE%2028x2%20Pinout.jpg

http://s17.postimage.org/49qq8s6un/alert.jpg
http://phys253-partyvan-2010.net84.net/upload/electrical/qrd1114.png

My robot should clear a maze similar to the line image. But it does not i redone the program again today.

Here it is.

Code:
symbol counter = b3
main:

high b.1 high b.2

readadc A.1,b0
readadc A.2,b1
debug b0
debug b1

low b.1 low b.2
if b0 < 200 and b1 < 200 then goto forw
if b0 < 200 and b1 > 200 then goto right
if b0 > 200 and b1 < 200 then goto left
if b0 > 200 and b1 > 200 then goto speed

goto main

forw:
forward A pwmout C.1, 99, 300  
forward b pwmout C.2, 99, 300
goto main


left:
do
readadc A.1,b1
backward a pwmout C.1, 99, 290 
forward b  pwmout C.2, 99, 325 

loop while b1>200 

goto main


right:
do
readadc 0,b0
backward b pwmout C.2, 99, 290 
forward a pwmout c.1,99,275 
 
loop while b0>200                                      

goto main

speed:
counter = counter +1
if counter > 3 then end
else
forward a
forward b 
pause 500
endif
goto main
it does not read any value yet and the ir sensor is not working. tried trouble shooting it and not helping :(. Ya it is the alertbot 2.1 i talked about.Sorrry for the confusion.
 

Attachments

westaust55

Moderator
From the links we can establish that the IR sensor is a QRD1114
http://www.hvwtech.com/products_view.asp?ProductID=97

The output is recommeded to be connected to an ADC input. The information is general but a while area under the sensor will an output of 5V (ie supply voltage) and a black area under the sensor will be somewhat lower (needs trial and error testing to determine a "black" setpoint)

Before you worry about solving the maze, you first need to ascertain if the IR sensors are working and what READADC value is received for the black and white areas.

The AlertBOT PCB track layout is hard to identify while pin on connector JP1 the 28X2 pinA.2 goes to.
Can you please post a schematic showing exactly how YOU have the QRD1114 IR sensors wired to the PICAXE.
Also a good clear straight-on (not at an angle) photo of the relevant part of the circuit so we can clearly follow the wiring to trace the wires to make sure the wiring matches the schematic and go to PICAXE pins A.1 and A.2 may be helpful.
 
Top