Time multiplexing

Discussion in 'Embedded Systems and Microcontrollers' started by msr, Oct 16, 2010.

  1. msr

    Thread Starter Active Member

    Jul 8, 2008
    62
    1
    Hello,

    Im using a PIC24F and I need to do the following: time multiplexing of two LEDs. I mean, at a given time the "LEDx" is ON and "LEDy" is OFF and another time the opposite. This is done at a fixed frequency (~ 200Hz).

    I thought of using PWM with small duty cycle (~ 1%) for more efficient use of battery. An LED is always ON on the positive edge of the PWM. For example, if a frequency of 1 kHz is used, each LED will light 500 times.

    However, I do not know whether I have enough control over the PWM to do this. Is there a way of knowing that Im on the positive edge of the PWM? In terms of code, I need to know what LED is being excited. I dont know if I can do that using PWM.

    I dont have much experience in programming MCUs but I did read something about Capture module... Can I detect the positive edges of the PWM with one of these modules?

    When an LED lights I need to do some processing, for example from an ADC. This processing is different for each LEDs, thats why I need to know what the LED PWM is exciting.

    Thanks
     
  2. wannaBinventor

    Member

    Apr 8, 2010
    179
    4
    I must admit that I've had a bit of alcohol this fine evening, so I can't say I understand everything your asking......

    but what about putting two LEDs on a port that can source AND sink current.

    For one, go "Vdd to resistor to anode to cathode to pin." This will be one when the pin is low and off when high. For the other LED go "Pin to resistor (not the same resistor as the other LED) to anode to cathode to ground."

    Once again, I'm kinda toasted and this may be the worst idea ever.
     
Loading...