revolution counter


Closed Thread
Results 1 to 30 of 30

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I have light to voltage chip,
    That's a SOLAR CELL!

    reading the encoder, the encoder is divided into 4 sections, 2 white and two black, read black show ADC below 127 and white ADC above 127.
    I get the feeling you might end up making a small program just to test the ability of your sensor to read the black/white patches in the first place rather than assuming your sensor/PIC will read everything the way you hope it will. Something like this:

    Code:
    ........setup.........
    ledout var port...some port here
    main: adcon0.2=1 'Start Conversion
    waitonadc: if adcon0.2 = 1 then waitonadc
    oldoutput_pot = adresh *256 + adresl
    if oldoutput_pot > 127 then
         ledout = 1
    else
         ledout = 0
    endif
    goto main
    Change the value 127 above to find a 'trip point' for the counter itself.
    See what happens with that. If that works for you, then you should be all set.
    (Also, you may want to check the manual for your use of the ADCIN command)

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by skimask View Post

    That's a SOLAR CELL!
    Not compulsory ...

    OPB 608/704 / CNY 70 i.e. are reflective Opto-couplers ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I just want to count the revolution, so even if the trip point is not on the 'dot' it do not matter. What matters here is that I want to be able to calculate the transitions from black to white and white to black. After four transistions I get a revolution .
    The problem in my program is that it is not showing anything on the LCD.

    ken

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    crap.. I forgot to define my ADC:

    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    ken

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    crap.. I forgot to define my ADC:

    Define ADC_BITS 8 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS

    ken
    So it is working now???
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    I dont know if it works, I m at work now, I will see when I get home tonight

    skimask, what do you mean by tripping?
    :is this it...

    ADCON0.2 = 1 'Start Conversion
    ADCIN 1, Output_Pot 'analog pin 1 (RA1) get the 8 bit result

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Ok, I see there's 2 places where I could be 'tripping' !

    1st tripping - by that I mean the point where the ADCIN routine distinguishes between the light and dark area of the disc.

    2nd tripping - Do you see this phrase anywhere in the manual?
    Code:
    ADCON0.2 = 1 			'Start Conversion
    I.E. YOU don't need to start the A/D conversion, ADCIN does that for you.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    I just want to count the revolution, so even if the trip point is not on the 'dot' it do not matter. What matters here is that I want to be able to calculate the transitions from black to white and white to black. After four transistions I get a revolution .
    The problem in my program is that it is not showing anything on the LCD.
    Right, but if it's not tripping in the first place, you won't get any counts in the last place...
    And the ADC, yes, that's part of it. The other part is 'starting' the ADC itself.

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    The problem in my program is that it is not showing anything on the LCD.
    Or is this the problem
    Code:
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits) '4 therefore put wire at 4, 5, 6 and 7 of LCD
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 07:14
  2. Counter not counting !!!
    By lerameur in forum mel PIC BASIC Pro
    Replies: 24
    Last Post: - 20th February 2009, 23:15
  3. Replies: 42
    Last Post: - 14th January 2008, 12:38
  4. 20 Digit Virtual LED Counter
    By T.Jackson in forum Code Examples
    Replies: 9
    Last Post: - 19th November 2007, 06:02
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 18:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts