After trying many different avenues to get this to work on an ATtiny85, I found manchester libraries from mchr3k GitHub - mchr3k/arduino-libs-manchester , which looked promising.
However when I use the provided example sketch "ManchesterTX_Basic" and select ATtiny85 (internal 8MHz clock) as the board and "Arduino as ISP" as the programmer, I get the following errors.
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp: In function 'void MANRX_SetupReceive(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:366: error: 'TCCR2A' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:366: error: 'WGM21' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:371: error: 'TCCR2B' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:371: error: 'CS21' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:371: error: 'CS20' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:372: error: 'OCR2A' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:379: error: 'TIMSK2' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:379: error: 'OCIE2A' was not declared in this scope
C:\Program Files (x86)\Arduino\libraries\Manchester\Manchester.cpp:380: error: 'TCNT2' was not declared in this scope
A closer look at Manchester.cpp shows the offending lines as
#if defined( __AVR_ATtinyX5__ )
<lots of lines of good code in here>
.
.
.
#else // ATmega328 is a default microcontroller
/*
Timer 2 is used with a ATMega328.
http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf page 162
How to find the correct value: (OCRxA +1) = F_CPU / prescaler / 1953.125
OCR2A is only 8 bit register
*/
TCCR2A = _BV(WGM21); // reset counter on match
#if F_CPU == 1000000UL
TCCR2B = _BV(CS21); // 1/8 prescaler
OCR2A = (64 >> speedFactor) - 1;
#elif F_CPU == 8000000UL
TCCR2B = _BV(CS21) | _BV(CS20); // 1/32 prescaler
OCR2A = (128 >> speedFactor) - 1;
#elif F_CPU == 16000000UL
TCCR2B = _BV(CS22); // 1/64 prescaler
OCR2A = (128 >> speedFactor) - 1;
#else
#error "Manchester library only supports 8mhz, 16mhz on ATMega328"
#endif
TIMSK2 = _BV(OCIE2A); // Turn on interrupt
TCNT2 = 0; // Set counter to 0
#endif
This tells me the that AVR_ATtinyX5 is not defined and I have googled all over but can't find anything to tell me where that should be defined and how to go about it.
If anyone can tell me what I've done wrong and/or how to define AVR_ATtinyX5, I'd be most grateful.
The easy way is to just edit the offending file to give you the code you want. Ot you could add the line #define __AVR_AT etc to the file.
Its not by the the way a compiler directive.
Thanks Mark, I took your advice and modified MANCHESTER.cpp as you described. That by itself didn't work because it's needed by the UNO sketch as well. So I ended up making a copy of MANCHESTER.cpp and MANCHESTER.h, renamed the copies to TINYMANCHESTER and saved them in a separate folder. Now the code that runs on the ATtiny85 includes "tinymanchester.h" and the UNO code includes "manchester.h" and all is well.
So now I'm messing about with 173mm straight antennae and longer coiled antennae to try to minimise the size of the transmitter and maximise the distance. So far I can transmit 18m (60ft) through walls with a 375mm coiled transmitting antenna and a 173mm straight receiving antenna and I get about 50% signal failure at 1200 baud.
Requires more experimenting with baud, antennae and distance ...... Oh and then there's error checking/correction to investigate to try to beef up the reliability.
Sorry this is a bit late, had a cyclone and power went out. Just turned my PC on and chrome asked if I want to reopen the last pages, which was this
I have a solution maybe.
I have been using the GP registers for some optimized routines and one thing I've noticed is all/most AVR chips have 3 GPIO registers, but only one is within range of sbi/cbi. However all GPIO registers are in range on an ATTiny
This worked fine in IDE 1.0.5.
However this code did not work in the 1.5.5 r2 IDE, the Atmel provided GPIORx defines seem to be missing or renamed to something else, will investigate later.
From a practical perspective it makes no difference. But, if someone were to ever use the comparison snippet for testing the sbi/cbi range it does make a difference.
The EEPROM address register L/H are at 0x1E & 0x1F, so the check could be useful ( and requires '<=' ). The Uno registers are out of range, and can also be used to check for a tiny.
Got the same problem using this lib with a 8 MHz Trinket, but managed to solve it by adding #define __AVR_ATtinyX5__ to the file hardware/attiny/variants/tiny8/pins_arduino.h. I'm using the Adafruit support package for ATtiny. Perhaps a bit of a hack, but I can switch to building for the UNO, by selecting board in Arduino IDE 1.0.5.
PeterDollar:
Thanks Mark, I took your advice and modified MANCHESTER.cpp as you described. That by itself didn't work because it's needed by the UNO sketch as well. So I ended up making a copy of MANCHESTER.cpp and MANCHESTER.h, renamed the copies to TINYMANCHESTER and saved them in a separate folder. Now the code that runs on the ATtiny85 includes "tinymanchester.h" and the UNO code includes "manchester.h" and all is well.
So now I'm messing about with 173mm straight antennae and longer coiled antennae to try to minimise the size of the transmitter and maximise the distance. So far I can transmit 18m (60ft) through walls with a 375mm coiled transmitting antenna and a 173mm straight receiving antenna and I get about 50% signal failure at 1200 baud.
Requires more experimenting with baud, antennae and distance ...... Oh and then there's error checking/correction to investigate to try to beef up the reliability.
Thanks again bud.
Please help. I am so desperate. By reading your post, it looks simple, but I am getting still the same message as mentioned above. Tried to add #defineAVR_ATtinyX5 at various place in Manchester.h, but still does not work. Please tell me exactly how to make it if possible. Thank you in advance.
jogco:
Got the same problem using this lib with a 8 MHz Trinket, but managed to solve it by adding #define __AVR_ATtinyX5__ to the file hardware/attiny/variants/tiny8/pins_arduino.h. I'm using the Adafruit support package for ATtiny. Perhaps a bit of a hack, but I can switch to building for the UNO, by selecting board in Arduino IDE 1.0.5.