Manchester encoding library for RF links.

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.

I know this is an old thread.

I was wondering, has anyone done any recent work on this? Is this still the prefered library to use when usinging multiple micro controllers and possible varying speeds?

Is there a way to send a string litteral with this library?

i am currently trying to find a way to communicate with a attiny 45 wirelessly from a arduino uno and cant seem to find any code that works i have tried Manchester but it does not compile it just keeps spitting out erros can anyone help me

hi diasr, im having problems too........im using attiny85 as tx and arduin uno as rx................ im confused as how to burn 8mhz bootloader? do use the high-low tech blog method or must i use daemillis core according to mch3k's blog

Hello World,

i want to connect between two arduinos, connected with a wire, per manchester code. Can anyone help me out what is wrong with the code?

Code for recieving:

int homo=13;
boolean empfangen;

void setup() {

Serial.begin(9600);
}

void loop(){
empfangen = false;

delay(1000);
Serial.println(homo);

/* do{

if(Serial.available() > 0){
homo = Serial.read();
empfangen=true;
}
}while(empfangen);

*/

Code for sending:

int incomingByte = 0; //einkommende Daten

void setup (){

//initialize serial
Serial.begin(9600); //definiert einen seriellen Port, Baudrate = 9600

}

void loop () {

if(Serial.available() > 0){
incomingByte = Serial.read();
/* incomingByte = incomingByte + 1;
Serial.println(incomingByte);
*/
}

Thanks for your help :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: :smiley: 8)

I download the manchester.zip library in my ardiuno but when i try to include it in code,it simply add blank line instead of #include <manchester.h>

CAn ı use this library with wire. I want to build a network with 250 slaves on 2 wire ring topology. And also powerup the slaves 24vdc from master on 2 wire . Each slave will have an id and respond if they are asked to.

İs it possible to send and recieve datas on a 24vdc 2 wire line with manchester coding.

İf so I ll start to work on it .

Thanks .

I2C, which Wire.h library supports, only works with with address 0 to 128, and some of those are reserved.