display on the LCD-HELP PLEZ-

Discussion in 'Embedded Systems and Microcontrollers' started by zeeba, Dec 20, 2010.

  1. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    Hi everybody
    I'm using assembly and PIC16F876A
    I want to Read two analogue inputs from two LDRs and display them on the LCD.

    I wrote a code but the problem is :

    the readings on the LCD are almost the same even if there is a difference between the lighting on the LDRs.
    I used the volt meter to measure, there is a difference in volts that's mean there is a difference between the lighting on the LDRs but the readings on the LCD almost the same.

    It suppose to be two lines: line1 to read from LDR1 and line2 to read from LDR2 but as I said the two readings are the same

     
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    This really should be posted in Embedded Systems and Microcontrollers.

    And it probably has nothing to do with the LCD itself.

    Did you try debugging your code to see if the values are different there?


    Post your schematic and post your code that initializes the ADC and the code that reads the ADC.
     
  3. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    yes I'm sure it has nothing to do with the LCD it is something in the code
    but I don't know what is it.should I put more delay between reading the channels? or it has nothing to do with that?
     
  4. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    990

    Yes, you will need to give time for your decoupling caps to charge. You are using decoupling caps on the ADC inputs right?

    Most humans will not be able to see changes that fast anyway. There should be little reason to update your display any less then once every few seconds or so.
     
  5. electro_yas

    New Member

    Dec 20, 2010
    15
    0
    Try and display by several led first and see whether its is changing according to the voltage,
     
  6. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    No Im not using any capacitors only LDRs and variable resisters at the input
     
  7. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Can you post a schematic and your source code?

    You may be reading the same result twice without realizing it, or some other oddity. I usually suggest a C compiler for most 16F apps for people relatively new to uCs.

    A decent compiler typically produces tighter/smaller code with better "practices" on memory and register use than somebody starting out in assembly. You still have the option of generating an .asm file from the C source to tweak if needed. Both Boost C and MikroC are common here, and the free versions aren't so strict as to not compile most "hobbyist" programs.
     
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    You should be using .1 mfd decoupling caps on the inputs of those ADCs. Check the sticky at the top of the General Electronics forum.

    And as thatoneguy suggests, you should use C. It will be far easier. The 18F series is optimized for C but the 16F will work.
     
  9. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    howe should I connect the capacitors on the inputs of those ADCs?
     
  10. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    990

    Read the sticky thread in General Electronics as I suggested.
     
  11. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    right now my code is fine the only problem I have now that the LDRs read different readings but there is no output from the pic.

    without the ldrs, when I put different voltages instead of them I get an outout from the pic

    that means there is a problem in the LDR circuit right? how can I solve it?

    Im connecting them same as this picture

    [​IMG]

    are you suggesting to connected a capacitor instead of 10k resister?
     
    Last edited: Dec 24, 2010
  12. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    What do you mean "there is no output from the pic"?

    Tell me about the LDRs. What is their resistance range?

    What voltage level is connected to the LDRs?


    The caps go from the input pin to ground. But please read the post I mentioned.
     
  13. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    I mean when I meagure the output voltage from the pic it is 0.5V only which is not enough to move the DC motor

    The LDRs and the pic are connected to 5V also the motor needs 5V from the pic to rotate
     
  14. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    which input do you mean is it from the 5v input or the pic input?
     
  15. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
  16. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    Did you read the thread I suggested?

    The cap goes from each ADC input to ground.

    You should also have a cap from your VDD to ground.
     
  17. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I though the output was an LCD, now there is a motor?

    Please provide a complete schematic and source code. We seem to be running in circles without the full information.
     
  18. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    990
    I agree. This is getting frustrating. Sounds like we are only getting half the story.

    An explanation how everything is expected to work would also be helpful.
     
  19. zeeba

    Thread Starter New Member

    Sep 26, 2010
    22
    0
    Im doning sun tracker so I have the LDRs as sensors to the sun light .

    the pic will take their readings and display on the LCD then it should compare and give an order to the DC motor to rotate in the light direction.

    Now I reached to the part where the pic should rotate the motor but it didn't.
    so I measured the output from the pic to the motor it was 0.5V only when it should be 5V !!!!
     
  20. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Is the ADC problem fixed?

    A PIC cannot directly drive a motor, you will need a motor driver, to recommend one, we need information about the motor and load the motor will be moving.

    code and schematic will help a lot for things overlooked and potential other issues.
     
Loading...