|Re: converting HP41 cx IR data to 8 bit serial|
Message #6 Posted by Ellis Easley on 29 June 2002, 5:43 p.m.,
in response to message #1 by Ron Meek
I think the HP41 IR module lets the 41 print to the 82240A/B printers (what else?). I also think the other calculators with IR, including the 48, 38, and 39 will also print to the 82240. Since those graphing calculators can communicate with each other through either the IR or the cable, and since the cable connection also connects to a standard RS-232 port (three wire, anyway), it seems logical to assume that the IR interface of the 82240 (and the 41 IR module) is a similar protocol to RS-232.
There is a standard called IRDA used by laptops and now incorporated into the multi-I/O chips in PCs as an optional mode of operation of the serial ports. IRDA was based on a protocol HP developed for their first palmtop PCs (or was there another level between "laptop" and "palmtop"?) like the 100 and 200 IIRC, small clam-shell units with full keyboards - the first things I saw with PCMCIA hard drives.
Anyway, IRDA physically is basically RS-232 modulating a narrow pulse at the beginning of the bit cell. It seems like one objective was to save power in a battery powered device. Where the RS-232 bit stream has a "one" (or whatever a start bit is), the narrow pulse is transmitted by an IR LED. Where the bitstream has the opposite sense, no IR is transmitted. I think the original name of HP's standard was "HPIR" or "HPSIR".
If this is correct, and the 41C IR module is based on something like HP-SIR or IRDA, you will need to receive the IR signal, translate it to RS-232 by stretching the pulses, then feed them into a UART. There used to be UARTs that could be completely programmed through pins, I don't know if you will find anything other than an 8250 or 16450 derivative today, and they need a microprocessor to program them. The main thing a UART does for you (on the receive side) is detecting the start bit including distinguishing a false start bit. If you are able to use a slow enough rate of sending bytes (allowing more than a full byte time between bytes) and don't have to worry about noise (stray IR pulses in this case), you could just use a one-shot as a start bit detector to start your receive clock (by RS-232 rules, you latch the data in the middle of the bit cell), then shift the data into a shift register. When the start bit gets to bit 9 or 10 or 11 (depending on whether the protocol has 7 or 8 data bits and 1 or 2 stop bits), it can enable the shift register contents to be transferred to another latch to be the next phase for the stepper motor (I don't know if the chip you name is a driver or an intelligent controller), this accomplishes the same purpose as the double buffering done in a UART. After the data is transferred you could clear the shift register to prepare it for the next byte's start bit to trigger the latching of the data. With the crude one-shot start bit detector, which will time out more than one byte time after the last data bit which has the same sense as the start bit, you can use its trailing edge to re-arm the data transfer circuit as well as the receive clock synchronizer.
Come to think of it, if you don't have to worry about noise, why bother stretching the IR pulses? You will still need to synchronize your receive clock and you will have to do it with more precision with a narrow data pulse.
Also, if you make the one-shot non-retriggerable (gate the trigger with the inverted output) you can set it to time out just after the last stop bit.
You could even use the trailing edge of the start bit detector, or perhaps more properly the "byte gate", to transfer the data from the shift register to the storage register, meaning you could forget about "arming" the shift register and detecting the arrival of the start bit in the last cell of the shift register. This would be trading some noise immunity for a simplification of the circuit.
Of course, all this assumes that what comes out of the 41 IR module is something like IRDA. You need to start by building a simple IR receiver and using an oscilloscope to see what the output looks like. A photodiode alone is sufficient for this. Applying some reverse bias to the photodiode speeds up its response by reducing its capacitance. There are two general wavelenghts of IR LEDs and some photodiodes are built with filters to make them respond better to one or the other. Some of these come in opaque (to visible light) packages. I think the photodiodes in clear packages will respond to either IR wavelength as well as to visible light.
Another possible issue is whether the protocol of the 41 IR module contains any overhead bytes around the data bytes. If this is the case you will need to filter them out. If you didn't want to use a microprocessor to do this, you could use a longer shift register and then transfer just those bits you want to the storage latch.
In this same vein, is it possible to send just one character from the 41 to the printer? I assume to control a stepper motor, you want to send a series of phases at a variable rate. The 41 might not be able to send characters - or blocks containing one relevant character - fast enough to allow you to drive the motor as fast as you are hoping to.
Also, the signalling rate you want - 2400 baud - might not be what the 41 IR module is doing. It seems like the default rate for the graphing calculators is 9600 baud (on the cable, anyway).
If your chip is intelligent, it might be able to buffer data and work with higher level commands than just individual motor phases. If this is the case, and if it will only work at 2400 baud, and if the 41 IR module sends more than just your data, you should consider using a microprocessor to receive the IR data, filter out the overhead, and retransmit the data bytes at 2400 baud to your chip. If the microprocessor only had one UART, I would use the UART to receive and use a general purpose output pin to "bit-bang" the 2400 baud output.
If any of this works, it will mean that there has been an HP41C RS-232 interface around all this time (even if it is transmit-only). On the other hand, it might be that none of this will work, in which case you will have to become expert in HP41C machine language to do what you want to do. Either that or figure out just what the IR module's protocol is and use a microprocessor to translate it.
BTW, there is the UART (Universal Asynchronous Receiver - Transmitter) and the USART (Universal Synchronous / Asynchronous Receiver - Transmitter) but did you know that in the National Semiconductor 1981 CMOS catalog they list a Universal Fully Asynchronous Receiver Transmitter?