Manchester encoding library for RF links.

Hi Carl47,

I am using an ATtiny 85 (internal osc) for tx and an arduino with mega328 for rx. Using your examples all I get is 0s in the serial terminal. Any idea what I am doing wrong?

Thanks!

Hi Carl47,

I'm having the same problem Ciscoios.
What are we doing wrong?

Thank you.

When we get all 0's it could be anything.

My first guess would be hardware.

What rf devices are you using?

Do you have access to a CRO to see if data is going to the Tx or being received at the Rx.

Without lots more information I cannot be more explicit.

Cheers.

I have tried connecting a wire directly between RX and TX pins.. and a led for an indicator. TX transmits once a second. The RX (arduino) shows a 0 every second in the serial terminal. The output stops if I disconnect the wire.

I dont have a CRO.

Thanks !

It sounds as though something is being sent by the 85.

How do you program the 85, I use:

http://arduino.cc/forum/index.php/topic,59968.0.html

There is a pdf which describes how to set the fuse bits.

When you dump lfuse you should get E2 this gives:

8 Mhz on the internal clock.

I mention this because the example sends data every 0.1 sec not 1 sec.

Keep at it!

Thanks for the reply.

I know it must be something small (it always is)... I use arduino as ISP .. maybe that is setting a wrong fuse bit?

I will check and report.

Just to clarify. I changed the example to send once a second.

If you are thinking of using the ATTiny85 as the transmitter checkout:

This is an excellent article by mchr3k. He uses the 85 as the Tx with this manchester library.

Hello Carl47,
I tried your Manchester implementation and it works flawlessly, no dropouts. However, when I changed your example from 0.1 sec to a slower interval (0.2 sec, 1 sec or 2 sec), it had numerous dropouts. I then changed it from an interval driven to a pushbutton driven, and it works perfectly, virtually no dropouts. This is very puzzling. Initially I thought your Manchester class was fine-tuned for sending data at 0.1 sec interval, but since the randomness of a pushbutton works, my theory is obviously wrong.
Why is it not working with different time interval? Or I am doing something wrong?

RobertL

THE CODE HAS A BUG

This was discovered by mchr.

I wont update my code because mchr has done a great job on improving the library.

I would now direct anyone using this code to use his modifications:

The latest version of this library is now available from the GitHub repo linked from my latest blog post: Mchr3k - Arduino: Wireless sensor node - code management

I have now added interrupt driven message reception to the Manchester library. Full details are available here: Mchr3k - Arduino: Wireless sensor node - background rx (6)

Can you show us an example of the hardware? Which RF module?

I'm using the following RF components:

You can find similar parts on many sites. There is a picture of my breadboard setup in the blog post which I linked.

http://secure.oatleyelectronics.com//product_info.php?products_id=747&osCsid=60e2f6876e4457d624342ead0ffa1a0a

These run at 12 V and I get 2 miles
A little higher in frequency but getting the antenna the right length is critical to reduce noise in all of these devices and not enough emphasis is placed on this.

The louder the signal the less the noise in radio . You can always add a signal adjustment pot to turn it down !

The original code works for RX and TX on ATTiny85.
The new library doesn't work for RX under ATtiny85.

The only issue I had with the previous library the that the timeout didn't work on the receiver and it would block.

Great work!

This is gold to me. I have been considering rolling my own Manchester encoding library and was quite puzzled that there wasn't one available already.

A little bit unfortunate that it seems to have split/forked into two (carl47 original and mchr3k streams).

Am I right to assume that the preferred version if the new mchr3k version on Github? (as you seem to suggest in you comment above regarding the bug carl47).

Thanks for putting together and sharing!

Anders

yes, at this time I would recommend mchr3k version.

Thanks,
I figured so.

Have the new mchr3k version running now. Had some trouble getting it to work as his example code does not compile... :-/

On the other hand, most of them were minor errors.

Have put together a rig with a laser and a photodiode and sending Manchester encoded data across. Too bad it doesn't decode at this point. Need to do a whole lot of debugging now.

Anders

Hi,

And thank you very much for your work on maintaining this library.

I needed to use the library on an atmega8 but it didn't compile. So I tried changing the MANCHESTER.cpp file to add support for the Atmega8.

I have tested it as a transmitter at 8 and 16Mhz, transmitting about half a meter.

Warning: I am not a programmer, and this is the first time I have messed with timers and such. I just thought it would be nice to at least try to fix it myself instead of just adding an issue and waiting for others to fix it... I know nothing about github, sorry, so I don't know how to do push requests (or is that pull requests) and such. So I post it here instead.

I guess what it needs is a changed timer/interrupt settings to suit the Atmega8, but timers/interrupts/clocks and all that is very new and confusing to me. However, after a couple of hours studying the source code and the datasheet for the Atmega8 I came up with this addition to the .cpp file:

#elif defined(__AVR_ATmega8__)
  TCCR1A = _BV(WGM12); 
  #if F_CPU == 8000000UL
	TCCR1B =  _BV(CS12); 
  #elif F_CPU == 16000000UL
	TCCR1B =  _BV(CS12) | _BV(CS11); 
  #else
	#error "Manchester library only supports 8mhz, 16mhz on ATMega8"
  #endif
  OCR1A = 4; 
  TIFR = _BV(OCF1A); 
  TIMSK = _BV(OCIE1A); 
  TCNT1 = 0; 

#else

I just added it above the definition for the Atmega328, and to my big surprise, it seems to work.