Code Monkey home page Code Monkey logo

arduino-libs-manchester's People

Contributors

baselsw avatar bkconrad avatar bredita avatar caoxp avatar endail avatar hjf avatar jcmk avatar mchr3k avatar nighthawk6389 avatar onegulin avatar paulenuta avatar per1234 avatar rmd6502 avatar tonyputi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-libs-manchester's Issues

Readme errors

There are some error in the readme:

For receiving 16 bits of data at a time:

void setup()
{
// Set digital TX pin <-- Set digital RX pin
MANRX_SetRxPin(4);
// Prepare interrupts
MANRX_SetupReceive();
// Begin receiving data
MANRX_BeginReceive();
}

For receiving arrays of 8 bit values:

unsigned char bufferSize = 10;
unsigned char bufferData[bufferSize];
void setup()
{
// Set digital TX pin <-- Set digital RX pin
MANRX_SetRxPin(4);
// Prepare interrupts
MANRX_SetupReceive();
// Begin receiving data
MANRX_BeginReceiveBytes(bufferSize, bufferData);
}

For sending data:

void setup()
{
MANCHESTER.SetRxPin(4); <-- MANCHESTER.SetTxPin(4);
MANCHESTER.SetTimeOut(1000);
}

2 kBaud speed

Hi

My chip have 2kbaud speed (2000 Baud). How I can set this speed ?

In example is only 1200 or 2400

(I use ESP 8266)

Jarek

Linux porting

I need to use it between an embedded linux transmitter and an Arduinio receiver.

Does exists a porting for linux?

Regards,
Antonio

receiveComplete() never true

I am at a loss here: my receiver logic is close to that of the examples:

#include <Manchester.h>

#define ALERT 13
#define DATA_433 4

uint16_t packet;
uint16_t last_packet;

void setup() {
  pinMode(ALERT, OUTPUT);
  digitalWrite(ALERT, LOW);
  man.setupReceive(DATA_433, MAN_1200);
  man.beginReceiveArray(2, (uint8_t *)&packet);
  last_packet = 0x2f3a;
  Serial.begin(9600);
  Serial.println("");
}
void loop() {
  Serial.println(packet, HEX); // #1 - see below
  if (man.receiveComplete()) 
  {
    Serial.println(packet, HEX); // #2 - see below
    if(packet!=last_packet)
    {
      if(packet&0x4000) digitalWrite(ALERT, HIGH);
      last_packet = packet;
    }
    man.beginReceiveArray(2, (uint8_t *)&packet);
  }
}

the first Serial.println() (marked #1) in the loop bravely prints out the received packet, whereas #2 never prints anything at all. So it looks like receiveComplete() never is true.

What am I missing here?

Receiver is an Arduino Nano, if that matters.

It's doesn't work under attiny25

(attiny85 too)because:

define F_CPU 8000000UL

if defined( AVR_ATtinyX5 )

...

if F_CPU == 8000000UL

  __TCCR1 = _BV(CTC1) | _BV(CS12) | _BV(CS11) | _BV(CS10);__ // 1/64 prescaler
  __OCR1C = (64 >> speedFactor) - 1;__ 

...
OCR1A = 0; // Trigger interrupt when TCNT1 is reset to 0
TIMSK |= _BV(OCIE1A); // Turn on interrupt
TCNT1 = 0; // Set counter to 0
interrupt does not occur. If OCR1A > 0 It's occur, but It's work not correct

Recent merge breaks for all but ESP

Commit 6d00177 breaks this library for attiny85, at328p and atmega32u4, and probably all non ESP boards.

I get the following errors

.piolibdeps/Manchester/Manchester.cpp: In member function 'void Manchester::setupTransmit(uint8_t, uint8_t)':
.piolibdeps/Manchester/Manchester.cpp:92:49: error: 'compensationFactor' was not declared in this scope
delay1 = (HALF_BIT_INTERVAL >> speedFactor) - compensationFactor;
^
.piolibdeps/Manchester/Manchester.cpp: In function 'void MANRX_StopReceive()':
.piolibdeps/Manchester/Manchester.cpp:490:24: error: 'timer' was not declared in this scope
timerDetachInterrupt(timer);
^
.piolibdeps/Manchester/Manchester.cpp:490:29: error: 'timerDetachInterrupt' was not declared in this scope
timerDetachInterrupt(timer);
^

RX does not work with ATTiny85

The ATTiny85 code consistently fails to read Manchester encoded input from a 433Mhz RF receiver. I've modified the intiialization so that it compiles:

  TIMSK |= _BV(OCIE1A); // Turn on interrupt

rather than

  TIMSK1 |= _BV(OCIE1A); // Turn on interrupt

however, the ISR method never exits RX_MODE_SYNC, as the following block on Manchester.cpp line 284, is always executed:

        if(((rx_sync_count < 20) || (rx_last_sample == 1)) && 
           ((rx_count < MinCount) || (rx_count > MaxCount)))
        {
          // First 20 bits and all 1 bits are expected to be regular
          // Transition was too slow/fast
          rx_mode = RX_MODE_PRE;
        }

RX support for Attiny84

Hi, it seems the library does not works on Attiny84 RX mode. I thought maybe is a problem with the timer compare match or the interrupt call. The basic code works fine for TX but does not runs on RX mode, its never enters into the if (man.receiveComplete()){} loop, so, the attiny never recives data.

Can you help me to resolve this problem?. Currently I work on fix it but I do not understand yet how the library works at all.

Thanks!!

Messages Sent simultaneously from more than 1 transmitters are not recived properly at reciever.

I am using this library and found it great at first sight, but i am getting into trouble when i have more than one transmitter. Sending data with different sender ids. But when i check in the reciever, many times i am not recieving messages from both the transmitters. It seem to drop few messages and i doubt if the no of tranmitter increases, no of dropped messages will increase even more ?
Is there any solution for this problem in the library ? or am i doing something wrong. ?

Does this library still working ?

Hi, I simply wanted to transmit a ON/OFF flag to an alarm, but it seems much more difficult than expected...

I made the example code tests with Arduino UNO first. Then, the objective will be to use ATtiny85.

However this library does not seem to work anymore, as I suppose it was working before 2020.....
2 notes:

  • I also tested RCSwith.h, nothing is working.
  • VirtualWire that is supposed to be old (and so obsolete) still works fine. I use it with success for other projects. But it does not support ATtiny85 :(

IDE version 1.8.13, is it the reason ?

RX not working when using ATtiny at 1MHz

The ATTiny85 code fails to read input from a 433Mhz RF receiver when working at 1MHz. The following example compiles perfectly and runs OK wihen the ATTiny85 is working at 8MHz. However, it compiles but does not receive anything (the LED connected in pin 3 does not toggle) when working at 1MHz. Any advice to solve this problem?

#include <Manchester.h>

#define LED_PIN 3
uint8_t moo = 1;

#define TX_433_PIN 0
#define RX_433_PIN 1

#define BUFFER_SIZE 10
uint8_t buffer[BUFFER_SIZE];

void setup() {
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, moo);
  man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
  man.setup(TX_433_PIN, RX_433_PIN, MAN_1200);
  man.beginReceiveArray(BUFFER_SIZE, buffer);
}

void loop() {

  if (man.receiveComplete()) {
    man.stopReceive();
    moo = ++moo % 2; digitalWrite(LED_PIN, moo);
    man.beginReceiveArray(BUFFER_SIZE, buffer);
  }

}

Unable to receive message on Attiny85 when sent from Arduino uno

Greetings,

I am working on a small project where I have to transmit a char array from Arduino Uno and receive it on Attiny85.

I am using 433Mhz transmit/receive modules and your library (thanks for developing it).

To keep it short, it works if I transmit and receive on Arduino Unos, also works to transmit and receive between 2 Attiny85s, but I cant get Attiny85 to listen to messages sent from Arduino Uno.

I have tried 1Mhz and 8Mhz speeds and bootloader flash (using Sparkfun tiny avr programmer). Tried all available baudrates including lower ones 300, 600.
Tried powering Attiny from 2 different power sources of 5V.
Also tried several Attiny and receiver to exclude any hardware mulfunction.
Blinky code works fine on attiny and delay() is not that much off from real perception. Let's say delay(1000) is not perfectly 1 sec, but within reasonable deviation.
man.receiveComplete() is never triggered on Attiny85 if I am transmitting from Arduino Uno.
I suppose I am using the right attiny core because it works between two Attiny85s.

I find couple of articles saying that it is probably due to controller speed, but then I also see "With this library you can sucessfully transmit data between various microcontrollers runnning at various speeds even if their clock speed varies up to 100%. "

Code for Transmitter (Arduino Uno)

#include <Manchester.h>
#define TX_PIN 7 //pin where your transmitter is connected
#define LED_PIN 1
#define BUFFER_SIZE 7
uint8_t TX_PAYLOAD[] = {BUFFER_SIZE,'1','2','3','a','b','c'};

void setup() {
  man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
  man.setupTransmit(TX_PIN, MAN_600);
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  man.transmitArray(BUFFER_SIZE, TX_PAYLOAD);
  digitalWrite(LED_PIN_1, HIGH);
  delay(200);
  digitalWrite(LED_PIN_1, LOW);  
  delay(500);
}

Code for Attiny85

#include "Manchester.h"
#define RX_PIN 0
#define LED_PIN_1 1

void setup() {
  pinMode(LED_PIN_1, OUTPUT);
  man.setupReceive(RX_PIN, MAN_600);
  man.beginReceive();  
}

void loop() {
  if (man.receiveComplete()) {
      digitalWrite(LED_PIN_1, HIGH);
      delay(200);
      digitalWrite(LED_PIN_1, LOW);      
      man.beginReceive(); 
  }
}

Meanwhile I would like to know if this is a common issue? anybody has come across with same?

Thanks in advance
Sergi

Cant get to work on 32U4

Hello all, kind of urgent issue.

Great library, and I'm using lots on Attiny85's and 328 Uno, but for the life of me I can't get it to receive on the 32U4.

Am I missing something?

Cheers

Ben

Can't run with atmega8

Hi!
First I think one line for the atmega8 is missing here
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

if defined( AVR_ATtiny45 )

ISR(TIMER1_COMPA_vect)

elif defined( AVR_ATtiny84 )

ISR(TIM1_COMPA_vect)

elif defined(AVR_ATmega32U4)

ISR(TIMER3_COMPA_vect)

// this line is a must, otherwise the chip stops at once

elif defined(AVR_ATmega8)


ISR(TIMER1_COMPA_vect)

else

ISR(TIMER2_COMPA_vect)

endif

+++++++++++++++++++++++++++++++++++++++++++++++++++++++
After inserting the line, the code in the function TIMER1_COMPA_vect
is used. But the atmega8 and the Attiny84 is not working.
I use it with an Attiny45 and an Arduino with an Atmega328, which works.
I have tried to find an error, but I am quite new, and not good enough.
May be some one made it. Would be great.
Greatings KK

Pulse width modulation

Hi,

I'm using the manchester library for a simple Visible Light Communication setup. Instead of a wired connection I use an LED as transmitter and a photodiode with a pull-down setup at the receiver. Works fine so far but now I would like to incorporate LED dimming through pulse width modulation.

I was wondering how to approach pulse width modulation for this library? I see the variable "delay1" and "delay2" in the .cpp file (line 85-86). If I add additional variables to shift the pulse width would that work? Do I overlook something? How would it affect the receiving?

Cheers
Charles

Attiny2313 Support

Hello,

I've got the library building for the atiny2313, however I can't get the chip to actually receive anything. I'm very new to AVR-C and I'm not sure if I've got a hardware or a software problem, so I was wondering if you (or anyone else) could verify the register flags I'm using:

#elif defined( __AVR_ATtinyX313__ )

#if F_CPU == 1000000UL
  TCCR1A = _BV(WGM12); // reset counter on match
  TCCR1B =  _BV(CS11); // 1/8 prescaler
  OCR1B = (64 >> speedFactor) - 1; 
#elif F_CPU == 8000000UL
// ...
#else
#error "Manchester library only supports 1mhz, 8mhz, 16mhz, 16.5Mhz clock speeds on ATtiny85 chip"
#endif

OCR1A = 0; // Trigger interrupt when TCNT1 is reset to 0
TIMSK |= _BV(OCIE1A); // Turn on interrupt
TCNT1 = 0; // Set counter to 0

I'm only using the 1Mhz clock rate for now, but once I get that working I'd be happy to get the constants for the other speeds.

Strange behaviour with Serial.begin

Hi,

First of all, thanks for your great work :)

I have an issue with the library. I'm using an Arduino UNO to receive data. In fact it doesn't work so I want to debug the program.

So I added this code :
image

In the Serial Monitor I get this :
image

What I seen is it is this statement wich make it crazy :

man.setupReceive(RX_PIN, MAN_1200);

Do you have any idear how can I use the Serial Monitor with your library ?

Regards,

ps: sorry for my poor english

Manchester library with ATtiny84

Hello,
I try to use the ATtiny84 with Manchester library as a receiver, and it did not work, I try to solve the problem.
Finaly I succeed, I belive that there a small missing part in the library.
In the ATtiny84 the timer is set by TCCR1B bits WGM13, WGM12, and this is handled in the library, but the 'Waveform Generation Modes' is with two more bits : WGM11, WGM10 in TCCR1A, these bits are not set in the library.
I added this line to the Manchester.cpp : TCCR1A = 0; this set the WGM11, WGM10 to 00, and to 0100 for all 4 bits (WGM13, WGM12, WGM11, WGM10) , I use the ATtiny84A 8MHz
refer to datasheet ATtiny84A table 12-5
Please check and maybe you will fix this for others to enjoy this library with the ATtiny84 as a receiver.

Avi

Missing Too many messages

I am using Arduino Genuino Uno Board for transmitter and receiver with 430Mhz transmitter receiver pair. I am using the exmaple code given with the library. To tranmit and receive an array.
But out of messages sent - For ex - {1}, {1,2}, {1,2,3}, {1,2,3,4}...
On the receiver end i am receiving only few of them - {1}, {1,2,3,4}...
What should be the optimal baud rate for atmega328 ?
I am using MAN_300...

Can't transmitt on attiny85 @1Mhz

Here is my bootloader config:

Clock: "1 Mhz (internal)"
LTO: "Disabled"
B.D.O Level: "B.D.O Disabled"
Timer 1 clock "CPU"
Save EPPROM: "EPPROM retained"

Here's my code:

#include <Manchester.h>

#define TX_PIN 3

uint8_t data[20] = {11, '1','2', '3', '4', '5', '6', '7', '8', '9','1','2','3','4','5','6','7','8','9'};

void setup() 
{
  pinMode(0, OUTPUT);
  digitalWrite(0, HIGH);
  man.workAround1MhzTinyCore(); //add this in order for transmitter to work with 1Mhz Attiny85/84
  man.setupTransmit(TX_PIN, MAN_300);
  digitalWrite(0, LOW);
  delay(2000);
}
 
uint8_t datalength=2;   //at least two data
// the loop function runs over and over again forever
void loop() 
{
  data[0] = datalength;
  
  digitalWrite(0, HIGH);
  man.transmitArray(datalength, data);
  delay(100);
  man.transmitArray(datalength, data);
  delay(100);
  man.transmitArray(datalength, data);
  digitalWrite(0, LOW);
  
  delay(5000);
  datalength++;
  if(datalength>18) datalength=2;
}

And the attiny dosnen't transmit when I use the 1Mhz however when I select 8MHz i works fine. Any idea ?

Not working on esp8266 esp-12e

I have receiver and transmitter. Transmitter is arduino. Receiver is esp-8266. I used your code example, and tried to connect the receiver and the transmitter. But they are not connected between themselves! But all working good when both devices are aruduino!

Receive may not change data

Hello, thank you for your code. It was very useful for some experiments with Conrad TX-01 temperature sensor although i had to make some changes)

I found that the receive code can sometimes not change the output data.

The bug is that the variable rx_curByte is incrementend correctly in the AddManBit function but only initialized on the program start.

It must be reseted when a complete receive is completed.

the following code resolves the problem (in the ISR):

...
if ((rx_sample == 1) &&
(rx_curByte >= rx_maxBytes))
{
rx_mode = RX_MODE_MSG;

		//get ready for next receive !
		rx_curByte = 0;
		rx_manBits=0;
        
      }
      else

...

38400kbaud possible on any board?

Hi

I have a Manchester bus that I would like to tap in on at 38.4kbaud.
I have an Arduino Mega ADK. Will that be fast enough to manage?
If not, what board will be, or is this speed just too high?

Thanks, Thomas

It doesn't work with certain digital pins

Hi,
I'm using this library to transmit certain numbers from one arduino to another. It works perfectly with digital pin 2 and 3. I want to use other digital pin as well, but it didn't work with any other digital pins.
Please, tell me if I'm missing something. I'm using Uno.
This is the code.
capture1

Can't compile for ATtiny84

This happens when compiling for the ATtiny84 using cores found here:
https://github.com/damellis/attiny/

Apparently, the compiler directives should then be altered in Manchester.cpp in MANRX_SetupReceive().

AVR_ATtinyX5 should become AVR_ATtiny85
and
AVR_ATtinyX4 should become AVR_ATtiny84

If not, the library is compiled as if it's for an ATmega328, while the ATtiny84 does not have Timer 2.

Transmit/getMessage don't work. Fixed.

Fixed by my changes. Don't really know how to use github though, so email/msg me for details if it isn't showing up. Essentially changed both to 8 bit as intended and changed the transmit function code to: uint8_t byteData[2] = {2, data};
transmitArray(2, byteData);

Arduino Due

Hello,

What should change to work in arduino due?.

Thanks

Attiny25/45/85 @ 16MHz internal clock

Hi!

I have absolutely no idea what kind of voodoo magic you've used in creating this library (I'm new to C programming), but can you please update it to work with the 16MHz internal clock setting on tiny25/45/85?
I think it works fine as it is but the delay becomes half of what it's set to (because of the 2x clock speed).

Cheers
Andrei

Cannot send numbers >255 between ATTiny85 and Arduino Uno

I have an ATTiny85 connected to an 315MHz transmitter and an Arduino Uno connected to an 315MHz receiver. I tried to send a number 511 (2^9 - 1, or 0b111111111 in binary) but the number received by Arduino is always 255, or 0b11111111. I tried MAN_600,1200,2400 and 4800. For attiny85 I tried both SpenceKonde and Damellis implementations. I'm on Arduino IDE 2.2.1
code for ATTiny85:

#include <Manchester.h>
#include "tinysnore.h"

#define TX_PIN 4
//#define TRIG 2
//#define ECHO 3
// int du;
uint16_t data = 511;

void setup() {
  // put your setup code here, to run once:
  man.setupTransmit(TX_PIN, MAN_2400);
  pinMode(ECHO,INPUT);
  pinMode(TRIG,OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  // digitalWrite(TRIG,LOW);
  // delayMicroseconds(4);
  // digitalWrite(TRIG,HIGH);
  // delayMicroseconds(20);
  // digitalWrite(TRIG,LOW);
  // du = pulseIn(ECHO,HIGH) * 10 + 1;
  man.transmit(data);
  snore(1000);
}

And for Arduino Uno:

#include <Manchester.h>

#define RX_PIN 11

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  man.setupReceive(RX_PIN,MAN_2400);
  man.beginReceive();
}

void loop() {
  // put your main code here, to run repeatedly:
  if (man.receiveComplete()) {
    uint16_t m = man.getMessage();
    Serial.print(m);
    Serial.println();
    man.beginReceive(); //start listening for next message right after you retrieve the message
  }
}

Manchester Coding in G E Thomas conventions

Dear Team
I want to use the Manchester Library with Arduino, but I found out that it Supports only IEEE802.3 convention.
Is there any possibility to modify to make it applicable for G.E Thomas Convention also..
Thanks

Add support for ATTiny167

I need to use the library with the Attiny167 micro, I use the arduino core: ATTinyCore

But it does not take the micro model, I wanted to insert the code so that it recognizes it inside the library, but it does not work it continues giving error:
error: 'TCNT2' was not declared in this scope
Code.

#elif defined( __AVR_ATtiny167__) || defined(attinyx7)

    /*
    Timer 1 is used with a ATtiny87/167. 
   
    How to find the correct value: (OCRxA +1) = F_CPU / prescaler / 1953.125
    OCR1A/B are 8 bit registers
    */

    #if F_CPU == 1000000UL
      TCCR1A = 0;
      TCCR1B = _BV(WGM12) | _BV(CS11); // reset counter on match, 1/8 prescaler
      OCR1A = (64 >> speedFactor) - 1; 
    #elif F_CPU == 8000000UL
      TCCR1B = _BV(WGM12) | _BV(CS12) | _BV(CS11) | _BV(CS10); // 1/64 prescaler
      OCR1A = (64 >> speedFactor) - 1; 
    #else
    #error "Manchester library only supports 1mhz, 8mhz clock speeds on ATtiny87/167 chip"
    #endif
    
    OCR1B = 0; // Trigger interrupt when TCNT1 is reset to 0
    TIMSK |= _BV(OCIE1B); // Turn on interrupt
    TCNT1 = 0; // Set counter to 0	

I don't know what's wrong, someone can help me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.