Anybody doing custom UIs for 12F629 PIC?

Driver in a light I'm tweaking uses a 12F629 PIC, and I know *nothing* about code, or flashing, only that most of the custom stuff is built for stuff that's not the 12F629. Anybody working with these, or if not, is it pin-compatible with the more widely used controllers?

It's a tailcap on/off with a side switch for modes, with typical L/M/H/strobe/SOS w/last mode memory. It also has a lighted button with green/red backlighting for battery condition (goes red when each cell hits 3.3V, which seems a little overly cautious to me). A group with no memory and no blinkies, another group with ramping is about as fancy as it needs to be.

I have plans to do that… but my driver is from a 4sevens Quark, so probably quite different from yours. Also i still have to figure out how exactly the driver works before i can reprogram anything.
So far i only played around with pic programming, like using the PWM feature, or the internal ADC, stuff like that.

It is NOT pin-compatible to an Atmel, so i guess the only pin-compatible MCUs to the pic would be chinese knock-offs of the pic.

I would look to the newer PIC12f1822 because of the more advanced peripherals, and increase code space if need be. With the ’1822 you can use the internal voltage reference and the a-d to determine the low battery voltage, no external resistor divider needed. Also, there is a proper PWM module over the ’629, which has to be a software or interrupt driven PWM.

Yes, those enhanced core PICs are cool. For my playing around i used the 16f1825. The ability to measure its own supply voltage without additional circuitry is great for flashlight purposes. I also like the ability to change clock speed in software. I think i need to get some of those 12f1822’s, only question is, how do i desolder the 629 and solder in the 1822 without desoldering the rest of the circuit? I have a butane soldering iron with a hot air tip, which is great for desoldering, but that will probably desolder everything, and the pieces from the other side of the board might just fall off.
Maybe i need to get some chipquick as shown in the eevblog (EEVblog #437 – Removing SMD Parts with ChipQuik – EEVblog), or are there alternative ways?

Safest way to remove IC from sensitive PCB is to cut it away (cut it’s legs) and manually remove the rest from pads with plain soldering iron.

I'm still slogging my way through that monster thread. Don't know if that applies to anything with the 629, or just the 105c/AK. Hopefully I will get a bit closer before resorting to bugging people with PMs.

I use the Chipquick solution for taking off selective multipin IC’s. With careful heating (like on a hotplate) you can pick off a components, on single sided boards, after the solder melts. With a heat gun, it is easy to blow chips off due to operator error :slight_smile: .

So how is that chipquick stuff?
I guess i’ll end up either trying it with a soldering iron and maybe a small screwdriver to bend each desoldered pin up away from the board, or just cutting it off. Before chiefinspectorfinch’s tip i didn’t even think of destructively removing the IC.
It’d be great to leave the chip intact, but maybe it’s not worth the effort.

Just use the butane hot air, that's what I use, it won't blow anything loose like a heat gun. Grab the chip with tweezers and lift a little, then heat, as soon as solder melts the chip will lift away, which limits the heat on the rest of the board. If you just blast it and poke at it every 10-15 seconds to see if it's loose yet you can make a mess of things.

Chipquick works good, you need some desolder braid to clean up the mess it leaves, and I give it a quick scrub of denatured alcohol. Place the Chipquick down to the pins you intend to desolder and melt a small bit with the iron onto those pins creating a solder “bridge”. Go to the other side of chip and do the same. Heat both sides (it stays molten for a long time) , and you can pull it, or just push off the IC with the iron.

I’ll try comfychair’s suggestion first :slight_smile:
By now i have figured out the schematics and ordered a PIC 12F1840 (like the 1822, but 7K flash).
3.5K should probably be enough, but it can’t hurt, and the online electronics store didn’t have
the 1822. And with the open-source sdcc compiler, which doesn’t optimize too well, i might even need it.
I can start coding in the near future!

Sadly i can’t easily measure the battery voltage, as the only free pin on the MCU is RA3, which is not available for analog input. And as this is a boost driver, the MCU supply voltage is/can be higher than the battery voltage.
Leaving RA3 not connected is probably a good thing, because that’s the pin that gets high voltage (was it 13V?) when in-circuit programming. So that way the rest of the circuit is safe. Too bad it’s not an analog input…

For Comfychair and SeanHatfield on enhanced mid-range PIC’s (PIC12f1822 etc.), the “no pin” Battery Voltage reading.

1) Enable and set the FVR (fixed voltage reference) register for 2.048V setting.
2) Enable and read the A-D FVR ;This is an internal register
3) You now know what the battery voltage is at that time according to:

2.048V / BatVolts = A-D FVR / 255 ;(8 bits is close enough)
;Promote values by 100
BatVolts = 52224 / A-D FVR (x100) ;A-D FVR reading should be around 175 at 3V

Note: add diode correction factor of around .3V for some of the AMC7135 drivers

PS SeanHatfield, As long as the battery voltage is equal to or greater than the minimum of 1.8V, you could power it by rerouting the PIC supply to the battery?

Watching this thread. The custom BLF is coming with a 629 MCU. I think this is going to be less than ideal, so having an upgrade path is important. What are the best tools for coding and programming a PIC these days?

I would get a PICKit 2 or PICKit 3 for programming the PIC. In my mind the PICKit 2 was a thing of beauty when it came out and love mine. The PICKit 3 is recommended for the newer devices, I’ve got this one too, but barely use it. I’m an oddball that uses Basic (GCBasic), and sometimes a little assembly. Someone else could give you their opinion on the current state of MPLAB or MPLAB X and their C versions.

I already did a proof-of-concept no-pin battery voltage read with my 16f1825. Works well! Of course, now the ADC reading is not linear, but inversely proportional to the voltage, so you
have to have the right “reference”, i.e. the 2.048V, for good precision.

The original Quark driver works with single AAs, and officially goes down to 0.9V. I wouldn’t want to lose that.
Maybe i’ll only monitor the voltage of li-ions, i have to measure at which voltage the circuit starts boosting. At least as long as a li-ion is full, there is no boosting, only 2 diode drops (and maybe a resistive drop across the boost inductor).