Loading ...
Sorry, an error occurred while loading the content.

Re: 3 Channel PWM library

Expand Messages
  • jan_steckel
    Hi Jm Thanx for the code, it is verry usefull. Pitty I can t try it right now, I am at school... When I come home, it will be the first t hing to do! (after
    Message 1 of 20 , Apr 1 12:05 AM
    • 0 Attachment
      Hi Jm
      Thanx for the code, it is verry usefull. Pitty I can't try it right
      now, I am at school... When I come home, it will be the first t hing
      to do! (after eating of course ;) )

      I'll let you know how it works.
      But I got some questions about the code:

      what is this:
      var byte pwm1 = 10
      var byte pwm2 = 128
      var byte pwm3 = 240

      can I set here the intensity of the leds? (the higher the better? )
      and what is the max value?

      Greetings
      Jan



      --- In jallist@yahoogroups.com, Jm Valera <imjm@s...> wrote:
      > Somewhere in your code, define 'red, green, blue' and associate it
      to your
      > pins.
      >
      > ----
      >
      > var bit ppwm1 = on
      > var bit ppwm2 = on
      > var bit ppwm3 = on
      > var byte count = 0
      >
      > var byte pwm1 = 10
      > var byte pwm2 = 128
      > var byte pwm3 = 240
      >
      > forever loop
      >
      > if ( ppwm1 ) then
      > red = ( count < pwm1 )
      > end if
      >
      > if ( ppwm2 ) then
      > green = ( count < pwm2 )
      > end if
      >
      > if ( ppwm3 ) then
      > blue = ( count < pwm3 )
      > end if
      >
      > count = count + 1
      >
      > end loop
      >
      >
      > ----
      >
      > ppwm* enables or disables the pwm generator for that pin. Turn it
      off to
      > to speed up the loop when your generator doesn't need to create a
      PWM on
      > that pin. This is an optomization technique and will produce a
      higher
      > frequency if used properly.
      >
      > - Jm
      >
      >
      > On Wed, 31 Mar 2004, jan_steckel wrote:
      >
      > > Hi
      > > I want to make an RGB led controller, that creates "mood-lights",
      > > and where you can choose the intensity of each color. I thouht to
      > > control each color by PWM. What my frequency requirements are, im
      > > not shure... someone told me to have at least 100 pulses per
      second,
      > > so i think at least 100 Hz?
      > >
      > > Where can i find the code?
      > >
      > > Jan
      > >
      > >
      > > --- In jallist@yahoogroups.com, Jm Valera <imjm@s...> wrote:
      > > > I have PWM code (not exactly 'library' quality, but I wouldn't
      mind
      > > > getting it there) that can generate 5 PWM channels. It can be
      made
      > > to
      > > > generate more or less channels depending on your requirements.
      > > >
      > > > What is this going to be used for?
      > > >
      > > > What are your frequency requirements?
      > > >
      > > > - Jm
      > > >
      > > >
      > >
      > >
      > >
      > >
      > >
      > > Yahoo! Groups Links
      > >
      > >
      > >
      > >
      > >
    • Jm Valera
      yes ... 0 is off, 128 is 50% brightness, 255 is full brightness. - Jm
      Message 2 of 20 , Apr 1 3:04 AM
      • 0 Attachment
        yes ... 0 is off, 128 is 50% brightness, 255 is full brightness.

        - Jm

        On Thu, 1 Apr 2004, jan_steckel wrote:

        > Hi Jm
        > Thanx for the code, it is verry usefull. Pitty I can't try it right
        > now, I am at school... When I come home, it will be the first t hing
        > to do! (after eating of course ;) )
        >
        > I'll let you know how it works.
        > But I got some questions about the code:
        >
        > what is this:
        > var byte pwm1 = 10
        > var byte pwm2 = 128
        > var byte pwm3 = 240
        >
        > can I set here the intensity of the leds? (the higher the better? )
        > and what is the max value?
        >
        > Greetings
        > Jan
        >
        >
        >
        > --- In jallist@yahoogroups.com, Jm Valera <imjm@s...> wrote:
        > > Somewhere in your code, define 'red, green, blue' and associate it
        > to your
        > > pins.
        > >
        > > ----
        > >
        > > var bit ppwm1 = on
        > > var bit ppwm2 = on
        > > var bit ppwm3 = on
        > > var byte count = 0
        > >
        > > var byte pwm1 = 10
        > > var byte pwm2 = 128
        > > var byte pwm3 = 240
        > >
        > > forever loop
        > >
        > > if ( ppwm1 ) then
        > > red = ( count < pwm1 )
        > > end if
        > >
        > > if ( ppwm2 ) then
        > > green = ( count < pwm2 )
        > > end if
        > >
        > > if ( ppwm3 ) then
        > > blue = ( count < pwm3 )
        > > end if
        > >
        > > count = count + 1
        > >
        > > end loop
        > >
        > >
        > > ----
        > >
        > > ppwm* enables or disables the pwm generator for that pin. Turn it
        > off to
        > > to speed up the loop when your generator doesn't need to create a
        > PWM on
        > > that pin. This is an optomization technique and will produce a
        > higher
        > > frequency if used properly.
        > >
        > > - Jm
        > >
        > >
        > > On Wed, 31 Mar 2004, jan_steckel wrote:
        > >
        > > > Hi
        > > > I want to make an RGB led controller, that creates "mood-lights",
        > > > and where you can choose the intensity of each color. I thouht to
        > > > control each color by PWM. What my frequency requirements are, im
        > > > not shure... someone told me to have at least 100 pulses per
        > second,
        > > > so i think at least 100 Hz?
        > > >
        > > > Where can i find the code?
        > > >
        > > > Jan
        > > >
        > > >
        > > > --- In jallist@yahoogroups.com, Jm Valera <imjm@s...> wrote:
        > > > > I have PWM code (not exactly 'library' quality, but I wouldn't
        > mind
        > > > > getting it there) that can generate 5 PWM channels. It can be
        > made
        > > > to
        > > > > generate more or less channels depending on your requirements.
        > > > >
        > > > > What is this going to be used for?
        > > > >
        > > > > What are your frequency requirements?
        > > > >
        > > > > - Jm
        > > > >
        > > > >
        > > >
        > > >
        > > >
        > > >
        > > >
        > > > Yahoo! Groups Links
        > > >
        > > >
        > > >
        > > >
        > > >
        >
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
      • Jm Valera
        Can anyone out there point me in the right direction on this? - Jm
        Message 3 of 20 , Apr 2 2:25 PM
        • 0 Attachment
          Can anyone out there point me in the right direction on this?

          - Jm

          On Wed, 31 Mar 2004, Jm Valera wrote:

          > Given (borrowed from someone's software PWM library):
          >
          > ----
          >
          > procedure PWM_lum_OUT(byte in PWM, byte in TRA) is
          >
          > var byte LoPWM
          > var byte HiPWM
          > assembler
          >
          > local PWMa
          > local PWMb
          > local PWMtra
          > local PWMend
          >
          > bsf status, status_rp0
          > movlw 0b_1000_0011
          > OPTION
          > bcf status, status_rp0
          > movf PWM, W
          > movwf LoPWM
          > sublw 0xFF
          > movwf HiPWM
          >
          > PWMa:
          > bcf INTCON, intcon_t0if
          > movf HiPWM, W
          > movwf TMR0
          > PWMb:
          > bsf pin_b7
          > call PWMtra
          > bcf INTCON, intcon_t0if
          > movf LoPWM, W
          > movwf TMR0
          > bcf pin_b5
          > call PWMtra
          > decfsz TRA,f
          > goto PWMa
          > goto PWMend
          >
          >
          > PWMtra:
          > btfss INTCON, intcon_t0if
          > goto PWMtra
          > return
          >
          > PWMend:
          >
          > end assembler
          >
          > end procedure
          >
          >
          > ----
          >
          > I want to call this procedure and have it do it's thing on a pin that I
          > define as an arguement to the procedure call.
          >
          > I see the line:
          > bsf pin_b7
          >
          > within the code, but can't figure out how to have this set by an argument
          > into the JAL procedure.
          >
          > In a nutshell, I want to be able to call:
          >
          > PWM_lum_OUT(20, 250, pin_b3)
          > PWM_lum_OUT(20, 250, pin_b2)
          > PWM_lum_OUT(20, 250, pin_b5)
          >
          > I currently have the above method copied 5 times with 'bsf pin_b?' as the
          > only line that's different, but have just run out of code space on my
          > 16f628 and want to condense this a bit.
          >
          > Please advise.
          >
          > Thanks!
          >
          > - Jm
          >
          >
          >
          >
          > Yahoo! Groups Links
          >
          >
          >
          >
          >
        • special [k]
          ... related ... I actually made one up just for this reason this morning and posted a request to the ring keeper ! The page is at http://www.wahoo-
          Message 4 of 20 , Apr 2 7:37 PM
          • 0 Attachment
            --- In jallist@yahoogroups.com, Vasile Surducan <vasile@s...> wrote:
            >
            > Special ka, would you consider to join with your web site (jal
            related
            > work) to http://x.webring.com/hub?ring=jal ?
            >
            > thank you,
            > Vasile
            > http://surducan.netfirms.com

            I actually made one up just for this reason this morning and posted a
            request to the "ring keeper"! The page is at http://www.wahoo-
            wa.net/PICprojects/
            I know the code isn't commented and I need to give more information,
            but I was excited to post it none-the-less!

            -special [k]
          • Eur van Andel
            ... Weird that you need a UN2003 to drive the gates of the FETs. Can t your PIC do that? -- Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V.
            Message 5 of 20 , Apr 6 8:34 AM
            • 0 Attachment
              On Wed, 31 Mar 2004 12:00:08 -0800 (PST), Jm Valera <imjm@...> wrote:

              >For LEDs, 300hz actually produces a visible flicker.
              >
              >I too am using JAL for an RGB led controller.
              >
              >Check out my website dedicated to blinky lights:
              >
              > http://www.svlife.com/blinkylights/
              >
              >Of possible interest to you would be the top two links, 'circuit' is
              >what I am using to drive my LEDs. That circuit is capable of driving
              >roughly 1000 LEDs.
              Weird that you need a UN2003 to drive the gates of the FETs. Can't your PIC do
              that?


              --
              Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
              Wierdensestraat 74, NL-7604 BK Almelo, The Netherlands eur@...
              phone +31-546-491106 fax +31-546-491107 mobile +31-653-286573
            • Eur van Andel
              ... You can t. Think about it. It is in flash memory. These are the constraints of a Harvard architecture. ... 20 and 250 being what? called as above, these
              Message 6 of 20 , Apr 6 8:50 AM
              • 0 Attachment
                On Wed, 31 Mar 2004 12:31:57 -0800 (PST), Jm Valera <imjm@...> wrote:

                >I want to call this procedure and have it do it's thing on a pin that I
                >define as an arguement to the procedure call.
                >
                >I see the line:
                > bsf pin_b7
                You can't. Think about it. It is in flash memory. These are the constraints of
                a Harvard architecture.

                >In a nutshell, I want to be able to call:
                >
                > PWM_lum_OUT(20, 250, pin_b3)
                > PWM_lum_OUT(20, 250, pin_b2)
                > PWM_lum_OUT(20, 250, pin_b5)
                20 and 250 being what?

                called as above, these pins will PWM AFTER each other.
                If you want them to PWM all together, you might need an ISR.
                This ISR might screw up your comms routine.

                Do you mind non- or erroneous blinking during comms?
                Do you mind lost comms, so you'll have to send the msg again?

                >I currently have the above method copied 5 times with 'bsf pin_b?' as the
                >only line that's different, but have just run out of code space on my
                >16f628 and want to condense this a bit.



                >Given (borrowed from someone's software PWM library):
                >
                >----
                >
                >procedure PWM_lum_OUT(byte in PWM, byte in TRA) is
                >
                > var byte LoPWM
                > var byte HiPWM
                > assembler
                >
                > local PWMa
                > local PWMb
                > local PWMtra
                > local PWMend
                >
                > bsf status, status_rp0
                > movlw 0b_1000_0011
                > OPTION
                > bcf status, status_rp0
                > movf PWM, W
                > movwf LoPWM
                > sublw 0xFF
                > movwf HiPWM
                >
                > PWMa:
                > bcf INTCON, intcon_t0if
                > movf HiPWM, W
                > movwf TMR0
                There is some messing with a timer and 16 bits?
                Uncommented assembler is like reading hieroglyphics before the Rosetta stone.

                --
                Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
                Wierdensestraat 74, NL-7604 BK Almelo, The Netherlands eur@...
                phone +31-546-491106 fax +31-546-491107 mobile +31-653-286573
              • Jm Valera
                Good point about it going into flash. Yeah, I don t mind it going one after each other. Awesome, thanks! - Jm
                Message 7 of 20 , Apr 6 9:31 AM
                • 0 Attachment
                  Good point about it going into flash.

                  Yeah, I don't mind it going one after each other.

                  Awesome, thanks!

                  - Jm


                  On Tue, 6 Apr 2004, Eur van Andel wrote:

                  > On Wed, 31 Mar 2004 12:31:57 -0800 (PST), Jm Valera <imjm@...> wrote:
                  >
                  > >I want to call this procedure and have it do it's thing on a pin that I
                  > >define as an arguement to the procedure call.
                  > >
                  > >I see the line:
                  > > bsf pin_b7
                  > You can't. Think about it. It is in flash memory. These are the constraints of
                  > a Harvard architecture.
                  >
                  > >In a nutshell, I want to be able to call:
                  > >
                  > > PWM_lum_OUT(20, 250, pin_b3)
                  > > PWM_lum_OUT(20, 250, pin_b2)
                  > > PWM_lum_OUT(20, 250, pin_b5)
                  > 20 and 250 being what?
                  >
                  > called as above, these pins will PWM AFTER each other.
                  > If you want them to PWM all together, you might need an ISR.
                  > This ISR might screw up your comms routine.
                  >
                  > Do you mind non- or erroneous blinking during comms?
                  > Do you mind lost comms, so you'll have to send the msg again?
                  >
                  > >I currently have the above method copied 5 times with 'bsf pin_b?' as the
                  > >only line that's different, but have just run out of code space on my
                  > >16f628 and want to condense this a bit.
                  >
                  >
                  >
                  > >Given (borrowed from someone's software PWM library):
                  > >
                  > >----
                  > >
                  > >procedure PWM_lum_OUT(byte in PWM, byte in TRA) is
                  > >
                  > > var byte LoPWM
                  > > var byte HiPWM
                  > > assembler
                  > >
                  > > local PWMa
                  > > local PWMb
                  > > local PWMtra
                  > > local PWMend
                  > >
                  > > bsf status, status_rp0
                  > > movlw 0b_1000_0011
                  > > OPTION
                  > > bcf status, status_rp0
                  > > movf PWM, W
                  > > movwf LoPWM
                  > > sublw 0xFF
                  > > movwf HiPWM
                  > >
                  > > PWMa:
                  > > bcf INTCON, intcon_t0if
                  > > movf HiPWM, W
                  > > movwf TMR0
                  > There is some messing with a timer and 16 bits?
                  > Uncommented assembler is like reading hieroglyphics before the Rosetta stone.
                  >
                  > --
                  > Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
                  > Wierdensestraat 74, NL-7604 BK Almelo, The Netherlands eur@...
                  > phone +31-546-491106 fax +31-546-491107 mobile +31-653-286573
                  >
                  >
                  >
                  > Yahoo! Groups Links
                  >
                  >
                  >
                  >
                  >
                • Jm Valera
                  I m using the ULN2003 in a very interesting manner ... Look closer. My circuit produces 5 pwm channels, the fifth going to a lumenosity channel that turns on
                  Message 8 of 20 , Apr 6 4:09 PM
                  • 0 Attachment
                    I'm using the ULN2003 in a very interesting manner ... Look closer.

                    My circuit produces 5 pwm channels, the fifth going to a 'lumenosity'
                    channel that turns on r/g/b together.

                    It allows for additive brightness without the software overhead to make
                    that possible.

                    - Jm

                    On Tue, 6 Apr 2004, Eur van Andel wrote:

                    > On Wed, 31 Mar 2004 12:00:08 -0800 (PST), Jm Valera <imjm@...> wrote:
                    >
                    > >For LEDs, 300hz actually produces a visible flicker.
                    > >
                    > >I too am using JAL for an RGB led controller.
                    > >
                    > >Check out my website dedicated to blinky lights:
                    > >
                    > > http://www.svlife.com/blinkylights/
                    > >
                    > >Of possible interest to you would be the top two links, 'circuit' is
                    > >what I am using to drive my LEDs. That circuit is capable of driving
                    > >roughly 1000 LEDs.
                    > Weird that you need a UN2003 to drive the gates of the FETs. Can't your PIC do
                    > that?
                    >
                    >
                    > --
                    > Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
                    > Wierdensestraat 74, NL-7604 BK Almelo, The Netherlands eur@...
                    > phone +31-546-491106 fax +31-546-491107 mobile +31-653-286573
                    >
                    >
                    >
                    > Yahoo! Groups Links
                    >
                    >
                    >
                    >
                    >
                  • special [k]
                    ... a lumenosity ... make ... From your schematic, you have 4 different colors (I think... you need to label your parts more clearly), Red, Green, Blue, and
                    Message 9 of 20 , Apr 6 6:14 PM
                    • 0 Attachment
                      --- In jallist@yahoogroups.com, Jm Valera <imjm@s...> wrote:
                      > I'm using the ULN2003 in a very interesting manner ... Look closer.
                      >
                      > My circuit produces 5 pwm channels, the fifth going to
                      a 'lumenosity'
                      > channel that turns on r/g/b together.
                      >
                      > It allows for additive brightness without the software overhead to
                      make
                      > that possible.

                      From your schematic, you have 4 different colors (I think... you need
                      to label your parts more clearly), Red, Green, Blue, and Ultraviolet?
                      (U?) Your "luminosity" channel is connected to only the Red, Green,
                      and U channels, not Blue. Also what are the parts Q1-Q4? They look
                      like some sort of PNP transistor or mosfet...

                      -special [k]
                    • Jm Valera
                      Mislabled. Sorry. - Jm
                      Message 10 of 20 , Apr 6 6:18 PM
                      • 0 Attachment
                        Mislabled.

                        Sorry.

                        - Jm

                        On Wed, 7 Apr 2004, special [k] wrote:

                        > --- In jallist@yahoogroups.com, Jm Valera <imjm@s...> wrote:
                        > > I'm using the ULN2003 in a very interesting manner ... Look closer.
                        > >
                        > > My circuit produces 5 pwm channels, the fifth going to
                        > a 'lumenosity'
                        > > channel that turns on r/g/b together.
                        > >
                        > > It allows for additive brightness without the software overhead to
                        > make
                        > > that possible.
                        >
                        > >From your schematic, you have 4 different colors (I think... you need
                        > to label your parts more clearly), Red, Green, Blue, and Ultraviolet?
                        > (U?) Your "luminosity" channel is connected to only the Red, Green,
                        > and U channels, not Blue. Also what are the parts Q1-Q4? They look
                        > like some sort of PNP transistor or mosfet...
                        >
                        > -special [k]
                        >
                        >
                        >
                        >
                        >
                        > Yahoo! Groups Links
                        >
                        >
                        >
                        >
                        >
                      • Vasile Surducan
                        Message 11 of 20 , Apr 7 12:53 AM
                        • 0 Attachment
                          On Tue, 6 Apr 2004, Eur van Andel wrote:

                          > On Wed, 31 Mar 2004 12:00:08 -0800 (PST), Jm Valera <imjm@...> wrote:
                          >
                          > >For LEDs, 300hz actually produces a visible flicker.
                          > >
                          > >I too am using JAL for an RGB led controller.
                          > >
                          > >Check out my website dedicated to blinky lights:
                          > >
                          > > http://www.svlife.com/blinkylights/
                          > >
                          > >Of possible interest to you would be the top two links, 'circuit' is
                          > >what I am using to drive my LEDs. That circuit is capable of driving
                          > >roughly 1000 LEDs.
                          > Weird that you need a UN2003 to drive the gates of the FETs. Can't your PIC do
                          > that?

                          :))
                        Your message has been successfully submitted and would be delivered to recipients shortly.