Dangerous Prototypes

Dangerous Prototypes => USB Infrared Toy => Topic started by: exapod on July 20, 2011, 09:45:55 pm

Title: pic18f2553 tv-b-gone with european code
Post by: exapod on July 20, 2011, 09:45:55 pm
i change the code of the irtoy for work with a 18f2553 at 8MHZ.The problem is that it not turn off tvs.
i use the c18 library for the pwm and also for the delay.
the ir led is working because i can see it blinking trough a camera.
i change also the freq to timer function.
thank you for the help.

THE CORRECT FILES ARE IN THE SECOND PAGE.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on July 23, 2011, 02:50:33 pm
i think that the errors are in the equation in freq_to_timervalue ,the setting of the dc value of the pwm and maybe in the delaytenUs routine.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on July 23, 2011, 03:18:53 pm
There could totally be errors. When I wrote the firmware I hand-tuned the timing by watching the playback on a logic analyzer and tweaking it to get the correct times.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 18, 2011, 02:05:52 am
i controlled all the function with the mplab sim and now it works, it turns off the european television.
I attached the code.Thanks ian for the suggestion.
Now i'm working on a smaller and powerful version.
i need to control 4 ir led ( http://it.rs-online.com/web/p/products/6997626/ (http://it.rs-online.com/web/p/products/6997626/))and i was thinking of using one transistor per led and one main for control the other 4 transistor, is a good way to do it?Any help or suggestion is very appreciated.

DOWNLOAD THE FILE ON THE SECOND PAGE NOT THIS ONE
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 19, 2011, 06:45:34 pm
i change idea and i will use a mosfet.
Putting two ir leds in series will affect the range?
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 20, 2011, 09:25:53 am
Thanks for the update, nice work getting this going. I have a blog post planned, but have not had a chance to run it yet.

IR LEDs typically need up to 2 volts (check the datasheet), so you can put 2 in series on a 5vlt supply. It is actually a good thing because you don't need to burn so much extra power in a resistor.

For example if you have one LED at 2volts with a 5volt supply, you need to burn 3volts in the R.
If you have 2 LEDs at 2volts (4volts total drop) you only need to burn 1volt.

You can use an online resistor calculator to find the R value (second one):
http://ledz.com/?p=zz.led.resistor.calculator (http://ledz.com/?p=zz.led.resistor.calculator)

I'm sure a professional engineer would mention differences among a batch of LEDs that would make one work slightly better then the other (steals some power). I think it will be negligible though.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 20, 2011, 01:01:15 pm
Can please someone that have a scope or a logic analyzer verify that the freq of the PWM is right?just check if the first code is : 35714 khz.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 22, 2011, 12:20:41 am
little update: i made all 138 code works and fit in the pic, i change the linker file and use 2 of the usb databanks so i don't think that the usb module is still working but i don't need it.
the files are in the attached.
P.S.:if you have a scope (and free time) read the previous post.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 22, 2011, 09:48:19 am
Thanks for the update. I am doing IR TOy debugging today, I'll take a look at the waveform.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 22, 2011, 03:40:44 pm
i'm having a strange problem, when i power the pic with a 5v supply everything works but when i use 2 AA for the power it doens't turn off all the tvs but just a part.
The clock is just 8 mhz and other people ( http://www.microchip.com/forums/m493862.aspx (http://www.microchip.com/forums/m493862.aspx) ) uses it with 48 mhz.
Any idea?
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 22, 2011, 03:48:03 pm
I don;t know about this chip, but most x55x chips have an adjustable brown-out detect on MCLR. IF the voltage is too low it will not start. You can set the level with the config fuses.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 22, 2011, 04:29:25 pm
I disable the bor but the problem is still there with the 5v and 220 ohm resistor the device turns off the samsung tv with 3v power supply and the led without resistor it doesn't turn off
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 22, 2011, 04:39:10 pm
I'm sorry, I'm not sure. Have you doubled checked that you're running at 8MHz? Could the PLL be on?

I think that PIC should be able to run 8MHz at 3.3volts, but have you checked the datasheet to be sure?
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 22, 2011, 09:07:52 pm
i was an error in the delaytenUs
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 23, 2011, 09:44:39 am
Thanks for the update, I'm glad you figured it out.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 24, 2011, 11:26:59 am
here it is the last code that works better.
One problem that i find and cant resolve is the function delayTenUs infact when you pass the value 0 (delayTenUs(0)) it delays 20 us.
If someone resolve it , please let me now
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 25, 2011, 08:28:52 pm
is possible to run 2 of this leds at 100ma in series http://docs-europe.electrocomponents.co ... e1b0e6.pdf (http://docs-europe.electrocomponents.com/webdocs/0e1b/0900766b80e1b0e6.pdf) and the pic with a cr2032 as power supply, the leds are controlled with a n channel mosfet.
I need to put some capacitor in series with the led and the battery? If yes what value?
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 27, 2011, 06:05:53 pm
What is the forward voltage of the LEDs (Vf)? A cr2032 is only ~3 volts and lower. It probably can only power one LED, not two in series.

Some caps would help even out any spikes from the LED going on. Value isn't important, 100uF or so, plus 10uF in parallel would probably help.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 27, 2011, 06:12:46 pm
On page 3 of the datasheet you can see the voltage vs current graph, at 100 ma the forward voltage is 1,5v .
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 27, 2011, 06:35:28 pm
CR2032 can drop low under load I think. As low as 2volt when low or under load. I would not expect it to operate reliably with two in series. Two in parallel should be fine with 100uF of cap for each. If you remind me, I will draw a schematic on Monday.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 27, 2011, 07:30:04 pm
Something like this?
Title: Re: pic18f2553 tv-b-gone with european code
Post by: ian on August 27, 2011, 07:56:55 pm
looks good, but you probably need a 0.5-2ohm current limiting resistor under (or over) each LED.
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 27, 2011, 09:18:48 pm
i have some 7,5 ohm 0,5 watt resistor so i will use them
Title: Re: pic18f2553 tv-b-gone with european code
Post by: exapod on August 29, 2011, 11:20:14 pm
for the delaytenus thing just reduce the ontime of 2 so it will be right.
For example if you find : 54 , 0 , ---change into--->> 52,0,
Any tips for get low power consuption? kind of: set all the unused port to digital.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01792127248session_write_close ( )...(null):0
20.01842258840ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01842259616Database_MySQL->query( ).../DatabaseHandler.php:119
40.09382398352Database_MySQL->error( ).../Db-mysql.class.php:273