bensykes1984 / homeeasyhacking

Automatically exported from code.google.com/p/homeeasyhacking
0 stars 0 forks source link

Transmission of BBSB Advanced protocol unreliable #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Using the download attached to issue 7, I was having issues on an arduino nano 
(328) and not being able to transmit reliably. Putting a scope on the output 
seemed to suggest two problems:

1. the sync pulse at the beginning of the first packet being of variable length.
2. the polarity of the pulses being reversed on every transmission.

Two patches seem to make this work reliably for me for transmission on the 
advanced protocol:
1. reset the counter at start of initSending
2. don't toggle 0CxA on compare match

i.e. initSending becomes:

void HomeEasy::initSending() {
  // reset counter
  HE_TCNT = 0;

  // ensure the transmitter pin is set for output
  HE_TXDDR |= _BV(HETXPIN);

  // the value that the timer will count up to before firing the interrupt
  HE_OCRA = (pulseWidth * 2);

  // do not toggle OCxA on compare match, do it manually otherwise we get out of sync
  HE_TCCRA = 0;

  // CTC mode: top of HE_OCRA, immediate update of HE_OCRA, TOVx flag set on MAX
  HE_TCCRB |= _BV(HE_WGM2);

  // enable timer interrupt for HETIMER, disable input capture interrupt
  HE_TIMSK = _BV(HE_OCIEA);
}

Presumably the code could be tidied to remove the TCCRA assignments from 
everywhere from init.

Could someone else please check this?

Original issue reported on code.google.com by bruce3...@gmail.com on 10 Oct 2012 at 8:47

GoogleCodeExporter commented 8 years ago
Diff format for above

Original comment by bruce3...@gmail.com on 10 Oct 2012 at 9:25

Attachments:

GoogleCodeExporter commented 8 years ago
Bruce,

I've been away from this for a while (quite a long while!) due to other 
commitments, but am now back.

Thanks for your bug reports... and especially for the fixes!

I'm working on quite a significant refactoring, and will integrate your changes 
in the process.

When I've tested it and believe it to be ready, I will attach it to a comment 
here for you (and anyone else) to test.  Once that's happened, I can commit it 
to the SVN as I now have write-access.

Thanks again,
Nathan

Original comment by nbur...@gmail.com on 5 Feb 2013 at 9:39