FAQ for RS232 or IRDA port Remote Control Project

Change History

28/02/2001 - A2 changed
26/08/2002 - A7 schematic and text changed. A15, A16, A17 & A18 added.

I have attempted to anticipate most of the likely issues resulting from the remote control project by dealing with them in the web page and the readme.txt file included in the download package. There are, however, a number of questions which arrive regularly in emails, so here is where I've collected the most popular ones and created some generic one which may have been alluded to.

Note that when I refer to the 'docs' I mean the file README.TXT in the download package. The 'site' or 'web page' refers to http://www.veg.nildram.co.uk/remote.htm.


Q1. Can I have your source code?

A. Not for winsamp.exe. I keep it to myself - still unfinished. Hence the reason for the complete explanation of how to do it on the site. The dos app is written in c, but is very much a hardware bit-banging, just marginally easier to read than assembler, sort of thing which would have no relevance to anything other than a PC. You can have most of the VB part (manybutt) though if it's any use to you - it just shells the dos app with appropriately-constructed command lines - explained in detail in the docs. It's neither clever nor well-written - just a quick little something to do what I wanted. It would have been interesting if it had been possible to do the whole thing in VB, but it gives nothing like the degree of control necessary.

What I have done is to take the VB file manybutt.frm and save it as manybutt.txt. You can just click and save it - at the end of the day it's nothing more than a text file anyway. Since you already have some sort of VB development system (it wouldn't be any use to you otherwise), you should be able to hack it about and import it to suit yourself - the icon is missing, so give it any icon you like. This should let you recompile the program to suit your system.


Q2. Can you give me part numbers for IR components?

A. I don't know the exact part numbers I used - they came out of my box of miscellaneous electronic junk. The actual choice of parts is not critical. A look through one of my (very old) catalogues suggests for example TSUS5402 for the Led and BPW41N for the diode - the part numbers are probably obsolete, but you should be able to search out equivalents. They operate around the 950 nm wavelength, and the photodiode is encapsulated in a black infrared-transmissive plastic package (very important if you don't want to saturate it with visible wavelengths or filter it yourself).

Chances are there will be some variation between the peak sensitivities of your various pieces of equipment and you couldn't hope to match them all exactly anyway. The best you can do is pick something which is about right for the majority - slight mismatches will tend to reduce range rather than stop it from working entirely. As far as the photodiode is concerned, the range of the sampler circuit is only a very few cm regardless, and you should be able to use the software to find the optimal distance - the important thing is to pay attention to the warning above about encapsulation / filtering, or make sure visible light is excluded.

28/02/2001

I had a look for some currently-available part numbers, and came up with the following. For the LEDs, SFH409 and OPE5584 might be suitable, and for photodiodes, SFH205F and SFH213FA might be suitable. I think. I haven't tried them, but they seem fine on paper. The bits required for this project are neither expensive nor particularly special, so why not obtain several types and find which combination works best for you?


Q3. What are the equivalent pin numbers for 9-pin D-connector?

A. On a 9-pin connector, DSR=6, DTR=4, RTS=7, TX=3, GND=5.


Q4. Can you give me sample files for the XXXXX (manufacturer/type) model YYYYY machine?

A. No. I have neither the time nor the inclination. My universal remote covers untold hundreds of manufacturers / devices, but does not give me details of actual model numbers, so in some cases I'd have to create maybe dozens of complete sets of buttons just to have a chance of making your particular box work. If you know the exact patterns and timing for your particular machine, it's possible to create your own sample packets by hand, otherwise build the sampler hardware and use your actual remote as a source.


Q5. Is there a library of sample files?

A. Not that I'm aware of. I think most people build the sampler and make their own samples. A library would be big and would involve someone in a lot of effort.


Q6. What is the acceptable range of voltages for the transmitter circuit as shown?

A. With the components shown, I would expect anything from about 6 to 12 volts would be OK. The source doesn't need to be well-regulated, and it's definitely not critical, within generous limits. The PP3 battery is nominally 9 volts (in case the part number is meaningless in your part of the world).


Q7. The sillyscope screen fills with Ws with and without external hardware. What's wrong?

A. Possibly nothing much. This is correct behaviour with no external hardware. With the hardware connected, DSR will be idle high (pulled up by 4k7 resistor) when winsamp is run. IR exposure turns transistor on and pulls DSR low. Because there is no hardware, DSR is already low so the sampler program thinks your photodiode is being exposed to IR (base current turns transistor on and line is pulled down) and starts sampling at once - all WWWWW.

If this problem is seen under Windows with hardware attached, possibly some Windows driver / process / application is trying to use the port. There must be NO OTHER DRIVER INTERFERENCE. This relates to my own experience with MS ActiveSync (used to connect my PDA to the PC) - if you have previously run this or normally have it in the background on the same port, it can for example make DSR look high from a status bit point of view even though it is actually externally electrically low. There is no practical way for the dos program to detect and correct for this situation. Other drivers may have different and unknown (to me) effects. You _must_ ensure that nothing else is tampering or has tampered with the port. You should certainly disable any such applications. Perhaps you could disable the port in the current profile through the settings in Control Panel - this will stop Windows from accessing it, but will not stop the dos app from using the port hardware directly. Remember to reset the PC after you do this.

If you have booted to real dos, have hardware attached and still see this problem, chances are you're not using the Com port you think you are, or your external hardware is - how can I put this without you taking offense? - suboptimally configured, differently correct (i.e. wrong).

On the Com port issue, the Com port parameter used by the dos program refers to the port base addresses 0x03f8, 0x02f8, 0x03E8, 0x02E8 in that order, as seen by dos / bios. If Windows decides to remap the base addresses (possible on some machines) the program may not find hardware at the addresses it expects, so check your port resources as reported in Control Panel / System.

On the suboptimal hardware issue, there are lots of possibilities, Firstly, check the obvious, like the polarities of the diodes and transistors, the pin numbers of the connector and verify that the connections and components are all in place as per the original diagram. It may help to look at the photo (also linked from Q9). Make sure your photodiode is suitable (see Q2). Below is a circuit diagram with measurement points marked. Study the diagram, the circuit description that follows it, and make some measurements. The act of working your way through this may help you to spot the problem, but if you really get stuck you can send me your readings - try to make measuremnts with winsamp active, and the IR detector both dark and illuminated (best to use a torch or lamp close by for illumination - you won't be able to catch the pulses if you use a remote control handset unless you have access to a scope). I need to know the measurement points as well as the actual voltages.

measurement points (8k)

Note - I do not intend this to be the place for a discussion on the finer points of electronic theory. All of the following description is based on the idea of current flowing from positive to negative - if this is abhorrent to you, then you probably don't need the explanation anyway. Also, I have taken a fairly seat-of-the-pants approach to it - there is only as much detail as I think is necessary to explain what's going on.

The transmitter. TX swings between a positive and a negative voltage. The spec for RS232 suggests anything between +/- 3 volts to +/- 18 volts (something like that anyway), but typically somewhere about + and - 9 volts (and depending on the load - RS232 expects the load to be equivalent to driving through a 3k resistor to ground). From now on I'll call these voltages +232 and -232. The handshake outputs will be similar to the TX. You should measure yours to establish a baseline for the other measurements. The fet (2N7000) will be fully turned on when the gate is more than about 2.5 volts above the source, and fully off when the gate is at a lower voltage than the source. When TX goes high, the fet turns on and pulls current through the resistor and IR led from the positive supply (9 volt battery or whatever). So the positive levels seen during RS232 transmission cause the led to turn on. The 100k resistor makes sure the fet is off when the circuit is disconnected. Unless you have a scope handy or know how to force a BREAK condition on TX, or how to poke your divider chain to achieve really _l_o_n_g_ bit times, you won't really see meaningful voltages on the transmitter side. The diode marked *NOTE* between the TX pin and the gate of the fet has been added for reasons explained in the main page.

The receiver. When Winsamp starts, it takes DTR high (to +232) and RTS low (to -232). With the photodiode in the dark, there is negligible current flowing into the base of the NPN transistor so it is off. Consequently, DSR is pulled towards the positive supply by the 4k7 resistor. Of course, the DSR input looks like a few k resistor to ground (see above), and you won't see the full +232 voltage appear at the pin. So in this state, DTR=+232, (1)=+232 minus one diode drop so maybe +232 -0.6V, (3)= about 3 or 4 volts, (6)= -232 plus one diode drop so maybe -232 +0.6V. (5) is your ground reference, but you can simply stick your meter lead to the PC case - that should be the same. The two diodes on the handshake outputs stop anything nasty happening should the port not be initialised correctly, though given the current available, I don't think there is any risk anyway. When the photodiode is illuminated, either by IR or for example a torch or table lamp, a light-dependent current starts to pass through it into the transistor base. The transistor turns on by an amount proportional to the base current times its gain (up to the point where it is fully on), and will pull current through the 4k7 resistor (and the DSR load once it goes negative). This increases the voltage drop across the resistor, so what you will see is the (3) voltage fall and go almost to (6), depending on how much light hits the photodiode. The sampler program simply looks for a high or a low on DSR as a result of this - when (3) is above 1 or 2 volts, it looks like a high, and when it is at 0 volts or less it looks like a low. Moving your IR source closer and further away will determine how turned on the transistor gets and consequently whether the signal crosses the high-low threshold reliably - too far away and it might not pull low enough, too close (or too much ambient light) and it might stay low too long. The Sillyscope will let you see what the sampler can see.

With winsamp running, measure the voltages at (1), (3) and (6) relative to (5) under dark and light conditions and tell me what you get, if you haven't already got the circuit working.


Q8. I've done everything exactly as you said and it doesn't work. What's wrong?

A. I don't think you have, but I suppose there's always an outside chance one or more of your components is damaged. If you have spares (you did buy spare parts didn't you), try changing something. If that doesn't help, please work through everything in Q7 and if you still have problems send me the measurements.


Q9. Can I see what your sampler hardware looks like?

A. I have stuck a photo, complete with legends here. It's about 73k.


Q10. Can I use the IRDA port for sampling?

A. As explained on the web page, no. Not with this method anyway, and probably not at all on a PC platform. You need the sampler circuit and a regular RS232 port to create the samples.


Q11. Can I use the circuit for wireless comms between PCs?

A. No. At least, not unless you want to write your own protocols and do a lot of programming and hardware fiddling, and it isn't worth the effort - there are easier ways (don't ask, use a search engine!). The system described is very cheap, but it's no substitute for a proper IRDA port.


Q12. I can't get the Windows program to work. What can I do?

A. As explained on the web page, manybutt.exe is a VB5 program, and I can't afford the bandwidth to support a full distribution on the page. If you see some kind of runtime error when you try to run it, you probably don't have all the VB runtime junk on your system to make it work. As far as I'm aware, I don't do anything clever or demanding in the program, so it might not be too difficult to find the necessary files. If you have a VB development system, you could compile your own version by using the text file linked in Q1.

Alternatively, why not just run winsamp.exe from a folder of shortcuts on your desktop? Get some button files, create shortcuts and edit the properties to feed each instance the appropriate command line (see docs). You probably want to change properties to Run Minimized and Close on Exit, and may wish to edit the shortcut label to say something meaningful like the button name. You could extend this idea to include shortcuts to dos batch files or whatever (see Q13). The only operational disadvantages are that for playback you need to double-click icons rather than pushing buttons, and for sampling / editing samples you need to do a bit more work with your text editor. But it isn't difficult.


Q13. I want scheduled operation. How do I set this up?

A. You can achieve this simply by using Windows task scheduler to call winsamp.exe with the appropriate parameters. You could set up a series of shortcuts edited to do such things as VCR ON and simply schedule the shortcuts. You could set up small dos batch files to give you multiple button pushes then exit, and schedule those. The tools are already there to achieve some quite sophisticated effects, given a little patience and the sampling hardware. So, for example, you might sample the TV power button and all the number buttons, then set up a batch file to call winsamp several times giving it one button at a time - say, turn the TV on, then push 2 then 7, or whatever - I'm sure you get the idea. You can use the command line options to make your samples from dos if my VB demo prog doesn't work for you. You can do various things with winsamp like sample a whole set of buttons in one session from dos then split the big sample file (which is only text) into a number of individual suitably-named button files. All the info you need in order to achieve this is hidden in plain sight somewhere in the docs, including some VB code lines to get you started with your own Windows interface. If you write your own interface, scheduling should be simple. Because there is no direct feedback from the appliance, you would have to consider the implications of it failing to work first time or at all - it's easy if you can see the effect of your control packet - if it fails you just try again, but what about unattended operation?


Q14. I'm still stuck or I want to send you feedback.

A. I welcome feedback on the project, but if you have specific questions or requests, please do me a favour and make sure they haven't already been covered by the web page, the docs or the FAQ. Email address is at the bottom of the page. Thanks.


Q15. I can't get hold of the FET you specify for the transmitter. How can I use an ordinary NPN transistor?

measurement points (3k)

A. Try this, using a BC107 which you should already have if you built the sampler circuit. Untested, but it should point you in the right direction. You could substitute something like 1N4148 in place of 1N4001, because there is almost no current involved, and the device is physically smaller if space is at a premium. The choice of transistor is wide open - any NPN device with a bit of low-frequency gain and the ability to handle the current will probably work, though you may want to play with the values of some of the passives to suit. The BC107 was just what I had lying around at the time.


Q16. I want more IR power. Give me some clues.

measurement points (5k)

measurement points (5k)

A. Here are outline examples of multiple series and parallel LEDs, which offer various possibilities - you can spread the LEDs around the room or arrange them to suit. You can combine both ideas or whatever. The important point is that more energy is being used to generate IR, though you may not get the results you hope for. LEDs tend to be quite directional, and I don't imagine for a moment that simply doubling the power will double the effective range. You will need to do some calculations in order to pick suitable values and devices. I chose slightly less than 100mA as a safe limit for my LEDs, in case some fault condition caused them to turn on continuously. Of course, under normal working conditions, the average current would be much lower, and LEDs can generally tolerate short pulse currents at much higher levels, so there is lots of room for experiment. Exploring the limits of the technology just isn't of much interest to me, so I play it safe.


Q17. Which versions of Windows work with the supplied software?

A. I have personally used the software successfully with Windows 95 and 98SE. I have mixed reports about Windows 2000 - it probably doesn't like the direct hardware access, but your mileage may vary. Windows XP is reported to work. NT - forget it.


Q18. Can you explain in English what you mean by 100R, 4K7 and 100K?

A. It appears that the convention I follow for noting resistor values is far from universal, so here they are in English. 100R = 100 Ohms, 4K7 = 4700 Ohms, 100K = 100000 Ohms. I apologise for not making it clearer in the first place.


Email

Back to Remote Control Page
View the other delights on my site
Copyright? Possibly .....