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,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    No, you replace the 270R with a 330R, the higher value of the bottom resistor the greater the voltage will be at the junction of the two resistors.

    Use Ohms law to calculate the voltages on the divider.:)

    EDIT: I use PIC Start Plus.. with MPLAB
     
  2. futz

    futz Active Member

    Joined:
    Sep 15, 2007
    Messages:
    2,043
    Likes:
    24
    Location:
    Vancouver, B.C.
    PICkit 2 or Junebug! You won't be sorry. Both are excellent, and inexpensive.
     
  3. bananasiong

    bananasiong New Member

    Joined:
    Mar 7, 2006
    Messages:
    1,893
    Likes:
    7
    Location:
    Malaysia
  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

    Thanks for all the replies, i am currently using EPIC Programmer which is using parallel port. It seem to not program sometimes.This is the reason why i need to find a new programmer.i'll take a look at above link and see which one is suitable for me,thanks guy! =)
     
  6. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ericgibbs i had tried your method which is using 680 and 330 it gave me 4.x V for the output to uC but my LED not lit at all. why is the course for this i wonder? not enough current to drive the LED? or what?
     
  7. mister_e

    mister_e New Member

    Joined:
    Jul 14, 2006
    Messages:
    350
    Likes:
    2
    Location:
    Montreal, Canada
  8. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    Hi mesamune,
    The supply to the LM393 is +12V, I am assuming you are using a RED LED. which should have a forward voltage drop of about 2V.

    So that leaves about 10V across the 680R and 330R divider, the current thru the divider will be 10V/1010R = 10mA,
    so across the 330R there will 0.01*330R= 3.25V + the LED Vfwd = 5.25V.

    The LM393 has an open collector output, so as the output transistor in the LM393 is OFF, it will not sink any current and load the divider.
    Also the input impedance[resistance] of the PIC input is a fairly high impedance it will not load the divider.

    So ALL the current flowing in the resistors 680R and 330R in series will flow thru the LED, as the current is about 10mA
    the LED should glow.!

    Could you post the diagram with voltages marked at the top of the 680R, the junction of the 680R and 330R ,
    also the voltage across the LED.

    You must have a fault elsewhere, are you sure that the PIC pin is set as an Input.?

    Lets know.:)

    EDIT: checking your figures that gave you +4V.... I suspect that the LED is blown short circuit.
    Assume that the LED is blown s/c... so 12V/1010 = 11.8mA... 11.8mA * 680R = 3.9V. [You measure 4V.!]
     
    Last edited: May 6, 2008
  9. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    I am using EWB 8.0 to do this circuit simulation,but afer i configure the circuit to what you mentioned earlier it gave me this result:
    i am using LM339N for comparator in my circuit (quad type )
    Anything wrong with my circuit?
     

    Attached Files:

  10. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    Hi Mister E ,my EPIC keep on promp me "code verify error at 0000" 3FFF should be 118A,continue verifying?
    i duuno why suddently become like this i already used it long time ago,no problem. ;(
     
  11. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    I'll look thru the circuit.
     
  12. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ya i had just tried out with my hardware.....hehe it works! but the voltage i measure to my uC is 5.25V when out of the Low lmt window =)
    i wonder why the simulation cannot show the lit LED =.=''
     
    Last edited: May 6, 2008
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    Hi,
    Checked the circuit looks ok, refer this attachment.

    I would suggest that you increase the 680R to about 750R or 820R, so that the input voltage to the PIC is just under +5V.

    EDIT: If you plan to use a second input pin on the PIC for the other LM output, change the 1K0 to 750R and 330R .. OK?
     
    Last edited: Jul 7, 2008
  14. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    okay,ya i need my uC to monitor this two limit ,when the input just out from the windows then the corresponding upper and lower lmt pin will act accordingly. :) actually i am using it for stepper motor.i will send pulse to the motor driver and move my motor up or down precisely. ('',)
     
  15. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    Lets know how the project goes..:)
     
  16. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    Alright. :) now i am doing the hardware part and also the programming part.
     
  17. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    eric, there is one problem i encounter when i disconnect the uC the LED lit but when i connect to one of the I/O pin RC.6 the LED goes off. can i add anything to prevent this? Thanks
     
  18. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    It sounds as though you have configured PORTC.6 has an Output which is set low.
    Post your code and we will advise.:)
     
  19. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    This is just the test code i used:

    '*********************************************************
    'Declarations of variables
    '*********************************************************

    Dim an4 As Word 'analog input RA5
    Dim an5 As Word
    Dim an6 As Word
    Dim a4 As Byte
    Dim a5 As Byte
    Dim a6 As Byte
    'Dim dir1 As Bit 'direction for motor1
    'Dim dir2 As Bit 'direction for motor2
    Dim i As Byte
    Dim n As Byte
    Dim n2 As Byte

    a4 = an4.LB
    a5 = an5.LB
    a6 = an6.LB
    Symbol dir1 = PORTC.1
    Symbol dir2 = PORTC.2

    TRISC = %00001111

    loop:


    If PORTC.6 = 1 Then

    dir1 = 0
    High PORTC.0
    WaitUs 500
    Low PORTC.0
    WaitUs 500



    Endif
    Goto loop
     
  20. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    hi,
    TRISC = %00001111

    loop:
    Code (text):
    If PORTC.6 = 1 Then

    dir1 = 0
    High PORTC.0
    WaitUs 500
    Low PORTC.0
    WaitUs 500
    Endif
    Look at the TRISC..... 0 = 0utput... 1 = 1nput
     
  21. mesamune80

    mesamune80 New Member

    Joined:
    Oct 14, 2004
    Messages:
    117
    Likes:
    0
    Location:
    Malaysia
    ya,from the above code i already se it as input right?
     

Share This Page