08M2 TX/RX Project

DRock

New Member
Hey everyone,

I have two breadboards setup with the attached circuits and I am using these transmitter and receiver chips, http://www.sparkfun.com/products/10533 and http://www.sparkfun.com/products/8945. I want to trigger an LED on the receiver side to flash once a mercury switch is tripped on the transmitter side, so pretty simple. I have come a very long way with this project as I have absolutely no prior experience with any of these components or this specific programming language but I am at a bump in the road. I want to flash the LED as long as the mercury switch is connected and when the switch is reset I want the flashing to stop. Here is the code I have for both the transmitter and receiver:

Transmitter code:

Code:
main:

    if pinC.3 = 1 then alarm 
        
    goto main


alarm:

    SEROUT 2,N4800,(1)
    
    if pinC.3 = 0 then main
    
    goto alarm
Receiver code:
Code:
main:
	SERIN 3,N4800,b1
	
	if b1 = 1 then flash
	
	goto main
	
flash:

	high C.2
	
	pause 100
	
	low C.2

	pause 100
	
	goto main
I can get the LED to flash a single time when I hold the switch down but it will not continue flashing. I know there is a programming error somewhere because I am not familiar with how a system like this works with sending the data and everything. I believe the use of an interrupt could permit the function I am looking for but I am not sure how to use it in this situation.

Any help is greatly appreciated! Thanks!RX.pngTX.png
 
Last edited:

jtcurneal

Senior Member
Looking at some of the info on the modules that you are using, I would suggest that you use t4800 (non-inverted) serial output instead of the n4800 (inverted) serial out that you tried. Before you send any data set your serout pin high (high c.2).

Try that, It may help.

Joel
 
Last edited:

baciocco

New Member
re

transmitter code:
Code:
main:

    if pinC.3 = 1 then alarm 
        
    goto main


alarm:

    SEROUT 2,N4800,(1)
    
    if pinC.3 = 0 then 
     
     SEROUT 2,N4800,(0)
     
     goto main
    
    endif

    goto alarm


Receiver code:
Code:
main:
	SERIN 3,N4800,b1
	
	if b1 = 1 then 

	high C.2
	
	pause 100
	
	low C.2

	pause 100

    endif
	
goto main
evidence in this way
excuse for English but I'm Italian
use google to translate
 

vttom

Senior Member
If you look through past entries in this forum, you will find that users of wireless TX/RC systems strongly encourage a known prefix to the data in order for the receiver to "train" itself to the signal from the transmitter and to reject spurious noise.

Also, your code could use some optimizing. So, with that in mind, I suggest...

Code:
' Transmitter code
do
  if pinC.3 = 1 then
    SEROUT 2,N4800,("ABC", 1)
  end if      
loop

' Receiver code
do
  SERIN 3,N4800,("ABC"), b1
  if b1 = 1 then
    high C.2
    pause 100
    low C.2
    pause 100
  end if
loop
The transmitter code should continuously transmit as long as the button is held down. The transmitter will flash the LED every time it receives a transmission.
 

DRock

New Member
Both of those codes just flash the LED one time while I hold the switch down and the T4800 doesn't work at all.

Hmm, not sure what is going wrong.

Thanks for the help.
 

1968neil

Senior Member
if you look at the walkthru on the sparkfun site it says non inverted serial connection (N2400)

http://www.sparkfun.com/datasheets/RF/KLP_Walkthrough.pdf

if you search the forum for "rf module" there are loads of examples.
Using a preamble and a qualifier in the code will help the modules to decipher each other from noise in this band.
from memory Stan Swan (AKA manuka) is the guru on this subject !

Regards
Neil
 

DRock

New Member
Thanks! I wasn't quite sure what to search for but I will do that right now.

EDIT: After a little research, do I need to add the 10k and 22k resistors to my schematic and breadboard like in this schematic?

Thanks!

08M to 08M RF Comms Project 240711.JPG
 
Last edited:

DRock

New Member
Do you believe adding those would fix my problem? I have been struggling with this project for the greater part of a month now and have done a lot of research but I am a mechanical engineer by trade so this stuff does NOT come easy to me.

Thanks!
 

manuka

Senior Member
Only one is really needed, but I always add both Rs to prevent "floating pins", which may especially be a problem when a transmitter is nearby! Including these 2 Rs,& a simple 3 pin socket,allows easy reprogramming too - refer below. (To standardise components 2 x 10k are used here in series for the 22k)
 

Attachments

hippy

Technical Support
Staff member
if you look at the walkthru on the sparkfun site it says non inverted serial connection (N2400)
My take on that would be the signal is as if "straight from UART, without inversion", which would normally be T2400 baud for PICAXE. It would be the first RX/TX pair I've seen which did not use Txxxx baud rates.

Both of those codes just flash the LED one time while I hold the switch down and the T4800 doesn't work at all.

Hmm, not sure what is going wrong.
I would bet it is almost certainly a lack of preamble and qualifier for data synchronisation.
 

Paix

Senior Member
An example: given that the signal type shown is T with a holding mark high, the red is the transmitted start bit and what follows in black is the character generated by the Picaxe followed by the orange stop bit. I use the character "1" rather than the value 1 for the illustration.
G226.png
See how this is interpreted if you don't set the serout pin high before you begin to transmit that single character. In our example, transmitting the character “1” the fifth data bit of the character is interpreted as the start bit and the next eight bits, stop bit and idle marking period that follows is interpreted as it appears. Of course if after a single stop bit, a new character starts at machine speed, then the results of the first character will differ and God alone knows how the next character will be viewed – Garble.
Best you find this out on a bit of wire before tearing your hair out for real by going direct to radio with the extra issues that it brings with it for the unwary.

Heed what Jtcurneal said in post #4.
I'm inclined to agree with Hippy on this one, regarding T and the need for synchronisation/qualifier.

A question however:
Given that serin 3, N4800, b1 doesn't compile, or comply with the syntax shown in Manual 2, and that for example serin 3, N4800_8, b1 does, how much of the code has been compiled and run?
 
Last edited:

hippy

Technical Support
Staff member
Given that serin 3, N4800, b1 doesn't compile
It should and does for me.

I think we are in danger of going off at a number of tangents which are unnecessarily confusing in trying to make things work or to explain what might be happening when the mechanism currently being used by DRrock won't work, period.

See Example 3 here : http://www.picaxe.com/Circuit-Creator/Miscellaneous/RF-Radio-Transmitter
And example 3 here : http://www.picaxe.com/Circuit-Creator/Miscellaneous/RF-Radio-Receiver
 

DRock

New Member
Should I attempt to use rfin and rfout instead of serin and serout?

I only want to transmit this one bit of data to flash the LED constantly and then to stop when the switch is let go.

How would the code look like if I were to use a synchronization/qualifier?

I have researched about those but I am unable to find an example with a well written explanation of what each piece of code does.

If I am correct then the code I am currently using, as was suggested by a forum member, contains a qualifier but NOT the synchronization?

Code:
' Transmitter code
do
  if pinC.3 = 1 then
    SEROUT 2,N4800,("ABC", 1)
  end if      
loop

' Receiver code
do
  SERIN 3,N4800,("ABC"), b1
  if b1 = 1 then
    high C.2
    pause 100
    low C.2
    pause 100
  end if
loop
Thanks!
 
Last edited:

manuka

Senior Member
Although ~50 years of hands on work has left me something of an RF "horse whisperer", I find ongoing 433 woes others report often arise from simple oversights. These 433 MHz TX/RX pairs are so PICAXE friendly that they "always work" if wired correctly & controlled with simple coding.

The transmitter may not be working for starters ! Perhaps borrow a scanner or make up a simple band monitor to check. Is the receiver correctly powered - many RX are picky & need 5V. Are the units too close together -some types will overload unless at least across the room from each other.

My #11 posting related to a modification to simply send tones- check some serial data ideas from the circuit below. Stan.
 

Attachments

DRock

New Member
Every time I think I am getting close more issues pop up...ahhhhhhhhhhhh.

I have two receivers and two transmitters and when I switch them out the system still will not function correctly so I am assuming neither are defective. Also the transmitter will send a signal to the receiver but it only flashes the LED once and I want it to continually flash, so it seems like it is working. I think they may be too close together, I have them about 8" apart on the same breadboard using a 4.5V 3AA power source to power the whole thing. I guess I have to go back to Radioshack and get another 3AA holder or 4AA holder since you said the RX might require 5V+ to run and then split it up onto two separate breadboards.

Thanks for the helpful replies, I will report back with progress!
 

eclectic

Moderator
Every time I think I am getting close more issues pop up...ahhhhhhhhhhhh.

I have two receivers and two transmitters and when I switch them out the system still will not function correctly so I am assuming neither are defective. Also the transmitter will send a signal to the receiver but it only flashes the LED once and I want it to continually flash, so it seems like it is working. I think they may be too close together, I have them about 8" apart on the same breadboard using a 4.5V 3AA power source to power the whole thing. I guess I have to go back to Radioshack and get another 3AA holder or 4AA holder since you said the RX might require 5V+ to run and then split it up onto two separate breadboards.

Thanks for the helpful replies, I will report back with progress!

Quick reply.

8" is MUCH too close.

Increase the separation.

Try, say, 8 feet, or yards or ....

e
 

manuka

Senior Member
Just a single LED flash -is your code correctly set up to loop ?! Check the RX supply specs as they'll probably handle as low as 4½ V OK. Use very fresh alkaline AA too, as these usually put out ~1.6V per cell when new ( 3x 1.6V =4.8V). 4 x regular AA = 6V, so too high for a PICAXE, but simply drop to ~ 5.3V with a series Si diode.
 

DRock

New Member
This is my code that I am running:

Code:
' Transmitter code
do
  if pinC.3 = 1 then
    SEROUT 2,N4800,("ABC", 1)
  end if      
loop

' Receiver code
do
  SERIN 3,N4800,("ABC"), b1
  if b1 = 1 then
    high C.2
    pause 100
    low C.2
    pause 100
  end if
loop
Is it looping correctly the way it is written?

Thanks!

EDIT: This is the spec sheet: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Wireless/General/RWS-374-3_315MHz_ASK_RF_Receiver_Module_Data_Sheet.pdf

According to that the min Vcc is 4.9V and the max Vcc is 5.1V so maybe that is the issue.
 
Last edited:

Paix

Senior Member
If you were to toggle a LED every time your transmitter looped, it would flash at half the rate that you are sending messages to the receiver.
This would show you that most messages are being lost because you are transmitting a lot faster than the receiver is capable of responding to.

Why not remove the 100mS delay in the receiver code after switching off the LED and instead put a 150mS delay into the transmitter loop after transmitting the message. Why, because after the transmission the receiver is going to be busy for 100ms at least while the LED is lit and 200mS the way you have it at the moment.

You could also put another LED in the receiver loop and toggle it also, then when the switch was held closed you would be able to see what the best delay was after transmitting your trigger.

Only contemplate the changes after you have your current code working properly.

= = = Consider:
At present, at 4800 baud, you are probably transmitting some 480 characters each second. Your message is four characters long, so with the switch closed you will be transmitting 50 (60 without loop overhead) trigger messages per second.

Your receiver loop cycles at something just under 5 times each second.
My suggestion above would speed up the receive loop and if the transmit loop was to generate trigger messages at a slower rate than the receive loop cycles, then the off state of the flashing LED would actually be determined by by the transmitter. If the receiver now cycles 10 times per second and the transmitter triggers at a maximum rate of 5 times per second, then the LED would flash 50:50 on/off at 5 times per second, the rate being set by the trigger sent from the transmitter.

Does this make sense?

With regard to your power supply, I would ensure that you have 5V, if you use 6V batteries then a 5V LDO regulator appears to be a good idea.
 

DRock

New Member
Yes! It works!

This is the code that ended up working for me after making the suggested changes:

Code:
' Transmitter code
do
  if pinC.3 = 1 then
    SEROUT 2,N4800,("UUUUUUUUUUUUUUUUUUUUUUUUU")
    pause 10
    SEROUT 2,N4800,("ABC", 1)
    pause 150
  end if      
loop

' Receiver code
do
  SERIN 3,N4800,("ABC"), b1
  if b1 = 1 then
    high C.2
    pause 100
    low C.2
  end if
loop
The LED flashes at a consistent rate but it will randomly miss a flash here and there, I think maybe if I slowed down the transmitter a little more it would help with that.

Thanks so much!
 

manuka

Senior Member
DRock: Yes!! For the record can your please verify if supply voltage and close proximity overload issues were addressed. Slower data rates indeed should help, both with missed data & range. Go as low as you can - even 300bps.

That "pause 10" line may not be needed -try the entire outgoing TX code code in a single line.
 

hippy

Technical Support
Staff member
@ DRock : Glad to hear you have it working.

As most modules use T4800 baud rate polarity, would you mind indulging me and changing it ( at least temporarily ) on both transmitter and receiver and seeing if that does work. Firstly I'm intrigued, and secondly intrigued by the likelihood that it could / should all work regardless of polarity.

If the polarity is wrong it will be transmitting all the time it is idle ( switch not pushed ), which isn't good etiquette, and will be using more power than necessary. As the transmitter appears to battery powered that could reduce battery life considerably.
 

DRock

New Member
@Joel: Thank you for the tip, I will try that and see how it works.

@Manuka: For the record I am still using the 3AA battery holder to power the entire system and they are still roughly 6"-8" apart but the whole thing is working flawlessly right now. I will tinker around with putting the TX code in a single line and with slower data rates when I do range testing as I am going to assume it will need some tweaking. I need the system to work in roughly a 200' range in a wide open area which I don't think will be that hard to accomplish. I am also thinking of switching to IR because the range is so little, but that is getting ahead of myself at this point.

@Hippy: The only switch I made was to change N4800 to T4800 and it did not work. I am not sure why at this point because I am still learning, but if the TX is transmitting all the time even at idle then that is something I definitely want to fix. Here are the components I am using:

http://www.sparkfun.com/products/10533
http://www.sparkfun.com/products/8945

I am going to a friends this weekend so I will have limited internet access but I will try to address any further posts as soon as I can.

Thanks again for all the help!
 

Paix

Senior Member
With the lack of a PTT switch input, do I understand that powering the tx is how it's done or are you suggesting the carrier sense may be significant in some cases Hippy?

I'm not quite sure what is meant by a modulation type of ASK, does this indicate Amplitude Shift Keying (meaningless!!) or a short form of AFSK. Crystal ball time perhaps? Does the data normally modulate an audio oscillator, or with this type of cheaper device is it just the data waveform that modulates the carrier, AM or FSK?

Questions, questions, always questions. Thanks in anticipation of a comment or answer.
 

jtcurneal

Senior Member
ASK, does stand for Amplitude Shift Keying,

I believe that the transmitter goes from zero output to full output as the serial input changes state.

Joel
 

manuka

Senior Member
Most simple data transmitters use rapid "Morse Code" style OOK (On Off Keying) modulation to encode the 0 1 data bits. ASK (Amplitude Shift Keying) diminishes the carrier level rather than reducing it entirely.
 

Attachments

Paix

Senior Member
Many thanks JTCurneal and Manuka. I should have known, but patently didn't. The diagram was indeed worth a thousand words. :)

No tones involved, just data keyed carrier, in the amplitude domain. A1D Guide to class if emissions.


I sort of got confused years ago when they updated the nomenclature and changed A3J to be J3E.
 

Paix

Senior Member
Many thanks JTCurneal and Manuka. The picture is worth a thousand words. :)

Ofcom Guide to classes of emission

That would be A1D for the top diagram and L1D for the bottom? Difficult to classify as I'm tempted to call them both A1D.
One could argue that the bottom one is A1A and that the modulltion type changes because of the intent of the originator. 40wpm Morse for aural or automatic reception. Does that mean that as more people use programs to decode Morse, that the modulation type changes . . . Hmmmmm.

I got confused years ago when A3J became J3E. << please feel free to ignore my rambling >>
 

DRock

New Member
I have come back to this project after a brief hiatus while looking for jobs.

The issue I am having now is I cannot transmit past 5' or so in a wide open room.

What are some things I can do to increase the range? More voltage? What is a cheap/easy/simple antennae I can make for testing?

Thanks again, you guys have been extremely helpful!
 
Last edited:

eclectic

Moderator
Welcome back.
5 feet sounds very low.
Most of the small cheap modules can do 50 yards+ line-of-sight.

Just for background, can you post a couploe of HQ photo's
of your present setup?

It'll help folks get a "feel" for the scale.

e
 

DRock

New Member
Nothing out on the ice yet, just testing in my living room so far.

I attached a picture of my setup on my laptop to give you guys a sense of scale.

I just walked about 15' away in my room and it was not steadily flashing, 20' and it wouldn't flash at all...from 5'-10' it flashes constantly until I let go of the button like it is supposed to.

Is it dropping too many packets or something to function properly at that distance? Maybe I should have it flash 20 times once it gets one signal instead of flashing every time it gets a signal.

Just throwing out ideas, I am lost here.

Thanks for any help!

IMG_0018.JPG
 

westaust55

Moderator
I cannot see any antennae in the photo you posted.

Typically a straight vertical wire of a quarter wavelength is required connected as close as possible to the antenna pin on the modules &#8211; every mm of circuit from the pin forms a part of the antenna circuit.
Many folks here have in the past used 433 Mhz modules which needs a wire with a length of 165 mm

The modules you have are 315 Mhz so the wire length needs to be increased slightly to 227 mm.

General formula is
Wavelength L (metres ) = 286 / Freq (MHz).
That is for 1 wavelength whereas you can usually work with a quarter wavelength with good results.

From my own past experience, do not have either module on top of your laptop. In my case, very close to another electronic (humidity) module was sufficient to prevent operation. Likewise even sat on top of a concrete slab even with the slab 700 above ground would greatly attenuate the Tx signal so could not be received at 20 metres. Lifting say 150mm above the concrete gave a good signal over 50 metres or more (never tested to find max limit).
 

Paix

Senior Member
The antenna are there, Black wire against a black keyboard and look to be about 100mm to 150mm in length canted over at 60 degrees and 20 degrees. left and right respectively.
 

westaust55

Moderator
Your are right Paix. While on a PC with a monitor obviously having better contrast I can see the wires.
Relative the the breadboard width, I would however suggest more like about 70 to 80 mm in length.

So for 315 MHz they need to be extended to around 227 mm as mentioned above for optimal length.
 
Top