Ryan Poethke (Customer) asked a question.

PWM outputs on the BRX

What's the technical limitation that prevents the use of PWM functionality on all the built-in outputs on a BX-DM1E-18ED13-D? Computing horsepower of the microprocessor in the PLC?

 

I have an application where the client wants to control the brightness of up to (8) indicator lights on a panel (not just on/off). I know I could buy multiple HSIO cards to get that functionality, but that's a lot of money for some blinkin-lights.

 

Alternatively, any chance of a PWM card with (8) or (16) outputs? This application doesn't require the extra functionality of a HSIO card.

 

 

Thanks,

 

Ryan Poethke


  • HOST_BobO (AutomationDirect)

    That would be scan dependent, and may or may not work as well as you like, but yeah that could work.

     

    I would personally probably use a timer interrupt and immediate output instructions. Under Interrupts, setup a single timer as recurrent at 500us. Add an ISR.

     

    In the ISR:

    // Count 0 to 19 to create 100Hz base freq

    MATH V0 = if(V0 < 19, V0 + 1, 0)

    // Add rung for each output x, V0x is duty cycle range of 0 - 20...0 = off, 20 = on

    STRLT V0, Vx

    OUTI Yx

     

    Just threw it together to test. Worked beautifully. ISR latency is 7-8us and the execution time is about 35us, which should produce a far better result than FLASHER and virtually indiscernible from the hardware PWM.

     

    image

    Expand Post
    Selected as Best
  • PouchesInc (Customer)

    I dont have the answer to your question, but I was wondering how well the dimming actually works in your testing? I assume you are basically pulsing the 24v more/less often with duty cycle changes to produce a lower average voltage to the LED to get the brightness down? Is there quite a bit of a brightness curve with the voltage change? And how low average voltage can you get before the LED simply wont turn on anymore? This is an interesting application of the PWM to indicator lights I hadnt thought of.

    Expand Post
    • Ryan Poethke (Customer)

      I've used the PWM outputs on a BRX to control a Red-Green-Blue indicator light on a panel, and it worked extremely well. Those type of LED indicators are set us as constant-voltage, and so PWM dims them with an almost perfectly linear dimming curve. It does get a little wonky down at 1 or 2%, as the eye can percieve very small changes in inensity, especially in low light conditions.

       

      I could pretty much set the color and intensity as I wished, and blink/flash it for additional meaning / attention getting. I'd love to use PWM on multi-color indicators more, but the current project that could use it can't really absorb the cost of two HSIO cards just to control panel lights.

       

      Dialight makes a nice series of 22mm RGB panel-mount indicators. They're getting used on an upcoming project, if funding comes through. They'd be a perfect fit for very versatile panel indicators.

       

       

      Ryan Poethke

      Expand Post
  • HOST_BobO (AutomationDirect)

    PWM channels are not software based. They use dedicated FPGA cores, and there simply isn’t enough room in the FPGA to do all possible functions on every output.

     

    You could possibly create additional PWMs from either interrupts or TDOs tied to timers.

    • Ryan Poethke (Customer)

      Would the Flasher instruction work? I see I can vary the ON and OFF times, down to 1ms. Will the sinking outputs respond as I'd expect at that on/off rate? I don't really need to vary the PWM value on the fly, just make it a set "dimmed" value and use that in logic.

       

      I'd set up three different flasher instructions as follows, and use their C-bit outputs as necessary:

       

      1ms ON, 3ms OFF for 25% brightness

      2ms ON, 2ms OFF for 50% brightness

      3ms ON, 1ms OFF for 75% brightness

       

      Thoughts on "poor man's PWM?"

       

       

      Thanks,

       

      Ryan Poethke

      Expand Post
      • HOST_BobO (AutomationDirect)

        That would be scan dependent, and may or may not work as well as you like, but yeah that could work.

         

        I would personally probably use a timer interrupt and immediate output instructions. Under Interrupts, setup a single timer as recurrent at 500us. Add an ISR.

         

        In the ISR:

        // Count 0 to 19 to create 100Hz base freq

        MATH V0 = if(V0 < 19, V0 + 1, 0)

        // Add rung for each output x, V0x is duty cycle range of 0 - 20...0 = off, 20 = on

        STRLT V0, Vx

        OUTI Yx

         

        Just threw it together to test. Worked beautifully. ISR latency is 7-8us and the execution time is about 35us, which should produce a far better result than FLASHER and virtually indiscernible from the hardware PWM.

         

        image

        Expand Post
        Selected as Best
      • Ryan Poethke (Customer)

        Thanks, BobO! It's a real privilege to have you as a resource on this forum.

         

        Out of curiosity, would this approach work if I were to use it with DO expansion cards? Will an expansion card's outputs respond fast enough?

         

         

        Sincerely,

         

        Ryan Poethke

        Expand Post
      • HOST_BobO (AutomationDirect)

        You're welcome!

         

        Sorry, no. The OUTI instruction you need only works with onboard outputs and (if memory serves) HSIO outputs.

         

        One other note, with the -18 you are using, only the first 4 outputs are high speed, but this will still work well enough with the standard outputs. I moved my test to Y4-Y7 and it still worked fine. Maybe a touch more variability between the outputs, but that's pretty subjective. With the slower outputs, you could increase the timer counts to 39, to decrease freq to 50hz, I don't see much flicker at 50hz.

         

        Don't panic if you see it, but the output leds are aliasing at 50hz. They are blinking much slower than the real rate, making it look like it isn't working. I have them looped back to a high speed input though, and they are glowing as expected. It's just the output syncing/unsyncing with the led update creating the illusion.

        Expand Post
      • Ryan Poethke (Customer)

        BobO,

        I'm not too concerned about the dimming being perfect. It just has to be good enough; these are pushbutton indicator lights for stagehands so not for public consumption. If the flicker is objectionable, I can always hang a 100uf filter cap across each indicator light if needs be.

         

        Thanks again.

         

         

        Sincerely,

         

        Ryan Poethke

        Expand Post