Dangerous Prototypes

Dangerous Prototypes => USB Infrared Toy => Topic started by: rsdio on April 15, 2010, 02:29:43 pm

Title: Timer settings
Post by: rsdio on April 15, 2010, 02:29:43 pm
Following up on the PIC Timer Calculator program errors, I decided to review the USB IR Toy firmware source briefly.

Looking in HardwareProfile.h, it appears that the 10 µs timer for TVBGONE was originally calculated as (65415) or 0xFF87, which would produce 10.083 µs, but later changed to 0xFF9A, which would produce 8.5 µs. I think that if 10 µs is really the goal (note that I have not researched TVBGONE to confirm this), then 0xFF88 (65416) would be better, since it produces precisely 10 µs.

#define T1_10usOffset() TMR1H=0xFF; TMR1L=0x88

Similarly, I've already explained that 64336 should be the preload for 10000.0 kHz.

#define T1_OFFSET 0xFB50 //64336 preload = 10000.0 kHz
#define T1_OFFSETH 0xFB
#define T1_OFFSETL 0x50

I have not reviewed the Timer2 values. They might be right, since the interrupt occurs on TMR2 to PR2 match. That's not the same as interrupt on overflow. I think that the PIC Timer Calculation program might produce the right values here, since the Timer2 does count up from 0 to PR2. Then again, counting from 0 to N still gives a period of N+1, so they could be off by one after all.
Title: Re: Timer settings
Post by: ian on April 17, 2010, 09:05:14 am
You're correct. Maybe the program's example source subtracts 1 to adjust? I should have done that, and I'll add it to the list of things that should be changed for the v1.2 firmware release.

The TVBGONE values were found by messing with the settings until the signals had the right timing on a logic analyzer. They were selected through experimentation. The PIC code has some overhead, and the smaller timer values allow for that.
Title: Re: Timer settings
Post by: rsdio on April 17, 2010, 09:09:14 am
Speaking of the v1.2 firmware release, is this something with a public source code revision repository? If so, then I may be able to help with some things once I finally get started with the USB IR Toy.
Title: Re: Timer settings
Post by: ian on April 17, 2010, 09:20:43 am
Yup, all code is in the SVN at google code (you have to get the USB stack from Microchip yourself for licensing reasons, but we're working hard on that too):
http://code.google.com/p/dangerous-prot ... y-firmware (http://code.google.com/p/dangerous-prototypes-open-hardware/source/browse/#svn/trunk/USBIRtoy/IRtoy-firmware)

( ! ) 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.00922045640session_write_close ( )...(null):0
20.00952177216ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.00952177992Database_MySQL->query( ).../DatabaseHandler.php:119
40.05382316704Database_MySQL->error( ).../Db-mysql.class.php:273