Jump to content
ELFORUM - Forumul electronistilor

ma ajuta cineva cu o idee de citire senzor digital ? p16f876


Guest danielmx

Recommended Posts

Guest danielmx

vreau sa citesc acest sensorhttp://www.pololu.com/catalog/product/961 pe portulB la pic16f876a... cand este pozitionat deasupra unei linii negre ar trebui sa am "1" pe pinul respectiv iar cand am alb...ar trebui "0". Problema mea este ca nu reusesc sa citesc acest sensor "digital .."

asta este codul meu de citire in care am urmat pasii din datasheet:

[list=]The typical sequence for reading a sensor is:

 

1.Turn on IR LEDs (optional)

2.Set the I/O line to an output and drive it high

3.Allow at least 10 us for the 10 nF capacitor to charge

4.Make the I/O line an input (high impedance)

5.Measure the time for the capacitor to discharge by waiting for the I/O line to go low

6.Turn off IR LEDs (optional)

These steps can typically be executed in parallel on multiple I/O lines.

 

 

 

 

>citsenz:        bsf STATUS,RP0  movlw b'00000000'   movwf TRISB         ; 1) setare portb iesire   bcf STATUS,RP0   movlw b'11111111'                             ;    drive it high pt incarcarea condens  movwf PORTB    call delay10us                               ;asteapta ~10us sa se incarce cond   bsf STATUS,RP0  movlw b'11111111'                  ;portb = intrare  movwf TRISB      bcf STATUS,RP0  call delay1ms  call delay1ms    movf PORTB,0                                   ;citire senzor paralel cu pastrarea rezultatului in "citiresenzor"  movwf citiresenzor

 

Link to comment
  • Replies 0
  • Created
  • Last Reply

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines