USB IR Toy: Calculate sampling rates

Posted on Thursday, April 15th, 2010 in Infrared toy by Ian

See the latest version on the documentation wiki.

The USB IR Toy raw IO mode samples and replays infrared waveforms.  IRIO mode starts with a default 10kHz sample and playback timer. The rate can be changed with the setup timer command (0x01), followed by two bytes that set the sample timer offset. The first byte is the high 8bits of the offset, the second byte is the low 8bits.

An easy way to find the values to send is a utility such as PIC Timer Calculator V4. Enter the key constants (timer 1, 1:1 prescaler, 48MHz fosc), and adjust the slider to find an offset that gives the desired frequency. The picture shows the settings for 10kHz.

To use the offset value (64331 in the example), first convert the number to HEX (64331=0xfb4b). Next, break it into a high (0xfb) and low (0x4b) byte.

0x01 0xfb 0x4b

Connect to the IR Toy virtual serial port with a terminal program that can send byte values, we like Hercules and realterm. Send the sample timer setup command (0x01) and the two bytes of the timer offset (0xfb 0x4b). New settings take effect immediately.

There is maximum limit to the sample speed, but it’s undetermined at this time. At some point the samples are so frequent that the PIC can’t service the interrupt before another fires, or it won’t have time to service the USB peripheral.

A screenshot of Hercules settings are shown below the break.

This entry was posted on Thursday, April 15th, 2010 at 7:41 am and is filed under Infrared toy. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

One Response to “USB IR Toy: Calculate sampling rates”

  1. Head over to the forum under a “Quick Question about Raw IO mode” for further discussion of Timer1 calculations.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • KH: IMHO PCA9685 is not a really good part for this application. It's a PWM LED driver for goodness' sake. NXP _does_not_ mention servos in the...
  • KH: So it's a servo library designed by a software guy, or a library targeted at embedded newbies, or a learner bike. Given the design of...
  • Max: A thing I wish I knew getting into Arduino-controlled servos is that the typical "180 degrees" servos DO NOT move 180 degrees for the standard...
  • Max: I have certainly noticed certain suppliers (like Adafruit, Pololu) being... "western-facing" - which is another way to say their prices definitely aren't Eastern Europe compatible,...
  • Shawn: Hello