Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 20:05 29 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Wireless for the nooby.

Author Message
banda
Newbie

Joined: 12/05/2014
Location: New Zealand
Posts: 35
Posted: 01:44pm 26 Apr 2015
Copy link to clipboard 
Print this post

I've been on a roll! I've been hot!

I've made my LEDs go blinky-blink.

I (with lots of help) have made my LCD read time and temperature.

I've measured my altitude, being 48.9006 metres above sea level, with an accuracy of 6/10 of a millimeter , (and I believe in the tooth fairy).

I've made my Darth Vader IR light sabre make LEDs go blinky-blink from across the room on demand.

HOWEVER, I think I'm now about to box above my weight because I want to read data wirelessly, sent from outside the house say. I already have a pair of transceivers,
HC-11 433MHz wireless RF serial UART, unused because I defected to micromite,



and as well I've ordered the following,
433Mhz RF transmitter and receiver kit Module



I'm always amazed at how arcane the cross-flow of information is on the forum. It's mostly an alien language to me, so here's my plea.

Is there anyone out there as simple as me (or anyone) who has a simple program that makes transceivers work? I'm good at analysing a working model.

Thanks for ANY advice.
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1209
Posted: 02:02pm 26 Apr 2015
Copy link to clipboard 
Print this post

Hi Banda,
Many moons ago when I was programming 8 bit pic's I had a play with those 433mhz wifi units and found them to very hit or miss. I was advised on another forum to use Manchester coding for them and that did do the trick. So maybe look into that but as far as doing it in basic I haven't tried as I doing ASM back in those days.

Regards Bryan
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 11:50pm 26 Apr 2015
Copy link to clipboard 
Print this post

I agree with Bryan on this one, and I have not had a great success rate with those super-cheap RF modules. From what I gather, they DO work, but don't expect it to be easy, depending on module.

I tend to use only Radiometrix or SunrayRF modules, but they are about US$20 each - or more depending on wanted power output etc.

The one major advantage of the more costly modules is that they are more likely to work right out of the box, and will most likely be type-approved.

However, if you wanted to try something with the cheap modules you have, you would need to setup two bits of code - one on the transmitter, the other on the receiver to form the data link.

Most "Dumb" modules(modules that have no processing on-board, they just transmitt the data sent into them) will tend to need some pre-amble bytes to help sync the data-slicer in the receiver end of things. This is normally done with capital U characters, as this represents 8 bits of alternating zeros and ones, which allows the data slicer to sync to the data stream. You also tend to need some kind of qualifier in the data, so the receiving end knows the message is for it.

So, you might have something like this in your code:

TRANSMITTER:

Open "COM1:9600" as #1
Print #1,"UUUUUUUUUUUUUUU$$$$YOUR MESSAGE HERE"
Close #1



In this example, we open COM1 and print the string to it.
The COM1 TXD line is connected to the transmitter module's RXD line.
The module and the MM share a common ground.

The series of U's is the pre-amble, the $$$$ is the qualifier, and the YOUR MESSAGE HERE is the actual message.

RECEIVER:

Open "COM1:9600" as #1

DO
If LOC(#1)<>0 then
D$=INPUT$(#1,LOC(#1))
If MID$(D$,1,4)="$$$$" then

{what you want to happen with valid message here}

Endif
Endif
LOOP


This receiver code will go around and around waiting for something to arrive in the serial input buffer - this is the line connected from your receiver module's TXD pin, to the MM chip's RXD pin - remember that unlike I2C, serial comms lines cross over from one end to the other: RXD to TXD, and vise-versa.

If LOC(#1)<>0 then - this asks the MM to go to the next level of processing IF and ONLY if, the serial input buffer has something in it for attention.

D$=INPUT$(#1,LOC(#1)) - This code asks the MM to suck however many bytes may be in the buffer, into a string called D$.

If MID$(D$,1,4)="$$$" then - This line of code looks for the qualifier, and if the message does NOT start with that qualifier, then the message will be ignored.

Note that we totally ignore all the U's in the receiving code, as the purpose of the series of U's is not for actual data purposes, but to sync up the receiver to the data stream, so that we CAN suck in the wanted data from the link.

Also worth noting is that smart modules don't need these U's - the first modules in your photos look like this type, but I don't have any of those.

This is a very simplistic look at how to drive RF modules just so you can see how it can be done, but I can help you if you like - I have done a lot of RF module work with the MM and Picaxe chips.

Edited by Grogster 2015-04-28
Smoke makes things work. When the smoke gets out, it stops!
 
banda
Newbie

Joined: 12/05/2014
Location: New Zealand
Posts: 35
Posted: 02:13pm 27 Apr 2015
Copy link to clipboard 
Print this post

Thanks Grogster, You've given me a beautiful, straightforward list of instructions.
In effect the mighty Micromite has done all the spade work and I can build whatever from that foundation.

It'll be a few days before I have the time to play about, but in the meantime .....

1. In essence I treat the module like my Darth Vader IR light sabre. If I give it the correct information as you have shown, the wireless will just do its thing.

2. Do all the "U"s just get looked at, taken notice of, then discarded?
Your MID$(D$,1,4)="$$$" suggests that, and your later comment seems to mean that.

3. If my message says "PIN(15)=1" will it turn the LED connected on? Is it just that Easy? It can't be. Why am I worrying?

Kindest regards.
Barry
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 02:23pm 27 Apr 2015
Copy link to clipboard 
Print this post

Hey Barry.

1) SHOULD do it's thing. The code examples I gave are just that - examples, and might need tweaking depending on what your modules can do - many cheap ones are unhappy at 9600 baud, so you might need to change that to 2400 or something with the "Dumb" ones.

2) YES - U's sync the data-slicer in the receiver(for the dumb modules), and then are totally ignored. With dumb modules, you will find that you really HAVE to use that preamble, or you will not get the message, or will be missing bytes from the message. The $$$$ is, again, an example. The qualifier can be whatever you like, but keep it short.

3) YES if all you want to do is turn on pin 15, then the receiver code example might read something like:


Open "COM1:9600" as #1

DO
If LOC(#1)<>0 then
D$=INPUT$(#1,LOC(#1))
If MID$(D$,1,4)="$$$$" then Pin(15)=1
Else
Pin(15)=0
Endif
Endif
LOOP


In this example, we also ignore any message per-se', and just send the qualifier, which IS the message, as you are sending data rather then a text type message.

Likewise, in the TRANSMITTER code, you would remove all of the text message, so that it just sends the string: UUUUUUUUUUUUUUU$$$$

If you had several different receiver nodes, each one can have it's own unique address just by changing one(or more) characters of the qualifier - $$$0 through to $$$9 would give you ten different receiver addresses, and receiver $$$5 would only respond to messages for it - the others($$$0-4 and $$$6-9) would all be ignored.

You can get even more crafty then that - this is just basic stuff, but I don't want to scare you off!

Keep up the good work - glad to see you still tinkering about. Edited by Grogster 2015-04-29
Smoke makes things work. When the smoke gets out, it stops!
 
banda
Newbie

Joined: 12/05/2014
Location: New Zealand
Posts: 35
Posted: 04:59pm 27 Apr 2015
Copy link to clipboard 
Print this post

Poor Grogster,
I shouldn't have looked at the forum again before I had time to play about, but I can't wait for the time to test it for myself.

Could I just send: Print #1,"UUUUUUUUUUUUUUU$$$$"(,?) pin(15)=1
Does data not need to be turned into a string? Would I need a comma?

I promise, no more questions until I'm playing about.

Barry

 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1328
Posted: 07:42pm 27 Apr 2015
Copy link to clipboard 
Print this post

@banda
@grogster

Minor correction to the INPUT$ line Grogs. You've got:
D$=INPUT$(#1,LOC(#1))

Think that should be:
D$=INPUT$(LOC(#1),#1)

The MMBasic Manual quotes:

INPUT$(nbr, [#]fnbr) Will return a string composed of ‘nbr’ characters read from a serial communications port opened as 'fnbr'. This function will return as many
characters as are waiting in the receive buffer up to ‘nbr’. If there are no
characters waiting it will immediately return with an empty string.


Greg

 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 11:10pm 27 Apr 2015
Copy link to clipboard 
Print this post

Thanks Greg. You are absouletly right.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024