ADC and POTENTIOMETER with Voltage Range

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

ADC and POTENTIOMETER with Voltage Range

1,212 次查看
MOSREJLS
Contributor I

Hi everyone

I'm new to this, but my teacher already gave us an excersise using the ADC with a voltage range I explain myself (im using MCS9S08LC60 8-bit)

 

We move the Potentiometer, when it reaches 1.9 (from 0 to 1.9 volts, one led will turn on)

When whe move it to 1.3 (from 1.9 to 0) the same led will turn of)

its not necessary to show the value of the voltage but I don't really know anything, I only know how to make the conversion from ADC to binary the eight leds.

Any info well be apreciated

thanks :smileyhappy:.

标签 (1)
0 项奖励
回复
2 回复数

415 次查看
MOSREJLS
Contributor I

I did this:

code section
;
            ORG    ROMStart

_Startup:
            LDHX   #RAMEnd+1        ; initialize the stack pointer
            TXS
            JSR confADC
           
            MOV #$E0,PTADD
            MOV #$FF,PTBDD
            CLI                     ; enable interrupts


fin:

            feed_watchdog       
            BRA fin

confADC:   
            LDA #$60
            STA ADCCFG
            STA ADCSC1
            RTS
                   

intADC:
            LDA ADCRL
            CBEQA #$00, OFF_PTA7
            CBEQA #$64, OFF_PTA7 
            CBEQA #$93, ON_PTA7
            CBEQA #$FF, ON_PTA7
            RTI
          
 
ON_PTA7:    BSET 7, $0000
            RTI
           
OFF_PTA7:   BCLR 7, $0000
            RTI

 

The first led turns on at a certain voltaje and then it turns off at a certain voltaje, I did some calculations and at my opinion It turns on at 1.9 V and it turns off at 1.3 volts (#$93 and #$64)

any opinions?????

0 项奖励
回复

415 次查看
admin
Specialist II

Not looking at anything but your IntADC routine, I can see why you may be having trouble with it.

 

You are turning the LED on or off when it EQUALS your threshold points. It would be easy for the ADC to have skipped some values as the pot is turned, so you want to turn the LED on or off when the value is above or below your threshold points, kinda like this:

 

LDA ADCRL

CMP #$64

BLS OFF_PTA7

CMP #$93

BHS ON_PTA7

RTI 

0 项奖励
回复