Monday, 9 September 2019

wireless - PICAXE and RFA001


I have two 40x2 with a RFA001.


I whant to send 1 if the I push the pusher and high a led to know if it recived the code. It seems that doesn't work. It's correct?



Transmitter:


main:
if pinD.3 = 1 then
high D.2
W1 = 1
serout 7,N2400,(W1)
else
low D.2
W1 = 0
end if

goto main

Receiver:


  high D.1
high D.2
pause 1000
low D.1
low D.2

main:

serin 0,N2400,W1
if W1 = 1 then
high D.1
else
low D.1
end if
if pinD.3 = 1 then
high D.2
else
low D.2

end if
goto main

Answer



Those style of RF receivers don't like having a DC component on the data being sent and received. Normally when sending data you should use something like Manchester encoding to keep the number of ones and zeroes being sent balanced. Atmel has a good document called Manchester Encoding Basics:


http://www.atmel.com/images/doc9164.pdf


However in your case because you're sending a single byte you can probably simplify things. At the moment you are sending the value 1, which in binary with a 0 start bit and one stop bit ends up being:


0 1 0 0 0 0 0 0 0 1

As you can see that has a long string of zeroes, what you want ideally is something with a fairly well balanced set of zeroes and ones like this:


0 1 0 1 0 1 0 1 0 1


Which in hex is 0xAA, so try sending that instead of one. You are also turning off when no data is received or there is a transmission error, you may be better off having a seperate code transmitted to indicate the output should be turned off, for example:


0 1 1 0 0 1 1 0 1 1

Which in hex is 0xCD, so as the second step change your logic to only turn the output off when that is received. Also be aware that when no carrier is being received you will receive a lot of 'junk' which will confuse the receiving UART.


The usual way to cope with that is to add a preamble but in your case you can probably transmit the byte multiple times to make sure it gets received. Also try taking the transmit line high for a while (say 5mS) before sending each byte to make sure that the start bit gets detected.


As a final note using a single byte you'll probably find that the random junk received also occasionally causes false triggering. Once the basics are working you may want to look at sending a longer sequence such as 32-bits / 4 bytes.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...