Instructables

Battery saving TV-B-Gone with region/range selection switches

Featured
Picture of Battery saving TV-B-Gone with region/range selection switches
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
1-40 of 86Next »
piddy05045 months ago

Hi thank you for a great instructable.I have managed to create the make file in avr notepad and i didnt get any errors, but i dont know what to do next to get the code into attiny 85.Please can you give me a step by step guide to do so i am using usbisp and this will be my first attempt at using this device to programme a chip.

JeonLab (author)  piddy05045 months ago

Sorry, I haven't used the usbisp. Did you mean USBTiny ISP? If so, I believe adafruit.com has an excellent tutorial. See

https://learn.adafruit.com/usbtinyisp/overview

piddy0504 JeonLab4 months ago

Hi i have managed to finally upload code to the chip (i think) well did not get any errors anyway,just waiting on resonator to arrive to test it out.I have a question regarding the fuses,do i need to change them in any way, it was a brand new chip and i have not made any changes to fuses i just uploaded the modified firmware.Also am i right in thinking that the LED on pin 7 will not light without the resonator in the circuit.I have built mine from your EU mod schematic.

JeonLab (author)  piddy05044 months ago

I'm glad you managed to upload the code. Did you use WinAVR or AVRdude? Anyway, if it is a brand new chip, you may need to change the fuses. For the TV-B-Gone with an 8MHz resonator using Arduino ISP, I use the avrdude command as below.

avrdude -c stk500v1 -P com%1 -p attiny85 -b 19200 -U lfuse:w:0xfe:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m

You will need to replace the programmer name stk500v1 with yours and the port com%1 with your connection..

piddy0504 JeonLab5 months ago
Thank you for reply, jes im sorry my mistake i am using usbasb
JeonLab (author)  piddy05045 months ago

Well, did you mean USBASP by usbasb? I'm not familiar with the programmer you are using, but try to follow the steps below with replacing the programmer name with yours in the MAKEFILE. You may want to contact the manufacturer of your programmer to find correct programmer name so that Avrdude can work properly.

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.

hi!! im from argentina...and its hard to get some of the components, the oscilator for example... some body could help me?? i need the code for the arduino IDE to this TV-B-Gone whitout the oscilator...

The circuit its the same right?

I´m using a Arduino nano as ISP

I have four Attiny85 20pu... and thats all!! no more buys outside the country, our government blocks all, no more adafruit, sparkfun, Techsupplies or Aliexpress for all the argentinian people... :(

Please Help!!!

JeonLab (author)  juanjosecastillo8 months ago
You can use an internal oscillator. In order to do that, you need to change fuse bit (http://www.engbedded.com/fusecalc). However, the frequency of the internal oscillator varies with environment temperature and power supply voltage, so the device might not work properly.
bsaw10 months ago
hi, Sorry if iam out of topic
does tv bgone work in asia?
and sorry for my bad english
JeonLab (author)  bsaw10 months ago
I think the most of the asian TVmodels use the same ir codes as North American. Visit Adafruit.com for full list of applicable TV models.
booliminator11 months ago
Im having trouble with the last part here. You said to make the changes, I did. Then compile and upload to the chip. what do we use to change the main.c into a .hex??? also once it is a .hex how do you program that using arduino-isp? ive sent arduino code to a attiny85 before but never a hex. Please let us know! Thanks!
JeonLab (author)  booliminator11 months ago
So you did make the changes in the programs which must be main.c, didn't you? And from WinAVR (if you don't have this, download it from http://sourceforge.net/projects/winavr/files/), you can compile and upload the .hex file directly to the ATtiny85 chip. But you need a programmer connected to your computer first. You can buy one from electronics shops (I just googled and found one at Sparkfun: https://www.sparkfun.com/products/11460) or you can make one. Try search "attiny avr programmer." You can also use your Arduino to upload .hex file. There are useful links in one of my blog post: http://jeonlab.wordpress.com/2011/11/20/jeonlab-mini-attiny-programmer-using-arduino-isp/ .
I Made the changes to the file, im not sure how to create a new hex file from the main.c, and then how to open a .hex in the arduino ide
JeonLab (author)  booliminator11 months ago
Try to follow steps below and let me know if you have any problem.

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.
Electo4fun1 year ago
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)  Electo4fun1 year ago
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.
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)  Electo4fun1 year ago
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.
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)  Electo4fun1 year ago
Yes, I have the resonator on my programmer. And yes, both 10pu and 20pu worked in my experience.
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)  Electo4fun1 year ago
Oh. The source code is not Arduino sketch. You need WinAVR to compile it. Arduino is used to upload the compiled hex file.
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)  Electo4fun1 year ago
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.
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)  furrysalamander1 year ago
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.
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)  furrysalamander1 year ago
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.
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)  furrysalamander1 year ago
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?
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)  furrysalamander1 year ago
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!
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)  furrysalamander1 year ago
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.
Will this do?
TV-B-Gone-2.0.png
JeonLab (author)  furrysalamander1 year ago
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.
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)  furrysalamander1 year ago
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.
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)  furrysalamander1 year ago
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.
1-40 of 86Next »