pic 16f877a help required

Discussion in 'The Projects Forum' started by supahariz, Apr 24, 2011.

  1. supahariz

    Thread Starter New Member

    Sep 8, 2010
    15
    0
    hello all,
    i am new to pic and I'm having problems with a project i'm doing now.
    i have used a pic 16f877a to control 8 dc motors using 4 l293b h-bridge ic.
    i have used port a with port e (pin e0, pin e0) as input 1 for the h-bridge, port b pins as input 2 for the h-bridge, port d pins as enable inputs.
    i have used a 20Mhz oscillator with 33pf capacitors.

    my problem is, i am not getting the required voltage on any of the output pins.
    i need to get 5 volts on all the ports specified.
    but i am getting only 1.02v max.
    i am using ccs or pcw *pic c compiler v 4.023*
    please help me with this...

    i have attached .c and .h files as well

    thank you!
     
  2. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    Hello,

    I do not see any attached files.
    Can you also post the schematic, how the pic and l293's are connected?

    Bertus
     
  3. supahariz

    Thread Starter New Member

    Sep 8, 2010
    15
    0
    here are the .c and header files.
    please help.
     
  4. supahariz

    Thread Starter New Member

    Sep 8, 2010
    15
    0
    i have added the attachments,
    the schematic will be up shortly.
     
  5. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    Hello,

    Firts I am not very good in programming, but I see this many times in the c file:

    Code ( (Unknown Language)):
    1.  for(i=0; i<500; i++)
    2.    {
    3.    output_high(PIN_A1);
    4.    output_low(PIN_A1);
    5.    }
    6.  
    Af far as I understand the pin is set high and immediately low again.
    There is no delay in between, so there will be "needle" pulses at the output.

    Bertus
     
  6. supahariz

    Thread Starter New Member

    Sep 8, 2010
    15
    0
    here is the schematic for the same...
     
  7. supahariz

    Thread Starter New Member

    Sep 8, 2010
    15
    0
    sorry!! my bad,
    here is the correct schematic!!
     
    • IMG.jpg
      IMG.jpg
      File size:
      150.3 KB
      Views:
      26
  8. blacknewnew

    New Member

    Aug 19, 2010
    3
    0
    Agree, and i think before that, the related pins should be configured as OUTPUT
     
  9. supahariz

    Thread Starter New Member

    Sep 8, 2010
    15
    0
    okay, i changed the code, and still the problem persists!
    please have a look at the code..
    and yeah i have pre configured the outputs..
     
  10. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    Hello,

    Do you have any idea how long your for-loop will take?

    Does the compiler support delay commands?
    Then you can use those to create the delays between the pulses.

    BTW are you actualy building the circuit or are you simulating?
    If you are actualy building the circuit a logic probe will show you if the pulses are coming at the outputs.
    (it does not tell you how long the pulses are).
    Here I made a simple TTL logic probe:
    Project: TTL Logic probe.

    Bertus
     
  11. blacknewnew

    New Member

    Aug 19, 2010
    3
    0
    Some compilers would change the code from
    for(i=0; i<50; i++)
    {
    output_high(PIN_A1);
    }
    output_low(PIN_A1);
    like to
    output_high(PIN_A1);
    output_low(PIN_A1);
    if compilation optimization is turned ON, please check it(and there may be better ways to do the delay).
    if it still does not work, you can try to execute a very simple code first and measure the IO voltage, to make sure it works as you expected, like:

    void main()
    {
    //Add your port init code here

    output_high(PIN_A1); //A1 should stay high
    output_low(PIN_A0); //A0 should stay low

    while(TRUE);
    }
     
Loading...