Battery saving TV-B-Gone with region/range selection switches by JeonLab
Featured
assembled TV-B-Gone_JeonLab 2.JPG
1st TV-B-Gone with supercaps.jpg
What is the TV-B-Gone?
TV-B-Gone is a small gadget that can turn on and off virtually any TV in the world developed and sold as a kit by Adafruit. They also provide the source code and compiled firmware under Creative Common Share Alike license.
I would like to thank original developers at Adafruit for this great work and sharing ideas before starting showing my modification.

First trial
At first, I downloaded the firmware v1.1 and flashed an ATtiny85-20 and made it with only one transistor and two wide angle IR LEDs with two supercaps as shown below. The switch is connected to the supercap + so it will beam only when you press the button.  It worked fine, but the problem was it drained the supercaps too quickly. The first reason is, of course, low capacity (compared to batteries) of the supercaps, but there are other reasons, too. I didn’t have a resonator at 8MHz, so I burned the oscillator selection fuse bit of the ATtiny85-20 as internal 8MHz. The internal oscillator has benefits of omitting an external component and programmable, but there are serious down side; its frequency can be unstable and varies depending on the temperature and power supply, AND it consumes more power at high frequency settings.

After this first trial, I added a 8MHz ceramic resonator and uploaded v1.2 firmware on an ATtiny85V-10 and found it can last double the time than ATtiny85V-20 using internal oscillator. One full cycle of pulsing all the codes takes a little less than a minute and with this latest testing configuration, more than 30 times of full cycle worked with 2 supercaps before the voltage dropped below 1.7V (two in series).

Need to save battery
I have thought about to turn off the device before the full cycle finished once it either turn on or off a TV. Adafruit's firmware database is designed as the codes for popular TV models emits first.  So in most cases, long before it emits all the codes, my target TV is turned on or off.  I thought about to add a power switch but that wasn’t very attractive to me.

Idea and solution!!
A couple days later, I suddenly got a good idea to utilize the Region Detection pin (pin6 of the ATtiny85v). Once the program detects the region from the level of pin 6 (float (internal pull-up): US, pull-down: EU), it is not used any more until all the codes pulsing is finished. So, in US mode for example, after it started pulsing and when you want to stop it, forcing the pin6 to ground will exit the do loop in software and the device will go sleep. I tested both US and EU mode with modified code and worked fine. This way, you can save battery.

Here in this introduction, I included a picture of the assembled TV-B-Gone JeonLab, but the circuit, which will be shown and explained step by step, is quite simple, so you may be able to assemble one on any prototype board or even on a bread board. 



 
Remove these adsRemove these ads by Signing Up

Step 1: Circuit modification

TV-B-Gone_JeonLab circuit_US.jpg
TV-B-Gone_JeonLab circuit_EU.jpg
TV-B-Gone_JeonLab circuit_UNI.jpg
The original design of the TV-B-Gone by Adafruit uses the pin 6 of ATtiny85v as region detection.  With a 10k pull-down resistor connected to the pin 6, the device generates codes for European TV models. Otherwise, floating the pin 6, it works for North American models and most Asian models as well. 

There are three circuits showing in this step: North American (US) models only, European (EU) models only, and all-in-one model with region selection switch.

The PCB I made and showed in the Intro section is the all-in-one model.

As you can see in the circuit diagram, the NA (or US) model has no pull-down resistor on the pin 6.  When you successfully turn on or off a TV in the middle of code generation (the visible LED blinking), simply push the button S2 will pull the pin 6 to the ground and the firmware will stop the process and go to sleep mode which doesn't consume the battery.

However, in EU model, the pin 6 is grounded by the pull-down resistor, R3, 10k, always.  But pulling up the pin 6 by pressing the button S2 and connect to Vcc, the modified firmware will stop the process and sleep.

The UNI (all-in-one, NA+EU) model simply has both in one by adding a slide switch.
1-40 of 72Next »
Electo4fun says: Mar 2, 2013. 3:06 PM
I've been able to get the files into the Arduino IDE now but when I verify them or try to upload the IDE gives these errors:
"main.c: In function 'main':
main.c:317: error: 'for' loop initial declaration used outside C99 mode"
It then highlights this part of code:
"// For EACH pair in this code....
for (uint8_t k=0; k uint8_t ti;"
I am not very experienced in C so I don't know how to fix this myself.
JeonLab (author) says: Mar 3, 2013. 12:10 AM
What code did you mean? Did you download Adafruit's source code and modified as my instruction and compiled to make it hex file? So did you try to upload the compiled hex file to ATtiny85 using the Arduino IDE and got that error from AVRDUDE? Please be a little bit more specific. If you compiled the code into hex file, please take a look at my blog page (http://jeonlab.wordpress.com/2011/11/20/jeonlab-mini-attiny-programmer-using-arduino-isp/) or my another Instructable (http://www.instructables.com/id/ATtiny-programmer-using-Arduino-ISP/) for uploading it. There are also useful links you can follow.
Electo4fun says: Mar 2, 2013. 7:19 PM
I downloaded the code from your link, and then modified it using notepad. I then loaded the files into the Arduino IDE. I don't know how to compile the hex file. I have attached two pictures to this post, one showing how I loaded the code files to the Arduino IDE and another showing the files that actually loaded. The *.hex file did not load into the IDE. I have checked both of the links provided but my problem is the *.hex file and loading it to the IDE.
Loaded Files.pngOpening Files.png
JeonLab (author) says: Mar 3, 2013. 4:52 PM
I found my explanation on how to compile and how to upload was not enough for those who are not familiar with AVR programming. I didn't elaborate because this article was focused on the TV-B-Gone modification. Anyhow, let me explain a little more about compiling and uploading.
1. Download WinAVR (http://sourceforge.net/projects/winavr/files/latest/download?source=files) and install.
2. Browse into where the WinAVR is installed: Start-All programs-WinAVR-20100110 and run Progrmmers Notepad
3. Open the source code and edit
4. Open the MAKEFILE and edit it (follow instruction in the post from my blog: http://jeonlab.wordpress.com/2011/11/22/makefile-setting-for-the-attiny4585-programmer-with-jeonlab-mini-or-arduino/
5. Go to Tools menu and click [WinAVR] Make all to compile. If you have any problem with compiling, look closely this MAKEFILE.
6. Now I assume you already have any kind of programmer (not software but a physical device to put your Attiny85 chip and connect it to your computer such as the one I introduced (http://www.instructables.com/id/ATtiny-programmer-using-Arduino-ISP/) or DASA or any other commercial product.
7. Insert an Attiny85 chip on the programmer and hook it to your computer.
8. From the Progrmmers Notepad, go to Tools and click on [WinAVR] Program to upload the hex file.
That's it!
Good luck.
Electo4fun says: Apr 11, 2013. 11:45 AM
Sorry for the long wait, but I have one last question about programming this. When you program the Attiny85, for the tv-b-gone, do you need to include the ceramic resonator? And does the attiny85 20pu vs attiny85v 10pu work?
JeonLab (author) says: Apr 11, 2013. 3:46 PM
Yes, I have the resonator on my programmer. And yes, both 10pu and 20pu worked in my experience.
Electo4fun says: Mar 3, 2013. 5:41 PM
When I tried to upload the program using WinAVR, Arduino as programmer (after finishing 1-7) it returned an error saying:
avr dude_ getsync: not in sync
I tried other setups using Arduino IDE to upload a Blink sketch and it returned these errors:
Access is Denied com3
File not found
I am not sure what the problem is, but I think it lies within my Arduino. I will purchase a USBtiny ISP and try this again.
JeonLab (author) says: Mar 2, 2013. 7:42 PM
Oh. The source code is not Arduino sketch. You need WinAVR to compile it. Arduino is used to upload the compiled hex file.
Electo4fun says: Mar 3, 2013. 3:59 PM
One last question about compiling the hex file, when I open WinAVR there is a simple looking GUI. I then try to open what file? I have tried opening the hex file but it says it doesn't have debug information. I have tried the other files as well but only the *.o files open? Is there a command line command that will compile the *.hex file?
JeonLab (author) says: Mar 3, 2013. 1:34 PM
Open the source code, main.c, not hex file. Once you compile it properly, it will generate main.hex. You don't need to locate this file to upload. The WinAVR (programmers notepad) will do the job.
Electo4fun says: Mar 2, 2013. 2:39 PM
How can I load the code files into the Arduino IDE? I have them edited as it says above but I can't find a way to open them.
furrysalamander says: Feb 26, 2013. 6:09 PM
I'm working on my own variant. Can you help me design it? I want the capabilities of all the codes from v1.2, but keep the hardware really simple. I'm wondering if I can do it with only the microcontroller, capacitor, resonator, button, and this.  If this is possible, please let me know, and I have one other thing I want to do.  I want it to run when I hold down the button, rather than just clicking it.  Please show me where everything goes, I'm still a noob, and it's for my best friends birthday, on march 13th.  I'm stuffing it inside a sonic screwdriver.  :D  Please reply asap, I need to order soon and she's going to love this present.
JeonLab (author) says: Feb 26, 2013. 6:33 PM
Probably you will need other design than mine or Adafruit's. There are a number of variants of the TV-B-Gone here in Instructables with only one LED for small form factor which you can easily put it in the screw driver you mentioned. I think the ir led from Sparkfun will work fine. As for the switch, simply use a power button. As long as you push the power switch, it will emit the code.
Good luck.
furrysalamander says: Feb 26, 2013. 7:19 PM
Will this work with the v1.2 software?  Double check everything.  If I understand it right, it should also transmit codes only when the button is held down.
schemeit-project.png
JeonLab (author) says: Feb 26, 2013. 7:39 PM
http://jeonlab.wordpress.com/tv-b-gone-mod/tv-b-gone-mod-v1-0/
Please take a look at this post in my blog. My first try was exactly the same as what you want to do. I used v1.1 which works just fine. From Adafruit's website, download v1.1 and look at the circuit. You will easily figure out what to do.
furrysalamander says: Feb 26, 2013. 7:53 PM
So, I think I answered the first of my two questions. Do I just add a pnp transistor too? Then the power drives the npn one connected to the led, I gathered this from looking at your picture. And lastly, will the button wiring allow me to hold down the button rather than just clicking it?
JeonLab (author) says: Feb 26, 2013. 8:04 PM
I guess you don't need both US and EU modes. If you need only US. Mode, use the first circuit in my blog page. Forget about start and stop buttons. Connect a wire where the start button so that it always close the circuit. Instead, put a push button switch between the battery and epower in pin. For simplicity, you don't need the pnp transistor. Connect the base of the npn transistor to the Attiny85 pin 5 through a resistor (e.g. 1-2k). Got it?
JeonLab (author) says: Feb 27, 2013. 4:05 PM
I found I made wrong comment here. Do not connect anything to the pin 1. And the transistor is to be pnp, not npn.
furrysalamander says: Feb 27, 2013. 5:33 PM
Okay, so last check, Leave circuit the same, except don't touch pin one. Ensure to use v1.2 software, assemble, the end, right?
furrysalamander says: Feb 26, 2013. 8:37 PM
Oh yeah, another clarification, you mean I need to short the pin the start button is connected to to ground? And then put a button where the power is? And all this with adafruit's code?
furrysalamander says: Feb 26, 2013. 8:13 PM
also, do I need to use your code or adafruits?
JeonLab (author) says: Feb 26, 2013. 8:16 PM
The original code, Adafruit 's, of course sine you don't need the stop button.
furrysalamander says: Feb 26, 2013. 8:10 PM
Yes. THANK YOU THANK YOU THANK YOU!!! Please keep an eye on your inbox over the next day or two. I'll make one more schematic that should be the final design. I believe the sparkfun kit has a resistor built in on the digital input anyways. The schematics for the LED module are here: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Kits/PowerIR-v11.pdf I believe that makes it so it's just the microcontroller, resonator, capacitor, batteries, switch, and led module? Correct?
JeonLab (author) says: Feb 26, 2013. 8:14 PM
That's correct. Please understand I may not be able to answer you as quickly as I'm doing now from tomorrow. But I will try!
furrysalamander says: Feb 26, 2013. 8:17 PM
Okay, thank you, this will be the best birthday present my friend has ever received! I'll probably email you before school, then check it during my fifth period, then when I get home, so that's fine. You've been a massive help because I've posted elsewhere and not even gotten a reply! Once again, THANK YOU!
JeonLab (author) says: Feb 26, 2013. 8:25 PM
As I said, I may not be able to answer you quickly because I cannot wait and review your questions all day but have to go to work. Have you soldered before and do you know how to upload the hex code to the chip? If not, do not rush and take your time to learn and practice first. Good luck.
furrysalamander says: Feb 27, 2013. 6:16 AM
Will this do?
TV-B-Gone-2.0.png
JeonLab (author) says: Feb 27, 2013. 4:09 PM
I don't know about the sound circuit you added. As mentioned above, use a pnp transistor and do not connect anything to the pin 1.
furrysalamander says: Feb 27, 2013. 4:22 PM
Ah, the sound circuit is just the guts of the sonic screwdriver. Can you show me how I should have the pnp transistor wired? The module has an npn transistor built in, so can I have both connected? I'm sorry but I have a really big headache and I feel sick, so if you could, don't worry about the sound and UV led, please just draw me up a circuit, and be sure to include the sparkfun module.
JeonLab (author) says: Feb 27, 2013. 4:27 PM
It's simple. You don't need a new drawing. I just checked Sparkfun's module and it already has the base resistor. So simply connect the pin 5 to the module control pin. That's it.
furrysalamander says: Feb 27, 2013. 4:30 PM
Pin five IS connected to the control pin, but isn't it the wrong kind of transistor? And, I need to leave pin one untouched, right?
JeonLab (author) says: Feb 27, 2013. 4:36 PM
In fact, either pnp or npn works. I have tested before with a pnp and an npn and both worked fine, but maybe only for my TVs. You may want to test them yourself before fully assemble them. Yes, the pin 1 should be left unconnected.
furrysalamander says: Feb 27, 2013. 6:24 PM
Version 1.1 or 1.2 software?
JeonLab (author) says: Feb 27, 2013. 7:17 PM
1.2
furrysalamander says: Mar 6, 2013. 6:11 PM
Yay! I successfully programmed the attiny. The rest of the parts get here tomorrow. Avrdude will spit out an error and not be able to read the code off the microcontroller if it didn't program correctly, right?
JeonLab (author) says: Mar 6, 2013. 6:33 PM
Congratulations! As long as you compiled correct source code with proper MAKEFILE, no error means a green sign. As I said before, before fully assemble the parts, if you have a breadboard, test your circuit on it without soldering first. That will save you $$$.
furrysalamander says: Mar 8, 2013. 8:24 PM
Problem fixed. :D It works, and I've turned off some TV's. Now to stick it into the sonic screwdriver and go wreak havoc at Walmart and such for "field testing"
JeonLab (author) says: Mar 9, 2013. 8:39 AM
Congratulations! I'm sorry that I couldn't reply you earlier for your previous message. What was the problem?
furrysalamander says: Mar 9, 2013. 10:48 AM
Well, I want to say it was the fuses, but it might have been my stupidity. The LED on mine flashes REALLY fast, so I just had to move it. However, before I did that, I re-burned the fuses according to the $3.50 TV-B-Bone micro, and then I reprogrammed it. So idk, but I think I have a record for running the file with the least amount of parts. But I think that could be shrinked again by two, but I can't guarantee that it would work at that point.
furrysalamander says: Mar 7, 2013. 8:53 PM
Please help me! I assembled it on a breadboard as shown, and the LED only just turns on, it doesn't flash! Is it related to how I burned the fuses? I used this command: avrdude -p t85 -c gpio -v -B 250 -u -U lfuse:w:0xfd:m -U hfuse:w:0xdf:m
then I ran this to upload the code: avrdude -p t85 -c gpio -v -U flash:w:tvbgone.hex
1-40 of 72Next »
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!