XBee digimesh, possibly that elusive sleeping router

moxhamj

New Member
Yes, a most interesting thread. This is a real conundrum - there are so many parameters that need to be juggled.

For instance, if you run off solar and batteries, you need to take into account the self discharge rate of batteries, eg NiMh lose about 1% a day, which for a 2400mAH battery is about 1mA. So there isn't much point in trying to get the current much lower than that.

Hope modules use about 20mA. I'm wondering about running at a 1:20 duty cycle eg on for 100ms, off for 2secs. A picaxe would be in charge of that. Another picaxe would listen for a sequence of letters - if no valid sequence then it all goes back to sleep again. This means you could wake up specific nodes.

I'm also pondering data formats. Serial is fine for modules like the Hope, but wherever that serial data goes will hang a picaxe. If a picaxe is listening to a serial signal it will be hanging. If it then sends to another picaxe, that one will be hanging too. How do you do a "fan in" where you listen to several lines at the same time? I'm working on a very simple protocol which could work for wireless and for wired connections. A 'low' is a short high pulse and then a short low pulse. A 'high' is a long high then a long low. If you send a binary 01010101 the receiving unit can work out the length of the high and low pulses using pulsin and then the system is tolerant of different frequencies, different clock rates, and can run at any arbitrary clock rate. It also satisfies the manchester coding principle for wireless where the low and high times are equal.

The other criteria is that the software on a node has to be upgradeable easily, ideally over the network itself. I've now got some CP/M boards working and these do have enough smarts to run a network. So picaxes will handle the lower level stuff like wakeup and sleep and turning on the main board. And CP/M (running compiled basic) can handle upgrades of software and local discovery of nodes and reliability of links.

Three systems could be used for the wireless - raw modules, Hope modules or friendcom. I think the smartest solution is to design a system that can run on all three.

I've also been thinking about a mathematical model to describe a wireless mesh. Think of a wired model. A picaxe with a pin that can be an input or output eg pin2 on an 08M. Ground that pin with 100k. Also, run that pin via a variable resistor 0-1M to a common point. Now build 10 of these and join them all up at that common point. Now inject white noise into that common point via a 10k resistor.

Set two of them with their resistors at 1k. These two nodes are 'near' each other in a wireless sense. When they are transmitting, they definitely move that common point high or low. They easily swamp the noise which is coming in via 10k.

Now let's have a node with 20k into the common point. This node is far away. It's signal is still audibile, but the noise is swamping it.

I think this illustrates two things. Firstly, the point is now how it works when signals are good - but rather how it fails when signals are bad. Signals might be white noise, but worse, they could be partial packets picked up from a node some distance away. Any mesh has to have some sort of filtering - either in the form of a picaxe or the Hope onboard micro. The second point this model illustrates is that only one node can be talking at once. Maybe some nodes won't interfere with others, but it is safest to assume they all interfere with each other. So you need some rules about how to talk. Eg a few bytes to say 'I want to talk'. Everyone else then listens. Then a few more bytes 'I want to talk to x'. All but x go to sleep for a bit, because there is no point being on and wasting power listening to a message that is not for you.

At a higher level, I am thinking about a system which can run various programs (as CP/M can). Eg there are nodes 1, 2 and 3. Node 1 wakes up node 2. Node 1 runs a 'bridge' program on node 2 that routes all messages to node 3. Node 1 talks to node 3. Then node 1 stops the bridge program.

Also you can automatically update software. I use a similar system in some practice management software that runs my surgery. Each program running on 8 computers has a version number. Every few minutes it checks with the server to see if the version number matches. So if you update just the server, it then automatically sends the updated version to all the other computers. Upgrades are thus easy and automatic.

You can do this with CP/M too. But you can't do it with picaxe, so picaxes will have to just do the low level stuff which is unlikely to change.

Another point is that I worry about being locked into proprietory systems. I think this should all be open source. Sure, people can use it in 'for profit' applications, but the system should still be open source.

In the last week, I've got all the jigsaw pieces working. CPM is working. Picaxe to CPM is working. Wireless is working. Picaxe to PC (and hence the internet) is working.

Now it is a matter of building the software with the appropriate network smarts. I don't know how it will look but I know it will evolve and I think it is possible to code it so it can evolve. Eg, at the simplest level, if you can copy a program to a remote node and run it, you can do anything. That program can copy to another remote node. It can copy files back. So the basic two things are just copy and run. And telling nodes to go to sleep.

Then one can write the code to, say, send a message to node 1,4,6,3 in that order, and for all other nodes to go to sleep. 1 wakes up 4. Sends message. 6 knows it is next so it only sleeps a short time. 3 only got garbled data so it will wake up in 2 secs time. Node 2 got the message and knows it is not part of the route so it goes to sleep a long time. Messages goes from 1 to 4. 1 now goes to sleep for a long time. 4 sends to 6. And so on.

I like the DTMF idea. In fact, with the 64k of program space of CPM, one can think of quite complex programs. Eg when a fax machine first turns on it tries increasing the baud rate till the data doesn't go through. It then backs off a bit so it finds the most efficient baud rate for the noise on that particular line. So one could try RS232. If that doesn't work, fall back to the dual frequency system described above. And if that doesn't work, fall back to DTMF. A lot of this could be software coded too, though I'm not so sure about a DTMF receiver in software. DTMF chips are still out there though - I got some quite recently (albeit in surface mount). But both picaxe and CPM can do serial, and tones and variable pulse widths etc. Maybe even some rudimentary DSP (I had a FFT running in compiled C on a CPM computer once).
 
Last edited:

ciseco

Senior Member
Drac,

You've made mention of serin hanging many times, have you tried an x part instead? Reason being I don't get this issue as I read the flag indicating a byte was recieved, wait 50ms allowing for the rest to pile in and then read from the scratchpad. Can be done circularly or by interupt, depends what is more appropriate for what it's doing inbetween time and if you want it to finish cleanly before reading what was sent.

Are you preposing CPM powered nodes? what's the power consumption and price?

Miles
________
CD250U
 
Last edited:

moxhamj

New Member
No I haven't tried the 28X. Price here in Australia is $22 which is roughly the same as the price for all the chips for a CPM computer. But the pic16 series are still greatly limited with the amount of ram space, which means no strings. The pic18 series, on the other hand, with their various compilers, do look very attractive. I hope picaxe can do something with those.

Serin checking a flag is the logical way to go. It is actually how raw uarts like the 16C550 work.

I have my 18X nodes working out in the field for the last month, and they are working. However, they need a solar panel worth $100 and a big SLA and an antenna that takes the best part of a day to assemble, and a radio Tx that is difficult to work with (needing a shielded box with ferrites going in etc). I'd like to do something with the Hope modules as they are a lot easier to work with. No big antenna to build for instance.

I'm still searching for the perfect chip to drive all this.
 

moxhamj

New Member
I've put together some boards and am doing some experiments. The current design is a z80/picaxe hybrid and various components are starting to come together. There may be scope for adding in the Propeller as well.

One thing that is very nice about CPM is you have a simple operating system. So you can start the board, run an autorun program, run batch files and run programs. Those programs can talk to other nearby boards and exchange files. They can download a new version of the program, then rewrite the batch file and restart the board, and hence upgrade the software via wireless. The software itself is just a BASIC program, not unlike picaxe basic, but the ability to change this software via the network is very useful because you don't have to physically go around to each of the nodes.

I wonder, as a general question, what is the simplest microcontroller design that can download, upgrade and run its own software?
 

hippy

Ex-Staff (retired)
I wonder, as a general question, what is the simplest microcontroller design that can download, upgrade and run its own software?
That would be the Propeller. Entirely capable of updating all or part of its own program and operating system while other cores continues to execute previous programs at full speed and without interruption.
 

moxhamj

New Member
I'd better go back and look at that chip. Thanks Hippy.

(Though I am almost finished with a hybrid Z80/Picaxe design, and at least that design does use the Picaxe - a couple in fact).
 

oymyakon

New Member
Xbee

hi guys, I see you have spent a lot of time and effort on the Xbee, so i am looking for a few pointers. I am trying to develop a system where the multi nodes are battery powered and a permanent powered "grandad".
With the cyclic sleep mode how does the picaxe know when to send the data?
Does the sleep co-ordinate itself with the grandad?
What happens if all of the picaxes send data at the same time?

Sorry for all the possibly basic questions but i am just trying to get my head round the sleep aspect.

Cheers
 

moxhamj

New Member
Excactly the same problems we are working on. No definitive solutions as yet. Had to build a computer from scratch just to test this, but that part is working. Experimenting with different languages - assembly, mbasic, sbasic (the latter looks promising). The rules determining radio comms are not simple - for starters only two devices can be talking at the same time and if more than one are talking how do you tell the others to be quiet reliably when everyone is talking? Even the "be quiet" signal will be swamped. And you need ways of dealing with nodes that are out of range - eg a "be quiet" signal needs to propogate through all nodes to ones that are out of range. Then once everyone is quiet you need to wake up just one and tell it what to do, establish data comms etc. "Wake on signal" seems elusive, "Listen all the time" uses power (3mA for a picaxe stuck in a serin), so the other option is to have a real time clock somewhere and periodically synchronise everyone's clocks so that when they do wake up at a certain time, then they all wake up roughly at the same time. Something like grandad saying to all the little picaxes "go to sleep for 5 mins" and they do that and then 5 mins later they all wake up and the first thing grandad is saying is "I only want to talk to picaxe x" so all the others just sit and listen.


Or just throw power at the problem and accept that you need a bigger solar panel. One thing I did get working last night was a simple switcher reg, so you can pump 18V in and get 5V out and get almost 18/5 times the milliamps. So a 3mA picaxe is only drawing 1mA at 18V.
 

ciseco

Senior Member
oymyakon

Your description of grandad is a good one, that is essentially how I do things. I'd call it a co-ordinator but grandad makes me smile, sounds friendly and warm :)

Wow, it's been a while since I've been here.

There are in my mind two distinct approaches, Drac favours the peer to peer democratic way where every device has to be sufficently intellegent to decide how to act, route, sleep etc. I however find master and slave a preferable route for many reasons.

"Something like grandad saying to all the little picaxes "go to sleep for 5 mins" and they do that and then 5 mins later they all wake up and the first thing grandad is saying is "I only want to talk to picaxe x" so all the others just sit and listen."

Yep, that's whats easy, the other could be to pass to all devices "I'm going to sleep for x" them all know I am and know when I wake and queue messages until, this becomes scary, every device has to be aware of every one of it's siblings at any point and be able to wake, drag that info off the nearest awake node before continuing. A bit like dynamic DNS crossed with dynamic routing and message queing. Is entirely possible, you'd probably need ARM level horsepower and certainly very high bandwidth (wireless USB perhaps) but then you are so far up the spectrum don't expect ranges in more than feet, everywhere has it's limitations :(

For me I was always looking at larger networks than I think most of the guys here would want, 10'000's devices (which is why autonomous behavior is out except for limited numbers of nodes as Drac has found), routing and sync'ing gets to be a huge issue very very quickly. This is why grandad has greater scale and ease, you only need one master, you can have endless slaves and are only ever restricted by bandwidth. For instance we have just finished the design for IP gateways that are like relay points for messages, the last 10's to 100's of feet are only wireless using XBEE (not zigbee, pure 15.4 mode to allow for cross compatibility). These gateways are backhauled via IP on cable/wireless/vpn whatever (why reinvent the wheel), all connected back to a single "host" application. This controls each and every device, telling it when to read/write, ping/pong, sleep and when to reawaken etc. Are there limitations, sure, but wireless is wireless that's usually the hurdle whatever approach is deployed.

What happens if more than 1 send at a time? the same as with any broadcast, corruption and ultimate data/packet failure, you need to factor in backoff periods and retries. Reading how Ethernet does it is a good place to start and when collisions avalanch, bandwith speed and proper routing is your only real panacea here (and I'm not talking about routing via wireless unless it's on different frequencies, think of hubs vs routers, the segments are physically different)

Going for battery power usually takes deep thought, sometimes what you want to do just isnt feasible within the size or energy budget, the XBee loves power (we are testing much lower power 15.4 devices too and may replace the XBee's). To show what's possible, I have recently had a design for a light switch done by Dippy that consumes so little, it should last 6 years on a single CR123 cell being used 20 times a day, it never fully powers off just sleeps really deeply(not using the onboard sleep features of the XBee)

You could look at the digimesh protocol which supports cyclic sleeping, I don't like it personally, the demand to have every node wake and sleep every cycle is too resitrictive for a generic network, if however you can bear this issue, it might suit your needs.

What is it you want to do?

Miles
________
Honda Z50J picture
 
Last edited:

manuka

Senior Member
Check the recent FC-711 Master/Slave mention in the "HopeRF" topic- they're claiming ~8 years from the likes of alkaline AAs (in other words ~shelf life)!

N.B. Aside from anything else, 433 MHz UHF will have much better punch thru' obstacles & vegetation than 2.4GHz microwaves. Even your moisture filled body may obstruct weak 2.4GHz ZigBee signals,yet LOS these may go for several km. Yeah OK- Xmas/NY celebrations may have left some of us with rather less internal moisture than normal.
 
Last edited:

ciseco

Senior Member
Hi, manuka

I just read the PDF you pointed to, 8 years on 2500ma, as opposed to dippy's 6 years on 1350ma, in simple maths thats nearly 16 years on XBee, neither figure mean much in isolation. You need to compare apples with apples.

All this fixation with frequency 'n punch is quite academic unless for simple point to point estimation, the whole premise of operation of the whole network is where your energy should lie, the distance between two back to back has little to do with having 10's or 100's of them all competing to exist. Seems the master/slave vision of the world finally gets a hearing, shame it took a datasheet to dawn?

What security do you envisage having in place? I suspect nothing, would that be right?

What does a 433 approach have over 15.4, to my mind only cost, well I say that, it was the only original point that stood, but when XBee's are $19USD + dealer margin and you are now talking about 433 modules that approach $40USD that doesnt stand either. There are chipsets for sub $3USD already here too.

May I draw your attention to the "drop in" 868/900Mhz 15.4 kit that will do 10's of KM, complete with all the encryption etc you get on 2.4Ghz, before you scream foul, I know they are expensive.

Where is the balance of facts?


Rant over :)

Miles
________
Chrysler TC by Maserati specifications
 
Last edited:

ciseco

Senior Member
I need to get out of the endless Xbee vs 433 argument, I need to stress IF there was similarly capable devices (fast data rate, secure, easy to use etc) at 433 we would agree I'm sure.

What I keep trying to say is that I don't think the kit is the issue it's what's hoped to be achieved using it that I think isn't realistic. You, drac and others have an obvious aptitude to come up with great things but I dont see a grand plan here that is feasible.

I find it frustrating that such talent is (in my opinion) going to waste on something I suspect will fade away over time.

Miles
________
Dodge Caravan picture
 
Last edited:
Top