(Comp.sys.hp48) Item: 2 by _davemarsh at hpcvbbs.cv.hp.com Author: [DAVID J. MARSH] Subj: IR remote repost Date: Mon Sep 30 1991 [repost; originally posted Aug 10, 1991] Presented here are three programs that form the basis of a learning remote control application for the HP48. The brief decription: NEWSTR- creates a string of N spaces. LOOK- Requires a string as input, samples IR, outputs changed string XMITREM- Requires output of LOOK, transmits IR. The verbose description: LOOK uses the length of the input string as a loop counter, and replaces the data area of the string with IR sample data. Any string may be used as input, but the length of the string is important. The sampling loop runs at just over 26kHz, so an input string of 1500 characters in length provides just over 100ms of sample time. Most remote controls have signals that fall nicely in this range, however, if you can't get it to work, try a longer sample length. (Notably, my Scientific Atlanta cable box requires a string length of 2000 to work reliably). The distance between the remote and the '48 is also important- if the remote is too far away, signal will be inadequate, but if it is too close, the Phototransistor may get swamped. I have found that most remotes behave well when nearly touching the '48, but some experimentation may be necessary in any given case. NEWSTR may be used to easily create the input string for LOOK. XMITREM takes a string from the stack and uses its data as a template for the IR transmission. The inner loop within the program has exactly the same execution speed as the loop in LOOK, so that the output timing may be as exact as possible. Although this loop is only running at about 26kHz, (as opposed to the optimal speed of 80kHz), it seems to work very well in most applications. Most devices may be controlled from a distance of about 10 feet away, with some going up to as much as 15 feet away (my VCR). These programs are not intended to be a finished application, but rather building blocks that may be used underneath any user interface that you might want to use. One last thought- There are several ways in which the functionality of these programs can be upgraded. The data storage is not very efficient, because it is optimized for speed- some simple compression would help tremendously. ( I am only using 1 bit in each nibble for data.) If there is sufficient interest, I am not unwilling to post the source files for these programs. I presented it at the HP Handheld conference in Corvallis, and the proceedings from that conference are available from Educalc. Dave Marsh ---------- The above is a repost of my original posting, for those who have been asking... I am still in the process of improving these routines, based on the many excellent suggestions from everyone out in Netland. Currently, the new version is nearly ready to post (incorporating some of Rick's (Grevelle) excellent routines- compression/decompression, automatic string creation, etc.), but time constraints are preventing me from finishing the project for a few weeks. In the meantime, please use these programs if they interest you. [Note: See REMOTE2 on this disk... -jkh-] P.S. Some excellent compression is possible using the Redundancy Fighter program that was posted to this group not too long ago [and included on this disk; see RF. -jkh-]. P.P.S. It has been pointed out to me (correctly so) that the NEWSTR program above stinks... personally, I was using Jim Donnelly's RPTSTR to create my strings, but I didn't want to violate his copyright by posting that routine with this. Anyway, it will be fixed soon as I'm able. [Note: If you have the Tool Library, you may replace NEWSTR with << 32 SWAP STRCON >>, which will run MUCH faster. -jkh-] Enjoy!