Another PWM newbie....

Status
Not open for further replies.

yfx4

Member
I have a project I am trying to figure out that needs PWM for 5 LED arrays. I want to replace the TS Flasher on my motorcycle with a MC-based one so I can use LEDs w/o hyperflash or load resistors. I am altering the stock functionality also. I originally planned to use a 16f628A but am open to change/suggestions.

5 lamps: 2 front turns, 2 rear turns, 1 center Brake (On low-level except when input is triggered.)

2 dash-mounted TS indicators (off always except flashing when TS is on)

3 active-high inputs: L/R turns and Brake

Typical function of left/right turn and brake. All the rear lamps light for brake unless turn indicator on when that side will flash at about 1 Hz. All TS flashes are On-Off, not On-dim.

In designing the circuit I need to understand how the PWM and On/Off parts can work. I plan to use one 2A Sharp 12V regulators PQ12RD21 with on/off for each of the 5 lamps, then a PNP for the high-side switching of the TS indicators (yup, the MC pins need to sink current here).

here is the DS for the regulators:

https://www.electro-tech-online.com/custompdfs/2010/02/pq05rd21_e.pdf

It seems to me that hardware PWM may work for the running light mode if I can shut off the regulator during the flashing. Otherwise I may need to go with SW PWM so I can switch pins from PWM to flashing on TS mode. The SW PWM version seems less desirable since quite a bit of overhead will be spent "watching" for turn signal and especially brake inputs. The various combinations of flashing and bright will seemingly interfere with the smoothness of the SW PWM function and limit further "improvements." I know me and this will only be a start.

Am I correct in understanding that HW PWM only outputs to 1 pin (CCP1) so all the other I/O pins work as regular tri-state pins?? If so then I could have the PWM waveform pulsing the regulators during regular function. Then have the port B pins 'override' the pulses for bright mode. Can they override the PWM pulses in the off direction too??

I thought I could use a couple of Port A pins to flash the dash lamps to keep RB6 and 7 open for ICSP. Since only one of these will only go 'off' or 'on' at 0.5 second intervals when the TS is on they will use next to no cycles.

I just can't get my head around how to get smooth PWM all the time and do the other stuff too. Am I just over thinking this?? Do I just not understand implementation of PWM? and so on....

Thank You!!!
 
It seems to me most of the lights are either on or off, only the brake/tail light needs two intensities which are dim and bright so that's the only PWM you'll need. Since it only has two brightness levels, the PWM for that needs little resource from the processor and doesn't warrant the use of a hardware PWM.

What you need is a timer driven interrupt to run your code functions at defined intervals, they will handle PWM brightness on the brake and flashing on the other lamps.

You're not going to see any jitter in the PWM unless your eyes can detect a few microseconds of variation in the pulse width on a signal repeating at a frequency of a couple of hundred Hz - which they can't.

Even at 4Mhz the 16F628A is executing 1,000,000 instructions/second (without getting pedantic about branches), so to do what you want the PIC will be idle for about 99% of the time.
 
Last edited:
Thank you Pete for replying.

All the lights are at a low level (about 10% duty cycle) as running lights. They will go On/Off as turns as needed.

To clarfy for myself--the PWM will run all the time and output to 5 pins. during "down time" of the PWM cycle the PIC will "look at" the input pins. If one or two are high it will, for certain pins, overide the PWM signal in favor of a Flash or constant bright, as appropriate. This can all happen on a schedule so each function will have little to no impact on the other processes. Is this an accurate summary???

Any suggestions on where to look for info on timer driven interrupts--other than a search here which I will do when my finger (yes only 1) is done typing??
 
Hi YFX4

I've seen many of these while Googling ...

this drop-in one i.e. ...

**broken link removed**

Alain
 
Yup, I've seen that one too. I designed one with a 555, some XOR gates and MOSFETs but then started down the slippery slope of interest in MCs.

My 2007 VTX1800R has a 9-pin flasher unit with some added functionality (more brake light and rear running lights) that I am trying to replicate. I've gotten a Hitachi 9-pin connector and two other Honda plugs so I can just PNP my new unit in and replace the incandescent lamps with my custom 'handmade with love' LED lamps. The stock unit does not like front LEDs at all.

This is also an opportunity to learn more about MCs.
 
Ok, I see ...

So, I can't be any more Help ... your summary is far too short whithout the bike + its electrical scheme ...

I return to modernizing the electr(on)ics of my old ... '76 Kawasaki H1.

hé,hé ... just another " way of life ".

Alain
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…