I'm trying to use Arduino IDE Serial Plotter and Monitor to do the same job as Saleae Logic analyser.
I can see the high and low signals from an underfloor heating system protocol in the logic analyser, and it decodes the manchester signal to hex as shown below.
Is there any library I can use to do similar with Arduino? I see some libraries for manchester decoding but the are for 1-Wire or I2C etc but not sure how to do for any old signal and ground wire protocol.
Thanks Tom, I have mchr3k's Manchester lib, but I'm not sure its decoding correctly for me.
#include <Manchester.h>
const int VOL_PIN = A0;
#define BUFFER_SIZE 22
uint8_t buffer[BUFFER_SIZE];
void setup(){
Serial.begin( 9600 );
man.setupReceive(VOL_PIN, MAN_9600);
man.beginReceiveArray(BUFFER_SIZE, buffer);
}
void loop(){
if (man.receiveComplete()) {
uint8_t receivedSize = 0;
//do something with the data in 'buffer' here before you start receiving to the same buffer again
receivedSize = buffer[0];
for (uint8_t i = 1; i < receivedSize; i++)
Serial.write(buffer[i]);
Serial.println();
}
}
This doesn't give me output to match the decoding in the Logic Analyser.
Some questions I have:
In LA, I need to use 4613 baud, but Ardunio only gives me (probably incorrect) output at 9600.
I only see monitor output when BUFFER_SIZE = 22. Any other size I try outputs nothing. Messages I'm reading are typically 26 bytes.
Any way to update the manchester.cpp to use 4613? I think maybe in this area, but don't understand any of it - 9600 baud uses timer scaling factor of 5.
/*
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