JOY_STIK.ASM Theory of Operation 2001 Overview: The program is designed to convert the movements of most analog PC joysticks into serial data formatted to operate a Scott Edwards SSC II servo controller. The hardware is a PIC 16F84, 5v regulator, 3 caps and a few resistors for current limiting. Data aquisition: The joystick's two variable resistors representing X and Y axis positions are read sequential with an RC based analog to digital conversion. Some of the routines are borrowed from Microchip AN512. Measured values are then stored for later calculations. Joystick calibration: When a joystick is first used with the converter, a calibration must be done by powering up with the fire button pressed. When the button is released, the routine begins measuring the position in both directions. The joystick is then moved in a sweep covering the full range of motion. At this point the fire button is pressed again which stores the maximum and minimum resistance in EEPROM memory. Afterwards, the LED begins blinking, indicating the calibration is complete. Because the calibration is stored in non-volatile memory, the data is saved and will be present the next time the interface is turned on. The calibration routine must be done when changing joysticks and can be performed anytime desired thereafter. Program operation: The unit is powered up w/o any buttons pressed for normal use. The calibration data is retrieved from PIC EEPROM memory. If the data is corrupt or not found, the program stops and the LED begins blinking. If good data is read back, the PIC starts measuring both axis with 16 bit resolution. The measurements for each axis are then scaled to 8 bits by the math routines prior to storage. At this point the fire button which controls a third servo is read. This servo shifts from minimum to maximum when the fire button is pressed, returning to minimum when released. Delta Compression: Data from all three inputs are compared to the previous readings. Only the data which has changed is sent serially. The LED will blink once for each update sent and the LED on a connected SSCII should blink in unison. Serial data format: Data out is jumper selectable 2400/9600,8,N,1 serial at TTL levels. The jumper control mimics the SSCII. On = 9k6, Off = 2k4. The present code is designed to operate with the SSC II connected directly. If the data is to be sent via a modem or other RS232 device, optional code written for use with an inverting TTL to serial converter (i.e. MAX232) will soon be availble. The data out line from the MAX232 would be tied to DB9 pin #3 instead of pin #2 for this type of connection. Other applications: Because the resistance measurements are self powered, this unit will work with any pair of potentiometers with values from 5k to 400k and a SPST switch replacing the fire button. Would make a great pan / tilt control for a camera. This version of the code requires all three standard joystick inputs (X,Y,fire) be present to operate properly. If you have problems, check the resistance at the joystick connector between pins #1 / #3 for X axis and #1 / #7 for Y axis, note change matching movement of the joystick. If none is seen, check the other pins. I wired mine to work with my F-15E Hawk joystick and am assuming other analog sticks are the same. You may also want to check which of your fire buttons pulls pin #6 low. This will be the one used for calibration and third channel control. Pinout: DB15 joystick - pin #1 is x,y axis common. Pin #3 is x axis out. Pin #7 is y axis out. Pin #6 is the fire button out. Pin #4 is fire button common (ground). DB9 serial - pin #2 is serial out. Pin #5 is ground. Obviously, this assumes you've wired the SSCII the same. This software is copywritten 2001 by Mike Berg N0QBH. It's free to use in a non commercial manner by experimentors. Mike Berg N0QBH