Help please ( INFRAIN )

ernest

Member
Hello all . I ues picaxe with my Meccano Hobby its a lot of fun.
I am trying to create a programe, to use with infra-red , so that when I
press the transmmiter button the output goes high ,and remains high ,so long as I keep the button pressed, and when I take my finger off, the output goes low. With my code the output remains high. I think I know why it stays high but I dont know how to fix it. A bit of code would be a big help please.
main
infrain
start:
if infra = 1 then high 4
else low 4
endif
goto start
 

gbrusseau

Senior Member
It looks like the GOTO command needs to go back to the beginning of the program to execute a new infrain so the infra data is updated with each loop.

start:
infrain
if infra = 1 then high 4
else low 4
endif
goto start
 

Andrew Cowan

Senior Member
I think you have misunderstood the infrain command. It simply stops the code running until an infrared signal is detected. It then puts the number into the infra variable.

Grusseau - that code will wait for an it signal, and put the output high if the signal is signal 1. It will then wait for another signal, and I the new signal is not 1, it will turn it off. If no new signal is received, or the new signal is code 1, then the output will remain on.

A
 

ernest

Member
It looks like the GOTO command needs to go back to the beginning of the program to execute a new infrain so the infra data is updated with each loop.

start:
infrain
if infra = 1 then high 4
else low 4
endif
goto start
Thanks for your reply,the out put still stays high.
 

ernest

Member
Andrew Thanks for your reply. I do undrstand your explanation, does that mean
I cant get the "manual" infrea-red control I would like, as discribed in my post. Brian
 

Andrew Cowan

Senior Member
Through the infr command - you can't do it.

However, when a 38Khz infrared signal is received, the output of the detector goes low (or high - can't remember).

This means using a digital input, you could make the setup you describe, but it would work with ANY 38Khz modulated infrared signal. Would that be any good?

A
 

gbrusseau

Senior Member
Brian,
I was a bit confused from the start about what you mean by transmitter, but I went ahead and offered a logical code fix anyway. By transmitter, do you mean a typical IR remote control device or some other type of 38khz transmitter, or something even more different. With the code I offered, the only way pin 4 would go high is if the INFRAIN command at least initially detected an IR remote control code of "1" and placed that code of "1" into the variable INFRA. Without knowing what type of IR transmitter you are referring to, I can only speculate.
Without knowing which PICAXE you are using, I can't say for sure, but pin 4 may appear to be high, but is actually a floating input pin and the code is stuck at the INFRAIN command waiting for a valid code from the IR remote control transmitter.
 
Last edited:

JeremyCorkery

New Member
I was trying a similar thing with a break beam idea. The receiver I had was active low and would stay high (not receiving), modulating with the PWMOUT command. As I was sending the carrier signal but not actually sending any data. I ended up using the infraout command from the transmitter just sending 1s (this would make the receiver go low) I haven't finished this, but I think with a bit of programming with logic (not infrain as Andrew mentions, as the program just halts) at the reciever it may work. The reason I'm using the receiver instead of a IR photodiode is because I can get the distance on it. I gather it has a filter and other smarts built in. Hope this helps.
 

hippy

Technical Support
Staff member
What's needed is something like ...

Code:
#Picaxe 08M
Do
  Do
    InfraIn
  Loop Until infra = 1
  High 4
  w0 = 0
  Do
    w0 = w0 + 1 * pin3
  Loop Until w0 > 1000
  Low 4
Loop
Once an IR command is seen the IR line itself ( active low, 0 = IR present ) is monitored until no IR is seen for a certain time. W0 is a timeout which either increments ( pin3=1, no IR ), or is reset to 0 ( pin3=0, IR present ). The timeout value ( 1000 ) will likely need to be changed to get the response desired.
 

ernest

Member
Hi I am using project board CH1035 with 18X IC.
I have simulated your code with O8M.Error infrain not supported this model.
I " " " " " 18X.Error unknown symbol-pin3 W0=Wo=1*pin3
I realy would like to try this code, thanks brian
 

eclectic

Moderator
I'm certainly confused.

From your other thread (post #5):
"Thanks for your reply .I have tryed switching the out put high and low 100ms but
it drops the voltage 12v down to 3v , I have to use a full second to maintain 12v,
which effects the smooth running of the motor. Brian"

Please, can you provide:

1. An outline of what you are trying to achieve.

2. A schematic / circuit diagram.
3. A description of the ALL components connected.

I've included a schematic of the CHI035, as a starter.

e
 

Attachments

BeanieBots

Moderator
The 18X uses infrain, the 08M uses infrain2. (change to suite which chip you are using).
Also, the 18X does not have "pin3" so you will need to change it to whatever input you are using on your 18X.
 

ernest

Member
I'm certainly confused.

From your other thread (post #5):
"Thanks for your reply .I have tried switching the out put high and low 100ms but
it drops the voltage 12v down to 3v , I have to use a full second to maintain 12v,
which effects the smooth running of the motor. Brian"

Please, can you provide:

1. An outline of what you are trying to achieve.

2. A schematic / circuit diagram.
3. A description of the ALL components connected.

I've included a schematic of the CHI035, as a starter.

e
Hi ,I am sorry to have confused things, I am very much the amature using pixaxe,as I have mentioned I use Picaxe with my Meccano models.
I am using CH1035 18X. and RevEd infer-red up grade kit.
An outline of what I am trying to achieve .
I have a 4 axis crane that I would like to operate"manually" with infra-red,
that is when I press a button and hold it a motor runs, when I let go the button the motor stops. I have put the kit together, as page 78 basic
commands and it works fine with the programs on page 79.
I am hoping to find a code todo this" manual" infra-red.
Thanks Brian
 

ernest

Member
18X pin 0 ,Meccano comes to life,Thanks Do
Do
InfraIn
Loop Until infra = 1
High 1
w0 = 0
Do
w0 = w0 + 1 * pin0
Loop Until w0 > 100
Low 1
Loop
 
Top