• Halogen to LED Headlamp upgrade Suzuki SX4

    03/30/2018 at 09:13 0 comments

    I ordered one of these for my 2011 Suzuki SX4 sedan. Finally found some time today to swap halogens with new LEDs. Current pair of halogens are Philips H4 90/100w and they are pretty good. I wanted to switch to LEDs primarily to lower power consumption, Headlamps will run cool and white headlamps looks neat!  This page will serve me as a reference in future if I ever go back to halogens or need to replace these LEDs. 

    Unboxed

    Complete Unit: LED, fan cooled heatsink, driver unit and H4 plug.

    CREE LEDs (XHP50+XM-L2)

    Active cooling: small fan encased in heatsink

    5 Pin connector to LEDs

    LED driver unit in aluminium heatsink


    Installation Issues:

    These LED headlamps are designed to be simple plug and play units, however, while installing, I could not get them attached to the bulb receptacle. Rubber/Silicone boots which provide dust and water protection to the headlamp interior seems to have an issue and needed some work to get them to accept these LEDs. The modifications I made to the boots does not compromise its dust and water resistance and they can absolutely work again with halogen bulbs!

    The LED lamp needed to be installed a little differently by first removing the notched metallic collar , fixing the collar to the headlamp bulb receptacle, securing it  with the wire clip, sliding on the protective rubber boots and then inserting the LED unit and twisting it into a locked position. 

    Metal notched collar

    The portion of the rubber boot which goes around the neck/stem of the bulb was interfering with the locking of LED bulb and I had to trim about 2 mm of its length. 

    Original rubber/silicone boot
    Trimmed!

    I also needed to remove four protrusions on the back of boot. They were interfering with the complete insertion of LED bulb and getting in the way of heatsink. 

    Need to remove these!
    removed them with a sharp blade

    I did a mock assembly on my desk before heading out to the car

    a little soap water helps get things moving!
    Insert LED lamp, twist about a quarter turn and LED lamp will lock against metal collar on the other side.
    Assembled successfully!
    Back view

    Now, need to repeat these steps in the car.

    Testing LED lamp - very bright!
    Replacing bulb is not easy, I wish I had smaller hands :/
    H4 receptacle with retaining clip (open)

    Install metal collar first in correct orientation.

    Metal collar in place secured with clip
    Wet rubber boot with soap water for easy installation. Ensure no water gets inside headlamp enclosure.
    Rubber boot is secured in place around the metal collar
    Finally install the LED lamp, insert - twist clockwise quarter turn and lock.
    LED bulb installed correctly in the proper orientation
    Connect driver unit to LED and secure it in place with tape or cable ties.
    Complete installation by connecting H4 plug from LED driver unit to existing headlamp harness.

    sweeet!


    Comparison Test (Halogen Vs LEDs).

    Wall distance = 13 feet.

    Low Beam (ISO 100, White balance - Daylight, Exposure -Frame Average)

    High Beam (ISO 100, White balance - Daylight, Exposure -Frame Average)

    Verdict:

    100watts halogen definitely looks a shade brighter and more focused. I still have to do real world test and night time drives to get to a fair conclusion. 

    I will post updates later.

  • EPOCH to Time Date converter

    03/24/2018 at 03:36 0 comments

    I needed a lightweight code to convert EPOCH to Date, Day, Year, Time etc for my NTP sync clock. I could not find a code example online and wrote my own. Message me if you find any bugs.

    https://github.com/sidsingh78/EPOCH-to-time-date-converter

    /*
    EPOCH to human readable time and date converter for microcontrollers (PIC, AVR, Arduino, STM32)
    Current EPOCH time can be found at https://www.epochconverter.com/
    The code can be suitably modified to suit your requirements. I have extensively
    tested this code with valid inputs. If you have any questions or if you find a bug, please contact me. 
    Author: Siddharth Singh 
    Ver:1.0
    Date: June 15, 2017 
    */
    
    
    #include <stdio.h>
    #include <stdlib.h>
    
    static unsigned char month_days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    static unsigned char week_days[7] = {4,5,6,0,1,2,3};
    //Thu=4, Fri=5, Sat=6, Sun=0, Mon=1, Tue=2, Wed=3
    
    unsigned char
    ntp_hour, ntp_minute, ntp_second, ntp_week_day, ntp_date, ntp_month, leap_days, leap_year_ind ;
    
    unsigned short temp_days;
    
    unsigned int
    epoch, ntp_year, days_since_epoch, day_of_year; 
    
    char key;
    
    
    int main()
    {
       //---------------------------- Input and Calculations -------------------------------------
    start: 
        leap_days=0; 
        leap_year_ind=0;
        printf("-------------------------------------------\n");    
        printf("Enter EPOCH => ");
        scanf ("%d",&epoch);
        
        // Add or substract time zone here. 
        epoch+=19800 ; //GMT +5:30 = +19800 seconds 
        
          ntp_second = epoch%60;
          epoch /= 60;
          ntp_minute = epoch%60;
          epoch /= 60;
          ntp_hour  = epoch%24;
          epoch /= 24;
            
          days_since_epoch = epoch;      //number of days since epoch
          ntp_week_day = week_days[days_since_epoch%7];  //Calculating WeekDay
          
          ntp_year = 1970+(days_since_epoch/365); // ball parking year, may not be accurate!
     
          int i;
          for (i=1972; i<ntp_year; i+=4)      // Calculating number of leap days since epoch/1970
             if(((i%4==0) && (i%100!=0)) || (i%400==0)) leap_days++;
                
          ntp_year = 1970+((days_since_epoch - leap_days)/365); // Calculating accurate current year by (days_since_epoch - extra leap days)
          day_of_year = ((days_since_epoch - leap_days)%365)+1;
      
       
          if(((ntp_year%4==0) && (ntp_year%100!=0)) || (ntp_year%400==0))  
           {
             month_days[1]=29;     //February = 29 days for leap years
             leap_year_ind = 1;    //if current year is leap, set indicator to 1 
            }
                else month_days[1]=28; //February = 28 days for non-leap years 
       
                temp_days=0;
       
        for (ntp_month=0 ; ntp_month <= 11 ; ntp_month++) //calculating current Month
           {
               if (day_of_year <= temp_days) break; 
               temp_days = temp_days + month_days[ntp_month];
            }
        
        temp_days = temp_days - month_days[ntp_month-1]; //calculating current Date
        ntp_date = day_of_year - temp_days;
        
       // -------------------- Printing Results ------------------------------------- 
        
        switch(ntp_week_day) {
                             
                             case 0: printf("\nSunday");
                                     break;
                             case 1: printf("\nMonday");
                                     break;
                             case 2: printf("\nTuesday");
                                     break;
                             case 3: printf("\nWednesday");
                                     break;
                             case 4: printf("\nThursday");
                                     break;
                             case 5: printf("\nFriday");
                                     break;
                             case 6: printf("\nSaturday");
                                     break;
                             default: break;        
                             }
      printf(", "); 
      
      switch(ntp_month) {
                             
                             case 1: printf("January");
                                     break;
                             case 2: printf("February");
                                     break;
                             case 3: printf("March");
                                     break;
                             case 4: printf("April");
                                     break;
                             case 5: printf("May");
                                     break;
                             case 6: printf("June");
                                     break;
                             case 7: printf("July");
                                     break;
                             case 8: printf("August");
                                     break;
                             case 9: printf("September");
                                     break;
                             case 10: printf("October");
                                     break;
                             case 11: printf("November");
                                     break;
                             case 12: printf("December");       
                             default: break;        
                             }
      
      printf(" %2d",ntp_date);
      printf(", %d\n",ntp_year);
      printf("TIME = %2d : %2d : %2d\n\n", ntp_hour,ntp_minute,ntp_second)  ;
      printf("Days since Epoch: %d\n",days_since_epoch);
      printf("Number of Leap days since EPOCH: %d\n",leap_days);
      printf("Day of year = %d\n", day_of_year);
      printf("Is Year Leap? %d\n",leap_year_ind);
      printf("===============================================\n");
      printf(" Press e to EXIT, or any other key to repeat...\n\n");
     key=getch();
    ...
    Read more »