Which method PICAXE to PICAXE communications?

CudaBlu

New Member
I have done a lot of research on this Forum and the PICAXE manuals and am now at a total lose as to which way to go for communications in an application I am working on. Here is the overall view of what I am trying to accomplish or believe I need to accomplish:

- Overall project is for greenhouse/aquaponics control
- One 08m2 to simply read (via i2c) the time (right now hour only) from a DS1307 module
- Above 08m2 used as a Master to send the hour to each of 4 to 8 other PICAXE Slaves that control lighting, pumps, solenoid valves, etc.
- Each Slave (some 08m2, some14m2) receive the hour from the Master to use in their timer code
- I am using multi-tasking on the Slaves at present:
Start0: being the Slaves main program, with subroutines
Start1: reading in the hour from the Master

I have read here about serial communications in the PICAXE Manual 3 (page 43) using RS232(MAX232).

On the Forum here (entry #9) about RS485 and (entry #6) about serout/serin.

On the Forum here (entry #8) about using serout/In, pwmout, and servo.

Questions:
1) Which method would be best for this application and a newbie’s level of expertise?
2) What are the pros and cons that I need to look out for if using one method over another?
3) I have more of a software background, how would the communications part be wired up?

There is a good amount of info on here for this subject so I appologize ahead of time if I am beating a dead horse, just need a little extra help to get me moving in the right direction.

Thanks to all for checking this out!
 

Goeytex

Senior Member
The type of communication depends upon the distance between the devices. What is the maximum distance ?

If it were me, I would consider Wireless RF instead of hard wired if the distances are substantial.
If only a few feet then standard serial should be ok. RS485 is good for long wired runs.
 

lbenson

Senior Member
If the distances are short enough, wired may avoid complications.

You don't need to use multitasking to read the hour--you can just set up the 08M2 for background receive (hserin) on pin b.1. The M2 devices have input buffers only 2 bytes deep, but you only need one byte to send 0-23 as a binary number.

Code:
hsersetup b2400_4,%01000 ' hserout pin normal, T, 

main:
  do
    hour = $FF ' non-valid hour
    hserin hour ' on b.1 if no bytes ready, no change
    if hour >= 0 and hour <= 23 then
'  you have a new hour: do what you want
    endif
'  the rest of your code
  loop
Note that hersin won't work with wireless, because there is too much noise, giving input when there has been no output from your master.

(This instance uses "True" logic (idle high) on the serial, because I drew it from a use on a device which idles high--if you are running on batteries, you will want to use "Inverted" logic--idle low.)
 
Last edited:

Buzby

Senior Member
Hi CudaBlu,

By far the easiest method is wireless.
There are plenty wireless modules, and a huge amount of stuff in this forum to show you how to use just about any of them.

The only downside I can think of is that some of your devices might be in metal boxes, even a metal framed greenhouse might affect the signal.
Wireless modules are cheap, and so are PICAXEs, so why not build a trial unit to test in various places ?.

Cheers,

Buzby
 

CudaBlu

New Member
@Goeytex

Right now I am building a very scaled-down version of what will one day be a large greenhouse. The present area is only 4ft x 8ft. The eventual greenhouse may be 30ft x 60ft.


@lbenson

Thanks for the pointer to hserin, I will check that out.


@Buzby

Will wireless increase the cost quite a bit? I am looking at up to 8 modules that only need to receive the time, would it be cheaper to just hook a DS1307 to each module?


Thanks to all for the input!
 

Goeytex

Senior Member
Note that hersin won't work with wireless, because there is too much noise, giving input when there has been no output from your master.
That may be true with cheap $2 ASK RF modules, but not with better smart modules that incorporate packet handling. Even the cheap modules can be used with the addition of the NKM2401 encoder / decoder.

@Cuda

You should develop your system based upon the final spec of 30ft x 60 ft and not upon the present area of 4 x 8 Feet.
A DS1307 on each module is probably the easiest way to go. However having a Master Module makes changes easier.

If your main specification is "cheap" then your options become limited. For cheap wireless, an ASK module with an NKM2401 encoder / decoder
will suffice and probably cost < $5 per node.

Better RF modules cost around 10$ - 15$ each. It is probably cheaper to just add a Clock chip to each module.
 
Last edited:

lbenson

Senior Member
If you have pins available, DS1307 modules will probably be cheaper, e.g., for $2.25US:

http://www.ebay.ca/itm/1PCS-I2C-RTC-AT24C32-DS1307-Real-Time-Clock-Module-for-arduino-AVR-PIC-51-ARM-/370778352677?pt=LH_DefaultDomain_0&hash=item56541cac25

If you need more pins, I'd just use the 14M2.

Goeytex has some very good tutorials, but wireless can be a pain.

One advantage to having communications available is that you can code more generally, and your master can send on/off requests as desired. With a self-contained unit, you have to reprogram to make any change.
 

lbenson

Senior Member
That may be true with cheap $2 ASK RF modules, but not with better smart modules that incorporate packet handling. Even the cheap modules can be used with the addition of the NKM2401 encoder / decoder.
But with a packet, you're usually dealing with more than 2 bytes, so hersin won't do it without more complicated code on an M2 device. You also may need more control lines than an 08M2 has available (at least with modules I'm familiar with).
 

Buzby

Senior Member
RFIN and RFOUT

Two very good PICAXE instructions to turn your cheapo wireless modules into reasonably decent devices.

Regarding cost, add up the cost of all the non-PICAXE parts, including those expensive fish, and see what little difference a few $15 wireless modules makes.

Edit : Or spend a little more for the PICAXE wireless stuff, which lets you program the PICAXE over the air.
 

hippy

Ex-Staff (retired)
My choice would be to keep it simple and go for hard-wired cable. It's probably the most flexible option, cheaper than RF modules, more reliable, easier to design and debug, and can easily provide a free talk-back channel and/or handshaking.

With cheap alarm cable you can have remote code programming, time and other data setting. In fact you can make the slaves almost completely dumb; only obeying commands from the master.

I'd probably go for 20M2's over 08M2's for slaves as the cost is only a little more and offers extra capabilities for the future. HSERIN isn't really needed, interrupts, SERIN and SEROUT would do the job.

Master with slave systems are much easier to deal with if they can have a send and acknowledge protocol and cable's the easiest for that as there should be least chance of lost data.
 

Buzby

Senior Member
Hi hippy,

I fully agree that wired is more reliable, and easier from the software point, but CudaBlu says he is more comfortable with SW than HW.

To build a reliable wired system he's going to need line drivers and receivers of some sort, my choice would be RS485 ICs.

His greenhouse is going to expand like a balloon, does that mean re-cabling every time it gets a bit bigger ?

There's always more than one way to skin a cat, but more some are more gory than others.

And I assume, but I might be wrong, that the fishes in this aquaworld will be worth more than the control system keeping them alive.

If that's the case, then the No. 1 priority is reliability, not cost.

So, CudaBlu, whatever method you decide on, there is support for it on this forum - the best you'll ever find !.

Cheers,

Buzby
 

boriz

Senior Member
Just to be different...

How about optical?

If your data is just simple time codes, the built in IR commands should be just fine. Cheap too. You could always use fiber optics if your links are not line-of-sight.
 

Buzby

Senior Member
IR struggles in bright sunlight, and there might be a lot of that in a greenhouse.

Fibre optic cables ?. Good idea, but the interface between the FO cable and the optical TX/RX devices needs to be reliable. Again we are into hardware design.

And you still need to re-cable if the layout changes.
 

CudaBlu

New Member
Well, I guess I still have alot to think about. I started looking into the IR option last night when I came across a link on the Forum to an Infra-Red Tutorial that Westaust55 put up. I like the ideas of scalable and cheap. With a little more weight going to the scalable side, so the IR option is appealing to me.

If I were to use the hard-wired option could someone give me an idea of how that would physically look? How do you wire from one Master to multiple Slaves. I'm sure it is not as commplicated as I am making it out to be in my mind.

Thanks once again for all the help everyone.
 

hippy

Ex-Staff (retired)
If I were to use the hard-wired option could someone give me an idea of how that would physically look? How do you wire from one Master to multiple Slaves. I'm sure it is not as commplicated as I am making it out to be in my mind.
Wires from one master output pin to all slave input pins, also connect master 0V to all slaves' 0V. As simple as that.

For extra robustness one can add current limiting resistors on the slave input pins and that would be recommended.
 

lbenson

Senior Member
The circuit by hippy that you reference is good, but also consider the suggestion by inglewoodpete in the last post of that thread about needing only one 10K pulldown. IP may have more experience in tying together large numbers of picaxes than all of the rest of us put together.

Two wires is your minimum--signal and ground. You might consider adding another and powering your remote picaxes from the central location.

Also check out this, if you haven't already--: kranenborg's "SerialPower" true two-wire data+power network

http://www.picaxeforum.co.uk/showthread.php?7694
 

hippy

Ex-Staff (retired)
Is this still valid also?
Yes, but that's mainly for a master to single slave setup. With multiple slaves, each slave will see what the master and the slaves send. Code can be designed for that but it's easier to use a separate talk-back wire. That can also be multi-drop, so master to all-slaves down one wire, all-slaves to master up one wire, and make sure only one slave talks at a time. The multi-drop wire(s) can be star, daisy-chain, or bus or a mix.
 

AllyCat

Senior Member
so the IR option is appealing to me.
Hi,

As mentioned above, bear in mind that one of the requirements of any "wireless" system is a "local" power supply (and of course nearly always "line of sight" for IR communications). For a greenhouse, the choice appears to be between battery and solar or a mains supply/regulator. The first two imply attention to a Very Low Power design, so IMHO "wired" is the obvious choice. "Data over mains (line)" is a possibility, but raises major safety issues so not really reccommended.

Cheers, Alan.
 

Buzby

Senior Member
... one of the requirements of any "wireless" system is a "local" power supply ...
The Slave devices are controlling pumps, motors, solenoids ( see post #1 ), so I don't think there will be a lack of power in their vicinity.

'Data over mains' would probably be suitable, but as you say, this is definitely not for a home made solution.

Look at X10 modules for control over mains. They are expensive, but safe !.

Cheers,

Buzby
 

Goeytex

Senior Member
The first two imply attention to a Very Low Power design, so IMHO "wired" is the obvious choice.
Obvious Choice? I don't think so, at least not for the reason suggested.

How much battery drain do you think there will be with a Picaxe and RF unit sleeping for 99.9 percent of the time while coming on for less than a second each hour to receive a few bytes of data ? Since a low power design is easy with the Picaxe and even cheap rf stuff, I fail to see the logic in your conclusion. You conclusion assumes that having to pay "attention to a Very Low Power design" somehow rules out wireless over wired. It's not that hard, just a few lines of Picaxe Basic. I have had an RF link up & running for months operating on 3 AAA cells and it receives a data packet once every 60 seconds.

Wired is certainly a good way to go, but not for the reason suggested.
 
Last edited:

pleitch

New Member
@Goeytex

Will wireless increase the cost quite a bit? I am looking at up to 8 modules that only need to receive the time, would it be cheaper to just hook a DS1307 to each module?
Hi. I'm starting a project doing something similar, water level and light control across multiple pots, but not in a greenhouse environment.

I'll be doing something a little similar in terms of measurement and control.

I've got 5 separate pots that have different types of carnivorous plants, each with their own environmental requirements. Some need very waterlogged conditions, some need periodically waterlogged, some need VERY cool water year round and some need very humid conditions.

I'm also planning on a master controller (probably a much larger chip), and 5 slave picaxes. I'm building it in stages and eventually plan to have integrated solar and battery to cut down on cost.

However - I was faced with many of the same questions you'll have and I have already investigated some communication options. I looked into direct connection (serial, i2c), IR and wireless.

I chose 433mHz wireless devices - the receiver and transmitter are the same as the PicAxe shop, but I got them from ebay for about $1.25 to $1.50 AUD. I found that the transmission distance was about 20 metres. But it has a spot where you can solder in an antenna. I used a solid core wire from an old network cable cut to a distance I calculated on an internet site (do a google search for antenna length calculations). Once that was done on receiver and transmitter I was able to travel at least 100m and still had a strong signal through concrete walls (i.e. not line of sight). I didn't bother taking it any further but I'm sure it could have gone further. I was really impressed by that.

To ensure good communication I used 2 x NKM2401 Radio Encoder/Decoder available from the PicAxe store. I'm planning on using ID values from waterproof DS18B20 temperature modules to differentiate the slave units during communications.
 

jerome06060

New Member
other way...

you talk about drive pumps, or other... so, you have hard wire connections for power in place.
To keep the modularity on and also have very long distance, and have low cost for this kind of communication between picaxe, you can also use the power wire cables way to comunicate with.

like that, no other cables, and no more wireless short life way.
 
Top