Soft start for powered peripherals ================================== I have just solved an issue on an application which may bite others so I'm dropping it here for interest. The system has an audio amplifier, lighting and LED's which are all controlled from a single transistor switch on a PIC output. The intention being to turn them all off when the PIC enters sleep. This group of peripherals has a single 22uF capacitor decoupling it. The issue was that when the transistor turned on the instantaneous current rush into the peripherals and the local decoupling capacitor caused a glitch on the PIC supply which caused it to reset, or jump or lose RAM conents. Undoubtedly it could have been fixed with better decoupling or PCB tracking but we were stuck with a PCB layout. The solution was a "soft" turn on of the transistor, effectively using a PWM signal to step the voltage to the peripherals in 6 steps over about 100mS. The C code to do this is shown below - it is quite short (it is written for the FED WIZ-C compiler, other compilers may need a change to the first line which defines the pin to which the transistor switch is connected). The function provided turns power on or off according to the parameter. This completely solved the issue and the system is now rock solid. This function takes around 100mS which is fine in an application like ours where the peripherals are turned on at PIC reset and only turned off when sleep mode is entered. For systems where the on/off signal is required more frequently and the system cannot afford to wait for 100mS, then an enhancement would be to drive this code in a timer interrupt. It will only ever work when the peripherals can cope with a slow Vdd pin rise and have suitable decoupling capacitors to avoid the 60KHz PWM signal hitting the power line. Finally if one of the CCP outputs is not being used then the internal PWM could be used to simplify the code. #define AuxPower bRC5. // Operate on the RC5 pin // (may need to change for different compiler) // Defined automatically with App Wizard void SetAuxPower(unsigned char On) { unsigned int j; unsigned char i,k; if (On) // Turning power on { for(i=0; i<5; i++) // Turn on power in 5 voltage steps for(j=0; j<1000; j++) // This loop controls the time in each step for(k=0; k<6; k++) // This loop controls the PWM output { if (k<=i) // Approx 60KHz here with 20MHz clock AuxPower=1; // In this example output high turns on the transistor (NPN) else AuxPower=0; } } AuxPower=On; // Finally turn it on (or off) all the way } Robin Abbott Forest Electronics - Home of WIZ-C ANSI C Compiler for PIC's with RAD Front end robin.abbott@fored.co.uk www.fored.co.uk -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist