IR receiver connected to 2 picaxe

ashawthing

New Member
I'm a bit of a beginner in the very early stages of planning a project, just wondered if I would have any issues connecting 1 IR receiver to the input of 2 seperate PICAXE ic's?

Thanks
 

techElder

Well-known member
Shouldn't be a problem if you aren't planning on the IR receiver being at some distance from the PICAXEs.

Please, experiment with that setup. Then report back to us here.
 

ashawthing

New Member
Also, is it possible to have the IR input as an interupt? So the program will be running but if there is an IR input it will stop what it's doing and call up a sub-procedure

I am trying to control all aspects of a reef aquarium. At the moment I am concentrating on lighting. I have a program that turns the lights on/off (gradually over the period of an hour using pwmout), but I would like to add a manual overide from an IR input???
 

techElder

Well-known member
It sounds like you are creating a central control, so why are you asking about multiple PICAXEs?

Choose the right PICAXE, and you have your central control.

You might find some advantage to have an "IR PICAXE" for the IR processing. Then send along commands from that to other PICAXES via I2C serial.

However, I can't see why you would need more than one PICAXE for your project.

Also, I can't see why you need INTERRUPT processing, either.

Except, maybe you just want to play around with the process? :)
 

ashawthing

New Member
Right, I guess I'm not tackling this problem the right way then. I'll put some more thought into it and come up with a better method
 

techElder

Well-known member
I always suggest that the solution to most designs is to go out to the periphery and decide what "small" actions need to be done. Then figure out how to read, activate and control those small things.

For example,
  • "adjust the lighting up at 1 second intervals"
  • "change the lighting color at random intervals and to random colors"
  • "read the temperature on demand"
  • "turn the air bubbler on/off"

From that you know,
"I need a PWM output"
"I need 3 PWM outputs"
"I need a thermistor/other temp measuring gadget"
"I need a bunch of AC switching circuits"

etc.

Then you can see that you need a PICAXE with 14 pins or 18 pins or 40 pins to accomplish those tasks.

Take a deep breath.

Work to get ONLY ONE of those parts of your design working. (You've started that with the lighting control.)

THEN and ONLY THEN, work on the next one. The next one will be much easier to implement.

You may have to "rethink" your design several times, but in the end (it NEVER ends) you will be glad you did it this way.
 

ashawthing

New Member
I appreciate the advice. My limited knowledge is getting me stuck, I can't see how I can gradually reduce/increase the lighting without having a huge list of IF/ELSEIF statements adjusting the light levels to match the time. I thought of triggering a "sunset" sub-procedure that would gradually reduce the light with a for loop, but that would stop anything else from going on while that is happening (I think???).

Could do with a point in the right direction, I'm reading about table and lookup commands at the moment but I think I could be barking up the wrong tree with that
 

ashawthing

New Member
Also, I think I am just going to go with one of the largest picaxe's to start with as that will give me the option to expand if I come up with any new ideas while I'm making it. Once it's done I can always streamline it if I feel like it :)
 

techElder

Well-known member
I don't know what "gradually" means to you. Think of your lighting change in percentages.

Your light level is going to change from 0% to 100% in how much time?

More practically, you will find that you will start seeing your light at some percentage, so that's where you start. There also might not be much change in light level at some percentage before 100%.

So, you need a routine that you can call with a parameter for the lower (or start changing) percentage and and a parameter for the upper (or stop changing) percentage.

If you are using PWM to make those changes, then you just call this routine periodically depending on how much time you have.

Think of your whole program as on big loop.

DO

Within that loop, you have to perform all of the tasks/actions in your prepared list of actions.​

GOSUB DoAction

Then you start back over at the top of the loop.​

LOOP


Subroutines are all together but separate tasks/actions

DoAction:

Do something here that is a little part of the total​
It could be a small increase in the lighting intensity​

RETURN
 

edmunds

Senior Member
The one useful thing to remember about IR receivers (at least the types I have been working with and certainly the one form picaxe store), is that the data pin goes low on receive. So, if you have your "loop of everything" as @Texasclodhopper is suggesting, the only thing you have to do is to check the IR pin every loop to see if there is something to receive. If yes, you go in and pick it up and do something about it. If not, you lost very little time checking if the a pin is high or low.


Edmunds
 

Hemi345

Senior Member
The one useful thing to remember about IR receivers (at least the types I have been working with and certainly the one form picaxe store), is that the data pin goes low on receive. So, if you have your "loop of everything" as @Texasclodhopper is suggesting, the only thing you have to do is to check the IR pin every loop to see if there is something to receive. If yes, you go in and pick it up and do something about it. If not, you lost very little time checking if the a pin is high or low.


Edmunds
I had tried that briefly and it wasn't reliable enough unless the button on the remote sending the data the IR receiver was held down so the PICAXE could "catch it" instead of a quick press. The PICAXE couldn't really be doing anything else except moinitoring the IR pin. I ended up using the SRlatch commands with a logic gate configured in invert mode to convert the low signal from the IR receiver to a high on the SRI pin. This allows the PICAXE to do other work and periodically check if SRQ has gone high. The first button press on the IR remote is sort of a wake up call to the PICAXE to pay attention for IR commands.
 
Top