Picaxe 18M2 question

pwaggie

New Member
Hi, I am a relative newcomer to Picaxe (around 3 months), I have not done any electronics for about 25 years until recently and then discovered Picaxe, wow never had anything like this 25 years ago!.

I have now completed several Picaxe projects based on the 20M but I now want to try the new 18M2 in my latest project, and have a question.

I would like the controller to monitor a wireless receiver via the Serin command and then initiate either of two timing programs independently whilst still monitoring the Serin command, can it do this. The timers would be for around 5 mins each and it could be either or both timers, but could it still monitor the receiver during the period it is timing, I know the controller can run up to 4 programs at the same time but am unsure about this.
I was going to use two 555 timers but wanted to keep the component count and battery power to the bare minimum, and thought the 18M2 might be able to do this.

Peter
 

BeanieBots

Moderator
Welcome to the forum.

The 14M2 will NOT be able to do that.
Once it enters the serin command, all other processing (of all tasks) stops until it exits. It will not exit until something has been received.

To do what you want, either use a couple of smaller PICAXEs (eg 08M) to handle the serin independantly or use one of the PICAXEs which supports background serial recieve. (eg 28X2).
 

pwaggie

New Member
Many thanks for your reply, I was afraid that might be the case, you have saved me a few hours breadboarding a circuit for nothing. I had thought of using 08m's but thought just maybe a 18M2 would do it and I already have a couple. I would probably have to use three 08m's I think as one would be needed to monitor the serin command and I think if running two timing circuits I would need one for each would I ?
 

hippy

Ex-Staff (retired)
You'll likely only need one master PICAXE and one slave PICAXE ( monitoring RF module input ) as the master won't have to wait on SERIN but can just poll the slave to see if anything is available or not.
 

pwaggie

New Member
Thanks for the reply hippy, can the 08m run two timers at the same time then ? if so how can I do this. I'm still feeling my way into the complexities of Picaxe :)
 

BeanieBots

Moderator
You can run many timers with a 08M.
Simply set up a loop that keeps repeating. (say every second)
Within that loop you increment a variable (counter) only if a certain condition exists. (timer 1)
Increment a second variable on a different condition etc. etc. (timer 2 .....)
Also within the same loop, check to see if any those variables have "timed out".
 

pwaggie

New Member
Ha, now I understand, increment a variable rather than say "wait 300" thanks very much for your help, I am still quite new to microcontrolers. Up to now I have prefered to lurk in the background and learn through trial and error rather than ask too many questions, but you help has saved a lot of time and pointed me in the right direction, many thanks,
 

knight

Member
Contary to what the others have said, the 18M2 might be able to do it.

The 18M2 does have a limited background serial recieve capabilities (one byte to be exact), this means that if what you were expecting to recieve from the wireless reciever would only be 1 byte long, you could set up your 18M2 to do background serial recieve, then during your timing loop above check the serial recieved flag, if true act on it.
 

hippy

Ex-Staff (retired)
The problem is that for RF receive, even if only a single byte payload, the serial input will receive numerous bytes of noise. You can't just take any byte which arrives and assume it is valid data.
 

pwaggie

New Member
I think that using a 18M2 to do the lot might be beyond my capabilities at the moment, but if I used an 08M to monitor the receiver would it be easier to implent two timers with a 18M2 as it can run 4 programs at the same time (and I already have some) rather than try runing two timers with a 08M.

Basicaly one timer will switch on a CCTV camera in the stable for 5 mins and the other will turn on the stable lights for 5 mins so my wife can see to get to the stable in the dead of winter. If I don't put them on a timer they will probably be left on for hours.
 

hippy

Ex-Staff (retired)
It probably is easier to use the 18M2, take advantage of the multi-tasking. Each task can use PAUSE or WAIT to implement its delay without having to worry about how that would impact on the other tasks.

As you already have some 18M2's that would seem the best approach to take. You can also use an 18M2 to monitor the RF receiver, no need to have to use an 08M.
 

pwaggie

New Member
Thanks very much hippy, I had come to that conclusion but it is always nice to have it confirmed by an expert. I would much rather sit and experiment with a Picaxe but I am told there is much work to do outside. :(
 
Top