Help please.Inrafra-red Picaxe20x

ernest

Member
Hello all
I first posted this request for help 01-10-2009.for PICAXE 18X (infrain).

Quote "I am trying to create a programe, to use with infra-red , so that when I press the transmmiter(TV remote) button the output goes high ,and remains high ,so long as I keep the button pressed, and when I take my finger off, the button the output goes low. A bit of code would be a big help,thanks."Unquote.

Hippy Kindly posted this code in reply ,its great I use it with 18X .
I would like to use similar code with Picaxe20X2.
I have played with the info on page2--121 irin (help! )
A bit of code for 20x2 would be much appreciated.
------------------------
To replace an infrain / infrain2 command with irin use these two lines:
symbol infra = b13 ; define an infra variable
irin C.0, infra ; read input C.0 into infra
-------------------------
-------------------------

'Picaxe 18X
'Infrared Latched
'Once an IR command is seen the IR line itsself(active low, 0= IR present) is
'monitored untill no IR is seen for a certain time.
'W0 is a timeout which either increments(pin0=1, no IR),or is reset to 0
'(pin0=0,IR present).
'The timedout value (1000) will likely need tobe changed to get the responce desired.

Do
Do
infrain
Loop Until infra=1
High 2
w0=0
Do
w0=w0+1 * pin0 '* Multiply or (returns low word of result)
Loop Until w0>30
Low 2
Loop

Thanks Ernie
 

Jamster

Senior Member
Please can you use the code tags to display code and the quote tags to display quotes

also can you post a link to the old thread
 

hippy

Technical Support
Staff member
The code for the 20X2 should be almost the same with a few changes ...

1) INFRAIN changes to IRIN, which needs a pin number of the IR receiver, and a variable to put the received value in.

2) Use of the INFRA variable changes to match the vriable used in (1).

3) Use of PIN0, which is what the pin number of the receiver was, needs changing to match that used in (1).

So, IR receiver on pin C.0, something like -

Code:
#Picaxe 20X2
Do
  Do
    IrIn C.0, b2
  Loop Until b2 = 1
  High B.2
  w0 = 0
  Do
    w0 = w0 + 1 * pinC.0
  Loop Until w0 > 30
  Low B.2
Loop
 

ernest

Member
Infrared "manual" control of motors PICAXE20x2

Hi Hippy Thanks for your reply, and the code , what I would also like tobe able to do is to activate, each output from its respective button on the
TV remote. I can change (for example) the code to high b5 and 5 goes high
but only when I press button 2. I have the infrared receiver connected to
input O. I would much appreciate your help please.
Thanks Ernie
 

billhayley

New Member
hi ernest
we have discussed this issue before,I had the same problem when moving onto the 20m chip and hippy gave me this code:

Code:
Do
Do
InfraIn2
Loop Until infra = 1
High 4
w0 = 0
Do
w0 = w0 + 1;;;this line differs depending on the chip
w0 = pin0 * w0;;;;and this one
Loop Until w0 > 30
Low 4
Loop
What I am not sure now is wether this is the correct code for the 20x2. As I have been having dificulties with my joystick project ( see previous posting).I tried the new code in the Puma but it made no diffrence. The joystick works with the Sarcen which has a 28x1 chip in it.
bill
 

hippy

Technical Support
Staff member
One solution would be ...

Code:
#Picaxe 20X2
Do
  IrIn C.0, b2
  Select Case b2
    Case 2 : High B.5 : Gosub WaitForRelease : Low B.5
  End Select
Loop

WaitForRelease:
  w0 = 0
  Do
    w0 = w0 + 1 * pinC.0
  Loop Until w0 > 30
  Return
You can add as many CASE options as you need to handle particular IR key presses.
 

ernest

Member
Infrared "manual" control of motors PICAXE20x2

Hippy big- thanks for your help. I now have all 8 outputs working from
my TV remote buttons, with output held until button is released. Magic!
Ernie
 

ernest

Member
Hi I will use tags in future. Could you give me an example of how I post a link to an
old thread please. Ernie
 

hippy

Technical Support
Staff member
Normally just pasting the address (URL) of the thread into your message will automatically turn that into a link when viewed, and adding [url]...[/url] tags around it will ensure that.
 

Tumbledown

New Member
I have been reading a lot of posts to get going on these chips but I finally have to ask a question.
Will the code above work on the 18M2 chip?
 
Last edited:

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

Most code should work on the 18M2 but there may be some alterations required depending on what the code was originally written for. It also depends if the original code uses any commands which the 18M2 doesn't support.

The IR code above should work just by changing the #PICAXE line.
 

ernest

Member
I have been reading a lot of posts to get going on these chips but I finally have to ask a question.
Will the code above work on the 18M2 chip?
Hi Tumbledown
Sorry I don`t know if they will work on 18m.
The code I received form Hippy for Infrared with Picaxe20x2 certainly work.
If your into Infrared control with Picaxe 20x2 I could send you some code.

Ernie
 

Tumbledown

New Member
I can't give you the code I'm using but when I use the Logicator, I don't get the irin or infrain put into the basic code.
I'm assuming the Logicator has not been updated for the 18M2 chip.
I have to manually type in an IRIN line in the code.
I assume (maybe a false assumption) the Logicator will be updated for the 18m2 chip.
Sorry if this has been talked about before but I couldn't find it in search.
I didn't mean to sidetrack the thread.
 

hippy

Technical Support
Staff member
@ Tumbledown : The missing IRIN / INFRAIN is something we will investigate and correct. Logicator was updated to support 18M2 but this seems to have been an oversight on our part and wasn't caught during testing. I'm not sure I have the latest Logicator installed so will have to check to see if we have already spotted the mistake and corrected it.

I don't recall it having been mentioned before so thanks for the information. We do have a specific forum for Logicator whre it's arguably better to post issues such as this one so other Logicator users will more likely see them but we do monitor all forums so we are now aware of the issue.

http://www.picaxeforum.co.uk/forumdisplay.php?f=41
 
Top