1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Input For PIC uC

Discussion in 'Microcontrollers' started by mesamune80, Apr 30, 2008.

  1. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,180
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    I would estimate, using the motor data you supplied, that with a 50uSec, you have a shaft rotation speed of 2rev/sec.
    [ was that the speed.????]

    The best you can expect, I would say will be in the order of 10rev/sec.
     
  2. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ya,but tyhe motor speed seem to alter with my code
    if i use the following code:

    While PORTC.6 <> 0
    dir2 = 1 'CCW go down
    High PORTC.2 'pulse port for m2
    WaitUs 800
    Low PORTC.2
    WaitUs 800 '50
    count2 = count2 + 1
    Wend
    the motor turning with faster speed.
    when i used the while loop the motor turn faster if compare to for loop.

    For j = 0 To count2 Step 1

    dir1 = 0
    High PORTC.2
    WaitUs 800
    Low PORTC.2
    WaitUs 800
    Lcdcmdout LcdLine2Home
    Lcdout "M2 =", #count2
    Next j
    count2 = 0


    another thing i need to clearify is this :OPTEK Reflective object sensor as i attaced here

    i am driving it like a LED Vforward =1.7V using 12V i need to have 510R resistor as to limit the current.but i cannot get any voltage drop across the resistor.it should be around 10.3V theoritically. am i driving the wrong way? Thanks.
     

    Attached Files:

  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,180
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,

    The opto should be connected as this drawing.

    You should be able to measure 1.7V across the emitter diode.
     
    Last edited: Jul 7, 2008
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia

    yes,this is the way to connect the opto,but how about the transistor part?
    currently i am connecting pin 4 to +5V and pin 3 to grd via a 100k resistor.
    so if we siad the 100k as load resistor ,then how to size this resistor for me to pump in this input to my uC ?
     
    Last edited: Jun 4, 2008
  6. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,180
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    Hi,
    This the question I answered.?

    Pin 3 of the opto goes to 0V, pin 4 is the collector of the opto transistor.
    Use a 10K resistor from pin 4 to +5V.
    Connect pin 4 to the input pin of the PIC.
    If the 10K dosnt give enough voltage swing on pin4, when the opto slot is blanked/open, then try a 22K.

    Do you follow.?
     
  7. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ok i'll try it now ^^
     
  8. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    Ok, i just tested just now and this is the result,i think may be 22k still not enough for the voltage swing thingy....=_='

    when the opto expose to light voltage to uc pin = 4.99V

    when somethin is blocking the opto from the light ,voltage to uc pin = 4.15V

    which cannot get a clean 0V when no light exposure.
     
    Last edited: Jun 4, 2008
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,180
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    As you say, try higher resistance values.
    If you cannot get enough swing, you will have to add an amplifier between the opto pin4 and the PIC. A single transistor amp should be OK.
     
  10. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ya if i used 100 k then the change is significant for pic to differentiate Hi and Low .i think higher value would be better.
     

Share This Page