Well, I got the regulator in the bike and running this weekend.
So here's the schematic and program for the modulator.
Its pretty simple...
a MINUS Five Volt voltage regulator and 3 caps for it.
a PIC 12F683 microcontroller
a CDs Photodetector
a few P-channel Mosfets
3 resistors
an optional diode to protect against reversed connections
A couple of notes:
The Modulator can be completely bypassed by connecting the two terminals marked BYPASS. You could connect them with a switch to turn it off or in case it fails. I didn't bother on mine.
The low beam wire is shown in the schematic. It is not used as part of the modulator. But if you wire yours in in between the socket and the bulb, you will need to make a wire for the low beam connection though.
D1 is only used to protect against reversing the input connections for +
and -
If you know you'll never do this, you can omit it...
It is shown as a power diode, but the only power it needs to pass is the
power to the PIC (negligible), the gate drive (negligible), and whatever
the regulator wastes. So any current rating is enough.
Also, the bike-ground wire going to the modulator can be very light wire, since it carries almost no current
The 1k resistor provides gate drive to the FETs.
The 47k resistor provides a weak pull down to drive the fets on
while the PIC is booting up. (and if it ever locks with the output
Tri-stated to high impedance)
Otherwise, there would be a 1/4 sec or so turn on delay when you turned
the high beams on. While this wouldn't be too noticable if the PIC
started modulating, it would kind of suck when you turn the high beams on
at night ...

As soon as the PIC starts up (assuming the light sensor sees light), the
PIC will override the 47k resistor.
The Nanny-State government says the modulator is supposed to work on the positive side and not the ground lead ... That means we can't use
N-channel FETs unless we use a special funky driver that will raise the
gates above the positive rail. I'd rather avoid that extra complexity,
so we'll use P-channel FETs. The number of Fets required depends on
their current carrying capacity compared to the headlight current. I
drew three, but mine were about 7 amps each, so I built it with just 2
in the end for a factor of safety of about two and a half. Just parallel
as many as you want/need.
To drive them, it's easiest if the PIC voltage will go all the way to
the positive rail (which acts as the ground for P type FETs) So we use a
NEGATIVE regulator, which provides a regulated voltage 5 volts below the
12 volt rail (instead of a positive regulator which rovides a regulated
voltage 5 volts above the ground rail) So the regulator section looks a
little strange, with "ground" being +12 volts ...
Also, since the P-FETs are on when the gate voltage is negative, the PWM
output is "active low".
The Photodetector and its resistor form a voltage divider. This is read
by the A/D converter in the PIC. To make it easy, I just read the first
bit ... That bit changes when the resisance of the Photodetector is
equal to the resistor ... slick and easy ... So pick a photodetector
that has a resistance of 10k at your desired level of darkness. The one
I show in the parts list is 10k at 10 to 15 minutes after sundown.
Internal weak pull-ups are enabled on pins 2,6, and 7. These let you
provide input to the PIC by either leaving them open or shorting them to
the Vss terminal. (the PICs local ground ... not to be confused with
the bikes ground)
The government says the "full brightness" time should be 50 to 70
percent of the total. I wanted to try both, and see what worked better.
If pin 2 of the pic is high, the duty cycle is 50%; If pin 2 is low, the
duty cycle is 67%. Internal weak pullups are enabled on pin 2, so if it
is unconnected it will be high. To pull it low, short it to Vss via a
jumper or Solder-bridge. Alternatively, if you connect pin 2 to Vss via
a switch you can vary the duty cycle by flipping the switch.
Pins 6 and 7 can be used to change the flash rate.
If neither pin 6 nor 7 is connected, the default rate is 240 flashes/min
connect pin 6 to Vss to change the rate to 202 flashes/min
connect pin 7 to Vss to change the rate to 278 flashes/min
(if both are connected, the rate will be 202)
If you connect Vss to the center, and pins 6 and 7 to the outside of a
SPDT-center-off switch, you will have a switch that provides all three
speeds in order.
Pin 4 (mclr) should be connected to Vss or Vdd after programming. It
doesn't matter which, it just shouldn't float.
Otherwise, pins 4, 6, and 7 are not connected, however, they are brought
out to pieces of wire which are used for initially programming the PIC.
Pin 1 and pin 8 are also used in programming, so there are wires brought
out for them too. These wires can be clipped after the pic is
programmed.
Also, PIN 8 (Vss) is eventually connected to the regulator, but during
programming it should not be connected to the regulator. The programmer
will supply power to Vdd and Vss, which would damage the regulator if
the regulator were connected at that time. So pin 8 is connected to the
rest of the board via an intentional solder bridge which is formed after
programming is complete. If you ever need to reprogram the PIC, make
sure to temporarily melt that bridge.