Interesting Wireless Picaxe Control

UmBongo

Member
Just getting back in to the world of Picaxe and saw this interesting article that talks about building networkable wireless devices with an 18M2.

http://openmicros.org/index.php/articles/85-llap-lightweight-local-automation-protocol/155-llap-18m2-really-basic-turn-on-an-led-and-reply-to-hello


Would it be easy to adapt this example to wirelessly switch 240v mains via a relay instead of an LED?


My electronics knowledge isn't brilliant so I thought to ask more experienced forum members. I was thinking of wirelessly controlling a 240v desk lamp.
 

hippy

Technical Support
Staff member
Would it be easy to adapt this example to wirelessly switch 240v mains via a relay instead of an LED?
PICAXE Manual 3 "Interfacing circuits" shows how to switch a relay rather than a LED so that part is easy. The rest is then in doing it safely if working with mains and choosing the right relay.

If you do try it, use the relay to switch a torch or a LED+R on a separate battery before going anywhere near mains. Come back here before making the first mains attempt then people can see what you have and advise on your circuit and associated precautions to take.
 

westaust55

Moderator
The web page you link to is far from a complete project.
There is PICAXE code to accept commands via SERIN and turn and LED on or off plus a message back using SEROUT.
while wireless is mentioned no details are given so the reader is on their own.
What wireless system (parts and protocol are intended) and not mentioned.
No schematics provided.

If you were just trying to control an LED that is one thing, but from what I perceive of you skills level and the DANGERS of working with voltages above even 32 Vac or 50Vdc which is deemed the threshhold for "Low Voltage" under international standards (less/lower is called extra low voltage) I, for one, am relectant to advise you on such a mains powered or controlling project.
 

g6ejd

Senior Member
I'm not really sure what I make of this so-called Lightweight Local Automation Protocol, when it's nothing more than a very simple programme that takes an input and responds to it, which is what nearly every programme associated with a micro controller does, it's probably the pretentious title that has put me off it.

That said, if this was produced in an school environment then my outlook on it would be different or modified, so without that context I will remain at best unimpressed.

Adding wireless capability should be relatively easy, although if any control of domestic supplies (230V in the UK) is involved; like Hippy, I would add some caution and suggest the 'protocol' needs to be considerably more advanced than the examples shown to prevent inadvertant or false triggering/activation and to provide some element of safety.
 

sedeap

Senior Member
220v Safe interfacing

Interfacing 220v must be done with EXTREME care... (Killing Power)

So I design some years ago this little ISOLATED box and drive it from Picaxe in many Projects
The box itself is a standard electronic box PVC from electronic supplier, rated to 380v
The cable plugs are standard 240v 10A with 10A fuse inside.
The board was reinforced with copper and soldering matter
The BT137 uses a aluminum dissipation shield
220vInterfaceDiag-ch.PNG
Hopefully this helps someone AVOID blinking in the night...;)

C U Pals
(See You Pals)


PS: sorry for my rusty english... LOL
 
Last edited:

hippy

Technical Support
Staff member
I'm not really sure what I make of this so-called Lightweight Local Automation Protocol, when it's nothing more than a very simple programme that takes an input and responds to it, which is what nearly every programme associated with a micro controller does, it's probably the pretentious title that has put me off it.
I'm not adverse to titles, pretentious or otherwise, because it always helps to have things labelled and well specified so everyone knows exactly what it is they are talking about or using.

As you say, one communications protocol is pretty much the same as any other and all set out to get data from one place to another. The advantage of any chosen implementation is, through its associated specification, it is pre-agreed on how that will be achieved and most likely what can be done.
 

sedeap

Senior Member
Here too, but only if you grab the main wire...
If you take power from an wall-outlet (supposed to be protected from Thermic-Switch and Differential Disjuntor in home as standard) and a fuse inside plug...
(No clue how you name those devices in home electrical switch board) but here are compulsory to use in every home.
http://www.alamtec.com.ar/admin/files/+57.jpg



CU Pals;)
 

ciseco

Senior Member
@g6ejd - I giggled, thats the whole point of LLAP, it's supposed to be simple, just 3 rules with positive ACK's. Needs a reliable mechanism for getting the data there and back and over multiple mediums, thats the hard part. Using it you can with new gateway publish picaxe data to Pachube, Nimbits, twitter, email etc. I wouldn't want you to confuse simple with unpowerful.

Haku is right we already do a relay board that'll do it and conforms to all UL creepage etc, it can be had with a matching box for physical isolation. The picaxe example was a simple exercise to show the bare minimum that is needed to get LLAP running doing a simple task on a £2 hobby chip. A full fat LLAP device has so many more things to do and would be well beyond an 18M2.

Stan, seriously, put LED in pin x and y, does it need more explanantion or schematic.

UmBongo, the guys are right, don't go playing in mains, the gateway will have examples of how to integrate stuff like those B&Q homeeasy switches so you can do it safely, also supports options for ethernet, wifi, bluetooth and xbee's so you'll not be limited to just axe 2 axe or to PC comms. Anyway thats a different story for a different day.
 

eclectic

Moderator
Would it be easy to adapt this example to wirelessly switch 240v mains via a relay instead of an LED?


My electronics knowledge isn't brilliant so I thought to ask more experienced forum members. I was thinking of wirelessly controlling a 240v desk lamp.

Why not just buy a ready made Module?

They may not be perfect, but there's no need to do any wiring.

One example:
http://www.picaxeforum.co.uk/showthread.php?16509-El-cheapo-mains-remote&highlight=cheapo+mains

e
 

ciseco

Senior Member
Now having more time to sit down and re-read the comment of g6ejd which says "suggest the 'protocol' needs to be considerably more advanced than the examples shown to prevent inadvertant or false triggering/activation and to provide some element of safety. "

I can see why you might think this, but you are incorrect within the context of the example with the XRF radio employed. This module provides a 100% dependable transmission of correct data (or nothing) all error checking, packetisation, fragmentation etc is done for the user automatically. The LLAP protocol provides a positive ACK for knowing the command was both recieved and actioned, the 18M2 example doesn't ultimately employ retires and such extra methods to ensure high reliability, this is to keep the code compact. What you perhaps fail to realise is that the XRF employs complex mechanisms to ensure data is valid and also provides 128bit encryption if desired, the XRF should not be confused with the more basic RF modules which are common place, it's a serious piece of kit at a very good price.

Therefore I can see why you might conclude LLAP would be insufficent with common basic RF modules, with an XRF, XBee and many other "smart serial RF transcievers" it's the perfect balance of simplicity and function and totally suited to any micro including the PICAXE. If you wanted to use a low end type of module you would need a pre processor as RevEd already sell, to manage CRC's etc, encoding and other things to give a dependable link.

I can ensure you, LLAP it's not only simple, it's solid, reliable, secure and proven. The XRF is being used in commercial and miltary applications, I assure you we know what we are doing and why.
 

g6ejd

Senior Member
I am merely observing that when the term 'protocol' is used in any guise, full-fat or lightweight, it needs to state what the rules are, viz:

Data exchange formats, field formats, headers and footers, command syntax, maximium transmission and reception sizes, data rates, data exchange adressing formats, some form of addressing scheme, maybe some routing information, the detection and correction of errors, a scheme of acknowledgement for reception confirmation, data loss handling, sequencing and flow controls. Even in the most basic of protocols I'd expect these to be defined, but I see nothing other a series of ad-hoc, almost trivial definitions, so on that basis I'd would not use the word 'protocol' and the fact that it's a 12-byte message format hardly makes it a protocol.

If an XRF part handles elements of the protocol then OK, but now I'm thinking what was supposed to be a LLAP protocol just got a whole lot complicated and by definition became full-fat...

The example cited was nothing more than a very simple control programme, so could I call all my programmes protocols :)

As to LLAC being used in military applications, well I do wonder, maybe for simple command structures and interfaces, but I doubt for mission critical communications, where the use of a protocol as I understand it seems inevitable.

Is the LLAC 'protocol' defined anywhere? I could find a 12-byte message format of ID,ID, byte1...12, but where are the details needed for implementation?
 

Paix

Senior Member
I am a little surprised that no one has commented before now, but the diagram by Sedap in post #6 has a bit of a potentially fatal flaw in it.

By custom and practice, it is assumed that the controlled conductor is the Live wire and not the neutral, yet this is far from being guaranteed with a two pin plug to connect it to the 230V AC mains supply.
 

ciseco

Senior Member
Why do I get the feeling you are a retired teacher?

Search and you will find my young apprentice as they say in the films, it's all there to be read on openmicros. You are free to call it trivial if I can highlight you are uninformed. Observation of parts, to make judgments on a whole makes you an easy target, play nice and I'll help you.

LLAP has 3 simple rules, starts with an "a" in byte 1 to denote where to start listening, bytes 2 & 3 are the address of which device we want to talk to and the last 9 are the payload. Thats essentially it! There are common methods but you need to look deeper than the example. It's only an ASCII based master/slave protocol like MODBUS and plenty of others. I keep everything as close to plain english for good reason due to the audience.

I said XRF's in military use, not LLAP, I know it's late in the day here in the UK perhaps thats why you confuse the two, let me clarify:

LLAP (the protocol) is a very simple way to automate objects by basic text strings, has nothing to do with hardware (and that's why its good)

The XRF (radio hardware) provides a secure way of transmitting serial comms OR deployed as LLAP devices OR as an OpenCC device programmed in C/C++.

That particular 18M2 example was intended to be utterly simple, it was only turning on and off an LED afterall. Sorry you feel such things are beneath you, but I struggle to understand why you are an AXE user as it's also trying to make a complex subject accessible to those with no/little knowledge.
 

g6ejd

Senior Member
protocols - you have completely missed the point OM. No retired teacher here, a practicing scientist and engineer
 
Last edited:

sedeap

Senior Member
I am a little surprised that no one has commented before now, but the diagram by Sedap in post #6 has a bit of a potentially fatal flaw in it.

By custom and practice, it is assumed that the controlled conductor is the Live wire and not the neutral, yet this is far from being guaranteed with a two pin plug to connect it to the 230V AC mains supply.
OK... thats only a Diagram... We use here 3Flat contacts plugs (with ground, Compulsory Since 1998 for any new installation)
and the Icon of BT137 isnt correct either... but... You catch the whole idea... right?
Code:
_|>|_
 |<|
 

Haku

Senior Member
All this talk of safety when dealing with mains reminds me of when I was at school (in the 80s) I got a clock radio one christmas with a note on it saying I was forbidden to take it apart - well I ignored that and found it had a couple of unused solder points for a bulb which should've lit up when the radio was turned on, those two solder points were then wired to a relay in a project box with a mains socket so instead of being woken up by radio I would be woken up by tv :D
 

UmBongo

Member
Found some time to get back in to PICAXE stuff (again!).

Hippy: Excellent advice. Thanks. Totally agree about the safety aspects surrounding 240vac. I was thinking that these days there would probably be ready made mains relay/interfaces that could be switched with the logic voltages from a microcontroller so avoiding the need to build anything that interfaced with 240vac mains. Lack of clarity in my original post!

Westaust55: I agree with the good advice regarding the dangers of working with mains. Was hoping to go for something ready made with a suitable relay and input/output terminals. I should have been clearer in my original post!

Haku:Thanks, the dual relay board looks like the best ready made solution to control, for example, a 240vac table lamp.

g6ejd:Thanks for the comments. I need to look further in to this side of things as well.

sedeap:I agree about the extreme caution. I do not want to make anything from the beginning unless I was 100% sure. I wanted to try and go for something that was ready made and already isolated, and then interface wireless control.

BeanieBots: Thanks, I wanted to avoid making anything that plugged in to the mains and go for a ready made out the box solution - I should have explained better in my original post.

ciseco:Thanks for the advice, especially the dangers of mains - which I have a healthy fear and respect of anyway!

ecletic:Thanks, that is exactly what I was thinking as well. In my original post I wasn't very clear. I should have asked if there is a ready made relay/240vac mains interface that can take an input from a micro/wireless combo so I can switch something like a 240vac table lamp. The most I wanted to do was either plug the table lamp in to a 'box' (or take the plug off the table lamp and wire it directly to terminals in the 'box') and then the other end plugs in to the mains socket. Inside the box have the wireless receiver/micro. I will take a look at the B&Q type off the shelf wireless socket controllers.
 

geezer88

Senior Member
and in the UK (where the OP is from) must be done by a qualified electrician to be legal.
Is this true even when working on your own stuff? ie. not for sale? In the USA you can do your own house wiring as long as there is no commercial connection, and it is inspected by the local electrical inspector. If it is something that simply plugs into a normal socket, there are no rules. Is the USA just too "wild west"? Interesting stuff. Maybe I need a new nick-name: SmokeTest?

tom
 

eclectic

Moderator
Is this true even when working on your own stuff? ie. not for sale? In the USA you can do your own house wiring as long as there is no commercial connection, and it is inspected by the local electrical inspector. If it is something that simply plugs into a normal socket, there are no rules. Is the USA just too "wild west"? Interesting stuff. Maybe I need a new nick-name: SmokeTest?

tom
Here's a starter on the regulations maze:

http://en.wikipedia.org/wiki/Electrical_wiring_in_the_United_Kingdom

Not just my opinion, but
get a professional to do the "nasty" stuff.

At 240v, a tiny mistake could be catastrophic.

e
 

papaof2

Senior Member
I'm one of those US people who has done my own home wiring. Proper wiring isn't difficult - just follow the code for your area.
When I enclosed a carport to add living space, the city inspector only had one question: "Are you an electrician?" No, just good at following the requirements - which also means I sleep well at night ;-)

There are simple rules for mains wiring, whether the voltage is 120 or 240.
Know how to work safely.
Use the proper wiring and fixtures.
Have the right tools - including a "live cicuit" detector that flashes and beeps when placed next to a live conductor (Do you really believe someone else's marking of the circuit breakers?)
Turn off the power to the circuit(s) you plan to work on and use the "live circuit" detector to verify that power is off.
Have good battery-powered lighting, as needed. I like the head-mount lights when wiring in dark areas, plus a large (usually LED) flashlight for area lighting.

John
 

geezer88

Senior Member
Here's a starter on the regulations maze:

At 240v, a tiny mistake could be catastrophic.

e
Thanks for the pointer to the UK regs. Glad I don't have to worry about them. The tiny mistake mentioned above reminds me of when I worked for a small industrial place that had a leaky roof run water into a 480 volt, 3 phase panel. It blew the 3' x 4' steel door off the panel, disintegrated all the inerds, and started a small fire. A week later the custom panel was re-installed. A fellow had been dispatched to repair the leak.

The tiny mistake was that the leak was not fixed, and two weeks later a rain storm leaked into the panel again and blew it all up a second time. While only property damage resulted, if anyone had been in front of the panel I doubt they would have survived.

tom
 

eclectic

Moderator
@PapaJohn
As you have mentioned before, several times,
you have an extensive background (decades)
in electrical/electronic circuitry.

However, many posters here do not.
Rule 1. Any doubt? Don't.

e
 

hippy

Technical Support
Staff member
At 240v, a tiny mistake could be catastrophic.
I remember arriving home one evening to find a flatmate had wired-up an old metal cased electric bar heater -

Used a mains plug with unsheathed prongs
Hadn't tightened the cable clamp
Cable sheath ended outside the plug
Had cross-wired earth to neutral, neutral to earth
One gentle tug and every wire came out

It was the same flatmate who was running the washing machine on a 6A mains cable drum, still coiled up with smoke billowing out of it :).
 

fernando_g

Senior Member
The tiny mistake was that the leak was not fixed, and two weeks later a rain storm leaked into the panel again and blew it all up a second time. While only property damage resulted, if anyone had been in front of the panel I doubt they would have survived.

tom
Some years ago I saw a safety video which I cannot longer find, where they expose a dummy to a 480V industrial panel explosion. They film was shown in slow motion, like those car crash videos.

The amount of damage that the dummy sustained was unbelievable. Even if it had not killed him, most likely the third degree burns would have left him scarred for life and both blind and deaf.

Of course, the key here was not only the voltage, but the amount of energy that an industrial installation can provide. If I recall properly, it was in the vicinity of 200 KVA, which is about normal for a small to medium industrial environment.
 
Top