0

Recompiled firmware-timing problem solved (maybe)
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Recompiled firmware-timing problem solved (maybe)

by WindyDay on Thu Jun 25, 2020 9:14 pm

(This was intended as a reply to an old post, but discussion on that topic was locked, so I'm creating a new post because I think I found a solution the problem raised. https://forums.adafruit.com/viewtopic.php?f=23&t=130881)

I wanted to modify v1.2 of the TV-B-Gone firmware. I was excited when I finally succeeded in re-compiling the code and flashing the ATtiny85 chip, but when I tested I couldn't get any TVs to turn off. (The device worked fine if I flashed with the original hex code, but not with the hex code that I created by recompiling.) User kandizzy's post referenced above pointed to a likely cause of the problem--timing differences in the transmitted signal. I made the following code change which seems to solve the problem (but I've only done limited testing, so I don't know if it will make all the IR codes work as well as with the original firmware).

In main.h line 22, I increased the delay count constant from 11 to 13 as follows:
Code: Select all | TOGGLE FULL SIZE
#define DELAY_CNT 13


The change was looking at the signal image posted by kandizzy and measuring the relative durations of the pulse sequences, from the original and kandizzy's compiled firmware. I came up with a ratio of 1.16 , meaning that the original pulse duration was 16% longer than kandizzy's, so I increased the original delay count by 16% and then rounded to the nearest integer. Given the limited precision available, it's easily possible that 12 or 14 would be better choices, but 13 seems to work for me. This could also depend on the specific compiler version used, I suppose.

For what it's worth, the compiler I used was the AVR-GCC build 10.1.0 x64 found at
Code: Select all | TOGGLE FULL SIZE
https://blog.zakkemble.net/avr-gcc-builds/
. Trying to figure out what compiler to use was really confusing to me, so any suggestions would be welcome. This was just a one-off fun little project for me, so this compiler seemed to do the job.

I should also note that in order to get the firmware to compile in the first place, I had to make the code changes in main.c related to constants, also referenced in kandizzy's post, and also get rid of references to sizebefore and sizeafter in Makefile.

WindyDay
 
Posts: 18
Joined: Sun Dec 22, 2019 10:20 pm

Please be positive and constructive with your questions and comments.