Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/29/02 15:58
Read: times


 
#21251 - TSL230 - Light to Frequency
Hello,

I have a TSL230 light to frequency converter. It is a device made by LAOS(datasheet: http://www.taosinc.com/pdf/tsl230.pdf ). The device outputs a frequency that corresponds to the light intensity on it. I am having trouble coming up with a program to read the frequency of this device and send it out serially to a computer. I have written a program(below) and I would like to know if someone could point out any solutions to this problem or any changes to the code that might help. Any help would be greatly appreciated. Also, I noticed some BASIC stamp code that uses the "count" instruction to read in the frequency. I am not sure what the assembly equivalent is exactly.

CODE:
S1 EQU P0.0
S2 EQU P0.1
S3 EQU P0.2
S4 EQU P0.3
OE EQU P0.4


MEASURELIGHT:
Again: ;Count 0-1 transitions arriving at external input pin T0
MOV TH0, #0 ;clear timer counter zero
MOV TL0, #0
MOV TMOD, #5 ;timer 0 is an event counter, C/T=1, Mode 1
CLR OE
CLR T0
JB OE, AGAIN
JB T0, AGAIN ;Start timer 0 running
JMP TRANSMIT ;At any time, the event count can be extracted by reading TL0/TH0
;The events continue to be counted independent of actual activity, ie,
;are counted in the background.

READLIGHT:
SETB TR0
CALL DELAY
CLR TR0
MOV A,TH0
MOV R0,TL0
JMP TRANSMIT

TRANSMIT:
CLR RI ;Initialize receive flag
CLR TI ;Initialize transmit flag
MOV SCON, #50h ;Configure Serial Port for Mode 1 and enable receiver
MOV TMOD, #20h ;Configure the Timer 1 for 8 bit auto reload
MOV TCON, #40h ;Enable the Timer 1
MOV TH1, #0FDh ;Set Baud Rate

Send:
MOV SBUF, A ;Transmit high data(light) byte
JNB TI, $ ;Wait for serial word to be sent
CLR TI
MOV SBUF, R0 ;Transmit low data(light) byte
JNB TI, $ ;Wait for serial word to be sent
CLR TI
JMP READLIGHT

DELAY:
mov R1, #0FFh
mov R2, #0FFh
mov R3, #0F0h
Loop:
djnz R1, Loop
djnz R2, Loop
djnz R3, Loop

RET

END



Thanks,
Corey C.

List of 3 messages in thread
TopicAuthorDate
TSL230 - Light to Frequency            01/01/70 00:00      
RE: TSL230 - Light to Frequency            01/01/70 00:00      
RE: TSL230 - Light to Frequency            01/01/70 00:00      

Back to Subject List