ilteris kaplan blog

Mechanics, thanksgiving progress

November 26, 2005

The floor was opened from 12 to 6 today. I worked all day about the final and it was fruitful, I built the device and also I happened to get smooth results from photocells, tomorrow I am hoping to add motors to the circuit and get it working at least.

There are some problems with wheels and I am sure they are going to give me headaches but still I am pretty happy with the progress I made, here is the code that takes the values from CdS and print on the hyperterm.

’ 10-bit A/D conversion
’ Connect analog input to channel-0 (RA0)

’ Define ADCIN parameters
’ Set number of bits in result
DEFINE ADCBITS 10
’ Set clock source (3=rc)
DEFINE ADC
CLOCK 3
’ Set sampling time in microseconds
DEFINE ADC_SAMPLEUS 10

adcVar VAR WORD ’ Create variable to store result

’ Set PORTA to all input
TRISA = %11111111

’ Set up ADCON1

ADCON1 = %10000010
v1 var byte ’ variable v1 holds cdS #1 information
v2 var byte ’ variable v2 holds cdS #2 information
Pause 500 ’ Wait .5 second

main:
ADCIN 0, v1 ’ Read channel 0
ADCIN 1, v2 ’ Read channel 1
SEROUT2 PORTC.6, 16468, [“CdS 1 = ”, DEC v1, 10, 13]
pause 5
SEROUT2 PORTC.6, 16468, [“CdS 2 = ”, DEC v2, 10, 13]
Pause 100 ’ Wait.01 second
GoTo main

DSC06222

DSC06223

DSC06225


Written by Ilteris Kaplan who still lives and works in New York. Twitter