Powered by Invision Power Board

Forum Rules Forum Rules (Please read before posting)
  Reply to this topicStart new topicStart Poll

> Pic10f204 To Control Smps Led Flasher, Is it able to do the job?
Posted: May 06, 2012 03:05 pm
Reply to this postQuote Post

Forum Addict

Group: Trusted Members
Posts: 945
Member No.: 17,791
Joined: August 29, 2008


We are doing an smps LED lamp which must flash on and off, possibly in synchrony with a sync signal, -if a sync signal is received. The flashing may also need to be in anti-sync to the sync signal. The lamp should also send out a sync signal itself, and if a sync signal is being received, then it must be in phase with the one received.

This all sounds simple, but is it possible to control all the above with no more than a PIC10F204?

So, in more detail……

I am writing MPASM code to control a simple Buck LED driver which flashes the LEDs on and off with on-time = 190ms and off-time = 300ms.
The lights are flashed in synchrony with a signal received at one of its pins (this signal comes from another lamp)
If a separate anti_sync signal is detected, then the flashing must be done in anti-synchrony with the received sync signal.
The lamp should also send a sync signal aswell as receiving one (if present)…..
If an external sync signal is present, then obviously the sent sync signal must be in phase with it.

The Buck’s mosfet is simply controlled by the comparator on board the PIC10F204.

There is a current sense resistor in series with the LEDs and if its voltage is less than 0.6V, the comparator turns the FET on, and vice versa.

Anyway, enabling the PIC10F204’s comparator is simple enough, but the PIC10F204 must also coordinate the flashing ON/OFF of the light, and also sync up to another similar light which is also flashing…….so theres a sync input , which is a logic high signal for 10ms.
-and when this signal goes high the FLASH_ON period must begin.

There is also an anti-sync input, and if this is logic low, then the light must be flashed in anti-synchrony to the received sync signal.
-and if a sync signal, is not being received, then obviously the lamp should produce a sync signal, but flash in antisynchrony to it.

Now there’s not enough ports for the sync_send and sync_receive to be having their own pins, so the send and receive must share the same pin.

Finally, as you may well have guessed, controlling an SMPS with nothing more than a comparator on a PIC10F204 is not without problems…….and yes, huge overcurrents can potentially occur at start-up and subsequently , every time the FLASH_ON period starts.
-Therefore, the comparator output has to be used as a soft-start…..
That is, at start-up, the comparator output pin is assigned to be a straightforward digital output, and is PWM’d high and low so that the FET duty cycle is gradually increased, until the point where the comparator trips, showing that the regulation current level has been reached…….so obviously during this phase, the comparator is still enabled, but its output simply goes to an internal register, instead of to the pin.
-and when the regulation current level has been reached, the comparator output is switched to the pin and it is allowed to go ahead and control the switching mosfet of the buck led driver.

The breakdown of pin usage for PIC10F204 is as follows:

GP0 = Input and output…..sync send and receive signal.
GP1 = Comparator inverting input (connected to current sense resistor)
GP2 = Comparator output, and sometimes just a digital output.
GP3 = Input……sense if anti-phase flashing is required.

Do you think its possible to do all this jolly lot with the PIC10F204?

Do you think the 256 words of flash will be enough for the code?

incidentally here is the circuit doagram of the buck stage:-


PMEmail Poster
Posted: May 07, 2012 02:26 am
Reply to this postQuote Post

Forum Addict ++

Group: Spamminator Taskforce
Posts: 3,984
Member No.: 4,223
Joined: February 06, 2006

Two of the things that are really going to bite are the 2 deep hardware stack on this device and the limited IO pins.

The 2 deep hardware stack means you're going to be limited in writing complex subroutines, and you'll probably end up using up some of your already limited code space with inefficient program loops. You can move up to something like the 10F3XX chip to get 8 stack levels. This can make your code both more efficient and easier to keep track of. While I'm almost positive you can do this with a 10F204, I'd also bet it'll take longer. And if you end up going over the code space, it could end up taking a LOT longer, trying to trim the fat.

The limited IO pins means you have to share that one pin for I/O, as you noticed. But it also means you are going to be limited in the ability to do ICSP. If you're going to have these chips programmed at the factory, then no big deal. I have used the 10F chips a few times, and I keep some on hand. But I avoid using them unless I really want a SOT-23 package.
PMEmail Poster
Posted: May 18, 2012 06:17 pm
Reply to this postQuote Post

Forum Addict

Group: Trusted Members
Posts: 945
Member No.: 17,791
Joined: August 29, 2008

Surely i can still do icsp, all i do is just put a 1K resistor to isolate the circuti from the ICSP header?

oh by the way, is it ok to do icsp if i have a 100pF capacitor directly on the ICSPCLK pin of the pic10f204?
PMEmail Poster
Posted: May 19, 2012 08:44 pm
Reply to this postQuote Post


Group: Trusted Members
Posts: 107
Member No.: 30,119
Joined: July 24, 2010

The 100p will not affect the clock signal.
The 2-deep stack will not affect you.
Simply write a program as MAIN and call any sub-routine, then return to MAIN.
In any of the sub-routines, you can call another subroutine then return to the original sub-rouitne, finish the sub-routine, then return to MAIN.
If you follow this rule for all your simple programs, you can "burn" them into PIC chips such as PIC12F629 or the PIC10F series.
You can always go to the PIC10F202 or 206 for 512 lines of code.
PMEmail Poster
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll


:: support us ::

ElectronicsSkin by DutchDork & The-Force