Essentials of Mechatronics  ISBN: 0-471-72341-X- ©John Billingsley 2006 - published John Wiley & Sons, Inc

11/3/1.htm  Code for PIC ADC

This has been provided by Mark Phythian:

Here is the PIC program (Basic version) (Assembly version)
These have been given a .txt extension to avoid security problems.

The URLs of the Basic compiler and other useful items are as follows:

http://www.oshonsoft.com/    Basic compiler (approx $25)
http://www.ic-prog.com/index1.htm    free software for a range of PIC programmers
http://www.siliconchip.com.au/cms/A_30668/article.html    one PIC prgrammer available from Jaycar for around $40.

The PIC used is a Microchip PIC16F88.

All commands are echoed, then data follows

Commands are:

Hex $30 character 0
Returns 8 bytes:  4 channels of 10 bit adc readings (right justified)

Hex $40 character @
Returns 4 bytes:  4 channels of 8 bit adc readings

Hex $50 character P
Returns 1 byte:  4 input bits in low part of byte

Hex $60-$6F characters ',a,b,c,d .. o
Sets the 4 output bits according to low 4 bits
Returns 0 bytes

Two other pins on the PIC are interrupt inputs (active low)
INT1 sends 1 byte hex $21 character !
INT2 sends 1 byte hex $22 character "

A Visual Basic 6.0 demonstration program is in this zip file.