Ultimate Pewatron Compass
This is the final version of our Pewatron compass. It is based upon the former PIC-Compass. This new RCX compatible sensor uses the Microchip PIC 16F628, which has an on-board comparator module. There is no need anymore of the analog switches and the comparator chip. The sensor gets smarter.
The standard 5V power supply with generous decoupling.
Each channel is amplified to fit into a range of 0 .. 4.8V
RA0, RA1 and RA2 are configured as comparators. This is done by software in the PIC program. Port B produces a rising reference voltage through the resistor-net ( R11-R18 = 20k ; R19-R25 = 10k ). The comparators store the respective Port B output numbers, which caused the comparators to switch.
RA3 is configured as Pulse Width Modulator at 4kHz. The signal is filtered to yield a voltage output which is proportional to the PWM-duty and thus the azimuth given by the PIC-program.
The PIC-program may be downloaded here as .asm-file and .hex-file