how to use pic16f877a and lm3914

Discussion in 'Embedded Systems and Microcontrollers' started by kamalsolimen, Oct 27, 2014.

  1. kamalsolimen

    Thread Starter New Member

    Oct 3, 2014
    18
    0
    how to use pic16f877a and lm3914 to control ten led

    how i can program that and whats cricut

    how its work ?
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    My first guess is you don't.

    Both chips share having analog inputs, digital inputs, and digital outputs, plus of course either can or could drive LEDs.

    What is not there is an analog output from the PIC to drive the LM3914.

    Just what are you trying to accomplish?
     
    kamalsolimen likes this.
  3. kamalsolimen

    Thread Starter New Member

    Oct 3, 2014
    18
    0
    i try to turn leds like that in program

    value : led on
    1 : 1
    2: 2
    3: 3
    .
    .
    10 : 10
     
  4. kamalsolimen

    Thread Starter New Member

    Oct 3, 2014
    18
    0
    can i use PIC digital output pwm
    but what value to turn 1 led , 2 led if i have osc 4mhz
     
  5. adam555

    Active Member

    Aug 17, 2013
    858
    39
    I was asking myself the same question, and I think that if you add a capacitor to the PWM output it might work.

    For the values you need to divide the maximum value of the PWM by the number of LEDs, and multiply it by the value you want to output; assuming that Vcc lights all LEDs and 0v lights none. For example: to light LED 3, given that the maximum value of the PWM output is 256, would be:

    256/10 * 3

    Just tested it with an Arduino and a 100uF cap on the PWM output and seems to work; I get a fairly steady DC voltage output from 0v to 5v. I have no idea if it will be good enough for the lm3914; it's just a matter of giving it a try.

    ...

    Edit: I assume you know already that you have enough output pins on the 16F877a to drive the LEDs without the need for the LM3914.
     
    Last edited: Oct 27, 2014
    kamalsolimen likes this.
  6. kamalsolimen

    Thread Starter New Member

    Oct 3, 2014
    18
    0
    thanks i will try but is very diffecult
     
  7. adam555

    Active Member

    Aug 17, 2013
    858
    39
    I would be really interested in knowing if you get it working -I'm learning too- or to help if you need anything else.
     
  8. kamalsolimen

    Thread Starter New Member

    Oct 3, 2014
    18
    0
    sure i will , thanks
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    You have a PIC with 40 pins, why not use 10 of them to drive these 10 LEDs and ditch the LM3914?

    Otherwise you set the LM3914 to use the internal 1.2V reference, and the PWM to output a pulse with a DC average between 0 and 1.2V

    Each segment turn on at a multiple of the 1.2V reference, or 0, .12, .24,.36... 1.08, 1.2 volts. Note these are the transition points, so if you put say .12 volts in you cannot be sure if the lowest segment is on or off.... but it is definitely ON when you put in .12 + .12/2 or .18 volts, so base your increments on a base of .18 volts, or:

    .06V+ N*(.12V) where N is the highest LED you want ON.

    To produce the DC average you have to set the PWM to an appropriate setting. The general formula for the DC average is:

    Avg = Vdd * N / 1023 where Vdd is the supply voltage of the chip and N is the PWM setting.

    Thus for an N of 511 you get a DC average of just about 1/2 of Vdd. You can work out the N settings for the 11 states (no LEDs on thru 10 LEDs on) to work with this.

    Also you need a "RC" network here not just a C between the PWM output and the LM3914 input. You need a break frequency (1.6/RC) above the PWM frequency more is a better DC but a slower reaction to any change.
     
    adam555 likes this.
Loading...