Help need with IR detection and irin

Hi,

New to this malarkey so please excuse the ingorance.

 

I built the "Start Here" robot by fritsl. Works fine no problems - great introduction. Moved on to a BEAM mini sumo from Junkbots and got someone at work to explaine why it worked...

So, I have tried to expand and experiment with the pic based bot. I have added LEDs and light sensitive direction. Works OK

My problem is with the IR detection using a PNA4602 and irin.

I replaced the sharp GP2D12 with the PNA4602. From the left with the bubble facing;

   Pin1=output (middle pin)

Pin2=black (pin furthest from the edge of the board) and

Pin3=red (pin closest to the edge of the board) 

I started using readadc 0, b1 - that was what is in the code for the sharp. This sort of worked, with b1 changing from 255 to 3 as I pressed lots of remotes, always 3. I then read about irin and thats where I got bogged down. No matter what flavor of irin I used the program just hung on the irin line. It refused to either timeout of accept that an IR signal had been received. Going back to readadc, proved that the IR receiver was still working.

eg code

main:

irin [500 , main], 0, b1    or     irin 0, b1

etc

Im using PICAXE-28X1 (40X1) Firmware version 6

Have I plugged the PNA4602 into the correct place, looks ok because readadc at least reads in a value ?

Whats wrong with irin, it will not timeout or read anything in?

 

HELP

 

Do you have the associated

Do you have the associated resistors/capacitors for the IR Rx circuit?

Do something

Do something like:


 

main:

irin [500, timeout], 0, b1

check for IR code, what code, etc here

.

.

.

timeout:

return


When the IRIN command times out it will go to the TIMEOUT sub which will then return you to the line following your IRIN command in the MAIN subroutine.

BTW…

I thought I was the only one who said “malarky.” Then again, I thought I was one of the last to habitually use the words “epic” and “awesome” till I came here too.

I was just doing that on my project.

  What you have set up right now is just to sense if there is any IR light.  For what you want (I think) try looking at this https://www.robotshop.com/letsmakerobots/node/75 under C.

Hope it helps

Just so ya’ know…

The Picaxe 28x board (the one used for the start here robot) has provisions on it for the addition of a IR sensor. There are places on the board to solder your 3-pin IR sensor and the cap/ resistors needed to make it go. Picaxe also has/uses IR commands built-in so it is able to talk nice to any Sony brand remote as well as anything that can transmit a 38khz signal with sony protocal.

Might want to try this with your start here bot.

Helpful feedback … thanks

Well I have learnt a bit more so thanks for the feedback.

 

No I was not using the necessary resistors or capacitor and I was connecting the IR detector to the wrong place on the board, apart from that not too bad - good start.

The best lead was from another forum topic that pointed me at a Picaxe IR kit, which went on to a parts list and a real diagram showing where to stick the bits - not a mumbo jumbo circuit diagram (http://www.rapidonline.com/netalogue/specs/13-0840.pdf) . 

So I need 2 resistors and a capacitor - about a £1, not the £10 Picaxe want.

 

My code is still a question, irin does not timeout, perhaps when I have the parts in the correct place it may work better.

 

Thanks for your help!

Sorry…

I hate to bump an old thread, but oh well…

I’m currently trying to make my 28x board be able to recieve IR from a TV remote as well, but not having much luck. I think my problem may be in my code, though, as I have the reciever soldered directly into IR-area on the board (along with the necessary components)…

Right now, it looks something like this:

ircontrol:
IRIN [500, ircontrol],0,infra
if infra = 1 then gosub tiltup
if infra = 2 then gosub tiltdown
if infra = 3 then gosub panright
if infra = 4 then gosub panleft
if infra = 5 then gosub clawclose
if infra = 6 then gosub clawopen

I think I may be trying to use the wrong input pin, but let me know. Thanks.

RE: sorry
See my “Do something” reply below. See if changing your code to that structure helps.

I changed to using a 08M chip

I was eventually convinced that my soldering was not up to scratch, moved away from using the IR area on the 28x board.

I changed to use a 08M on a separate board and talked “serially” to the 28x - it sounded more interesting anyway… and it worked!

Pic_IR.jpg

28x code

 

#com 3

do 

  if pin2 = 1 then gosub get_data

loop

#picaxe 28X1

let dirsc = %00000000

 

get_data:

let dirsc = %00000000

serin 0,N2400,b1

if b1=51 then

gosub body_rturn

endif

if b1=52  then 

gosub body_lturn

endif

return

 

 

08M code

 

#picaxe 08M  

symbol junk = w0

do

 

infrain2

 

high c.4

pause 600

' pulsin c.4 ,1, junk

low c.4

serout 2, n2400,(infra)

debug

pause 1000

loop

 

Well…

First, “infra” was a symbol for b13, sorry I didn’t include that… I’m still not sure how to arrange the “if…then” statement.

Is this correct?

if b13= 1 / 2 / 3 / 4 / etc. then …

One last question:

Sorry I forgot to put this question in my last post.

The only other thing that I could think of that might be the problem is that I might have the microcontroller looking for the infra red signal on the wrong input pin. i.e: IRIN [500,ircontrol] 0, b13

You need a different subroutine to timeout to

I think you didn’t understand my previous reply. In short, you can’t timeout back to the same sub you’re already in. It seems to be how everyone tries to set it up the first time. Try this:


ircontrol:

irin [500, timeout], 0, b13

insert your check for IR code here

 

timeout:

return


 

You code looks like it needs some ENDIF statements IIRC. Only IF…GOTO can be used without the ENDIF at the end.

edit- Incorrect; omission of ENDIF does not cause a syntax error, my bad.