View previous topic :: View next topic |
Author |
Message |
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Sat Feb 08, 2014 5:19 pm Post subject: using RC5 protocol to connect two AVR's |
|
|
I'm trying to connect two AVR's together with RC5 code - a reason is that i will be using 433MHz transmitter later and i thought that RC5 is great way to encode/decode signals.
SO, i tried to connect them with wire first: i connected TX out to RX input:
-TX is mega8, i'm using program from HELP section with rc5send command, TX pin is B.1 (OCR1A)
-RX is mega16, i'm also using program from HELP section (getrc5), RX pin is B.6
both are using XTAL 11059200 MHz, so i guess timings are correct.
i also tried using timer2 on RX section.
i just can't connect the two. I tried direct signal, inverted signal...
on the oscilloscope i see pulses from TX, so rc5send is working. i tried pull-up on rx, pull-down...
What am i doing wrong? result from getrc5 is only 255 for address and 127 for command...
I also tried with IR receiver TSOP34838 and one old remote, for which i'm sure it's RC5, but still doesn't work...
Bascom is latest version
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Sat Feb 08, 2014 10:48 pm Post subject: |
|
|
RC5 is working with an carrier frequent of 36Khz. 433Mhz transmitters has an bandwidth between 1.6kHz and 13kHz, so that won't work. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Sat Feb 08, 2014 11:00 pm Post subject: |
|
|
Yes, you have the point... i saw that after a while, too. So, i tried with IR receiver TSOP34838 (which is 38kHz, to be exact, but that wasn't the reason for not working), but that didn't work either. After a few hours of struggling, i finally managed to get it to work. It seems that crystal on the receiver part was bad (can you imagine?) , so after i switched to internal clock it was OK.
Anyway, i see that this won't work, so i will have to find a different way - i intend to make a wireless connection from my garage to my house for burglar alarm, so connection must be foolproof and 100% working at all times.
I must find some sort of manchester code for this purpose. The point is that i need one both for TX and RX side...
Thanks! |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Feb 09, 2014 10:15 am Post subject: |
|
|
Hi,
Maybe have a look at the HopeRF rfm73 Radio modules. I'm currently playing with them and am quite impressed. The range isn't wonderful (ca. 10 meters through 2 concret walls) but the modules are:
1) Really cheap at 2.50Euro a Piece
2) SPI Interface
3) Include Auto acknowkledge/retry
4) Really small 16x13mm
5) There's a Bascom AN for an earlier model that almost works
6) 2.4GHz Radio frequwncy
7) Each Radio can have it's own ID so i's possible to create a one to many star Network (One Transmitter, many Receivers)
I'm currently transmitting a data packet to one of 16 Receivers every 300ms. Once I get the Software working 100% I'll create an AN (I'm corrently having Timing Problems with the initalisation).
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Sun Feb 09, 2014 1:12 pm Post subject: |
|
|
I already did play with RFM22B modules, but they are sooo complicated, i'd almost need a college degre to undesrstand it...
HMTRP module is quite nice and simple, but a bit more expensive...i wanted to buy it in my local store, but they ran out of them...but i will try them out soon...what i like there is a capability to change TX power and monitor RSSI value.
However, i did manage to find this site:
http://www.roboternetz.de/community/threads/5068-Funk%C3%BCbertragung-mit-Bascom-%28-L%C3%B6sungsansatz-%29
it's in german, but there's a sample of manchester encoding, with start bytes, 4 bytes of data and CRC checking. it took me a while to get it work, mainly because i changed clock frequency and so i managed to corrupt timer and timing values. So, if anyone intends to try out, a second code is definitely working( from space teddy, 3rd page). BUT, a piece of advice: DON'T change frequency! OK; you can change that 7362700 to 8 MHz in TX section, but that's all. unless you know what you're doing, of course.
What i don't undestand in that program is timer0 in RX section, though...a guy loads 8bit timer with 16 bit value...?? With settings below about 80' uS is achieved, crystal is 8 MHz
Code: | Const Reload = 256 'Timerreload
...
Const Timer0_reload = - Reload '--> 65535 - reload
...
'Timer einstellen+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Config Timer0 = Timer , Prescale = 1
On Timer0 Timer0_overflow
Enable Timer0
Enable Interrupt
|
But for now, all is working just great - and with 2 euro modules (RFM83C/RFM85). If it will continue to work, then i win! |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Feb 09, 2014 1:40 pm Post subject: |
|
|
Hi protoncek,
The documentation from HopeRF for the rfm73 isn't that goof, but with the AN (an 115) and some time to study it's not that hard.
These things are complex, so the programming is complex. But once it's working the chip offers alot of functions (Auto retry, Multi Receiver etc.)
So: no pain, no gain.
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Sun Feb 09, 2014 2:40 pm Post subject: |
|
|
Aha---now i see that RFM73 is 2.4GHz module...i didn't work on that frequency yet...i will read about it and see. Thanks! |
|
Back to top |
|
|
DK5BU
Joined: 06 Aug 2012 Posts: 23
|
Posted: Sat Feb 15, 2014 3:27 pm Post subject: |
|
|
Hi protoncek,
I sucessfully played around with IR and RC5. I think it should work on a 433 MHz radio link, too, but I never tried.
Well anyway, the reason that your experiments didn't work is not the lack of bandwith on the radio link, but the way the IR communication works:
The transmitter is a dumb IR diode. It is switched with a 36 kHz square wave from an AVR Timer and modulated by the (much slower) RC5 Signal. Modulated means: simply switched on an off.
The IR receiver chip, however, delivers a DEMODULATED signal. At its output there is the demodulated RC5 code, no more 36 kHz carrier signal.
So, the way to use RC5 for a radio link should be: Use the GETRC5 command for receiving, but make your own RC5 Bascom code on the transmitter side. The difference being, that your own code does not use the 36 kHz Timer output, but simply switches an output pin (without the 36 kHz modulation).
The RC5send command was not always included in Bascom. Before it was added, a guy named Ger Langezaal had written an application note describing how to generate RC5. You may use parts of his code to generate a RC5 signal that is not modulated onto a 36 kHz carrier:
http://www.mcselec.com/index.php?option=com_content&task=view&id=69&Itemid=57
Happy hacking,
Ralf |
|
Back to top |
|
|
protoncek
Joined: 16 May 2011 Posts: 52 Location: Slovenia
|
Posted: Sat Feb 15, 2014 7:09 pm Post subject: |
|
|
Yes, you are correct. I will try your suggestion once. All options for reliable communication are still open for me, including some more complicated RF modules. I must eperiment some more and see what will be best.
If i manage to solve this IR method over radio, it willbe useful for many other things, too, so i will definitely keep working on this method.
Thanks for suggestion! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|