Robert Korn
Published © MIT

EV Charger

EV chargers are starting to show up everywhere. Why not at your place?

AdvancedFull instructions provided1,711
EV Charger

Things used in this project

Hardware components

Futaba VFD Display
×1
Magtek Swipe Reader
×1
Patlite Signal Tower
×1
Solid State Relay
Solid State Relay
×1
contactor
×1
PC Power Supply
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Schematic

Code

EV_Charger_demo.ino

Arduino
Demo timing version
//****************************************************************
//*  Name    : EV Charger Demo                                   *
//*  Author  : Robert Joseph Korn                                *
//*  Notice  : Copyright (c) 2015 Open Valley Consulting Corp    *
//*  Date    : 12/14/15                                          *
//*  Version : 1.1                                               *
//*          :                                                   *
//*  Notes   :  Charger Control Codes                            *
//*          :  03 - Charger On                                  *
//*          :  04 - Charger Off                                 *
//*          :  07 - Initialize Display                          *
//*          :  12 - Clear Display(must be followed by cr lf)    *
//*          :  22 - Signal Tower Off                            *
//*          :  23 - Signal Tower Red                            *
//*          :  24 - Signal Tower Yellow                         *
//*          :  25 - Signal Tower Green                          *
//*          :                                                   *
//*          :  States                                           *
//*          :  0 - Waiting for Swipe                            *
//*          :  1 - Parsing Track 1                              *
//*          :  2 - Parsing Track 2                              *
//*          :  3 - Processing Swipe                             *
//*          :                                                   *
//*          :                                                   *
//****************************************************************

int SER = 0;
int state = 0;
int numlen=0;
int namlen=0;
int o=0;
char nam[255];
char num[55];

void setup() {

  Serial1.begin(9600);
  Serial1.write(22); 
  Serial1.write(4);
  Serial1.write(12); 
  Serial1.println();
  Serial1.write(12);
  Serial1.println("MediaTek Linkit One");
  Serial1.write(14);
  Serial1.println("  EV Charger Demo  ");
  delay(2500);   
  Serial1.write(25);
  Serial1.write(12);
  Serial1.println("EV Charger is Ready");
  Serial1.write(14);
  Serial1.println("Swipe Card to Begin");

}

void loop() {
   
          if( state == 3 ) 
          {     
              Serial1.write(24);
              Serial1.write(12);
              Serial1.println("      Welcome       ");
              Serial1.write(14);
              
            for(int o=0;o<namlen-1;o++)
             {
               Serial1.print(char(nam[o]));             
             }
             
             Serial1.println("");
             
             delay(2500);   
             Serial1.write(3);
             Serial1.write(12);
             Serial1.println("Charging in Progress");
             Serial1.write(14);
             Serial1.println("  2.0 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.9 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.8 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.7 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.6 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.5 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.4 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.3 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.2 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.1 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  1.0 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.9 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.8 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.7 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.6 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.5 Hours Remain");

            delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.4 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.3 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.2 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.1 Hours Remain");

             delay(1000);   
             Serial1.write(14);
             Serial1.println("  0.0 Hours Remain");

             delay(1000);   
             Serial1.write(4);
             Serial1.write(12);
             Serial1.println("Charge Time Complete");
             Serial1.write(14);
             Serial1.println(" Notification Sent");

             delay(2500);   
             Serial1.write(25);
             Serial1.write(12);
             Serial1.println("EV Charger is Ready");
             Serial1.write(14);
             Serial1.println("Swipe Card to Begin");

            numlen=0;
            namlen=0;
            state=0;     
          }
  
  if (Serial1.available() > 0) {
      SER = Serial1.read(); 

  switch(state)
  {
    case 0:if (SER==0x3B)  
               {
                 state=1;
               }
           if (SER==0x25)  
               {
                 state=2;
               }break;
               
    case 1:num[numlen]=SER;  
            numlen++;             
              if (SER==0x3F)  
               {
                 state=3;
               }break;
               
    case 2:nam[namlen]=SER;  
            namlen++;              
              if (SER==0x3F)  
               {
                 state=0;
               }break;
          
     default:break;
  }
 
  }

}

Serial_Test.ino

Arduino
//****************************************************************
//*  Name    : Serial Demo                                       *
//*  Author  : Robert Joseph Korn                                *
//*  Date    : 12/14/15                                          *
//*  Version : 1.1                                               *
//*  Notes   : Really just the software serial demo              *
//*          : changed for serial1                               *
//****************************************************************

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

 Serial1.begin(9600);
}

void loop() { 
  if (Serial1.available()) {
    Serial.write(Serial1.read());
  }
  if (Serial.available()) {
    Serial1.write(Serial.read());
  }
}

ev-charger-light-control.pbp

Plain text
'****************************************************************
'*  Name    : EV-Charger-SERIAL.BAS                                 *
'*  Author  : Robert Joseph Korn                                *
'*  Notice  : Copyright (c) 2015 Open Valley Consulting Corp    *
'*  Date    : 12/15/2015                                         *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
  
DEFINE  OSC     10
 
DEFINE HSER_RCSTA 90h 
DEFINE HSER_TXSTA 20h            
DEFINE HSER_BAUD 9600 
DEFINE HSER_CLROERR 1

x       var     word

        ADCON1 = $7f 

char    var     BYTE

red     VAR     PORTB.7
yellow  VAR     PORTB.6
green   VAR     PORTB.5
charge  VAR     PORTA.0
        
        PORTB = 0
        TRISB = $7e

        low charge
        low red
        low yellow
        low green
        
        on interrupt goto serial
 
        INTCON = %11000000
        PIE1 = %00100000
 
         goto    main


' interrupt service routine        
        disable
serial:
       
        hserin 0, endisr, [char]
        
        if  char = $04 then 
            low charge
        endif
       
        if  char = $03 then 
            high charge
        endif
         
        if  char = $16 then 
            low red
            low yellow
            low green
        endif
        
        if  char = $17 then 
            high red
            low yellow
            low green
        endif
        
        if  char = $18 then 
            low red
            high yellow
            low green
        endif
        
        if  char = $19 then 
            low red
            low yellow
            high green
        endif

endisr:
        resume
        enable
        ' end of ISR
       
main:     
       pause 500
       goto main
        

EV_Charger_Live.ino

Arduino
Live Timing Version
//****************************************************************
//*  Name    : EV Charger Live                                   *
//*  Author  : Robert Joseph Korn                                *
//*  Notice  : Copyright (c) 2015 Open Valley Consulting Corp    *
//*  Date    : 12/14/15                                          *
//*  Version : 1.1                                               *
//*          :                                                   *
//*  Notes   :  Charger Control Codes                            *
//*          :  03 - Charger On                                  *
//*          :  04 - Charger Off                                 *
//*          :  07 - Initialize Display                          *
//*          :  12 - Clear Display(must be followed by cr lf)    *
//*          :  22 - Signal Tower Off                            *
//*          :  23 - Signal Tower Red                            *
//*          :  24 - Signal Tower Yellow                         *
//*          :  25 - Signal Tower Green                          *
//*          :                                                   *
//*          :  States                                           *
//*          :  0 - Waiting for Swipe                            *
//*          :  1 - Parsing Track 1                              *
//*          :  2 - Parsing Track 2                              *
//*          :  3 - Processing Swipe                             *
//*          :                                                   *
//*          :                                                   *
//****************************************************************

int SER = 0;
int state = 0;
int numlen=0;
int namlen=0;
int o=0;
char nam[255];
char num[55];

void setup() {

  Serial1.begin(9600);
  Serial1.write(22); 
  Serial1.write(4);
  Serial1.write(12); 
  Serial1.println();
  Serial1.write(12);
  Serial1.println("MediaTek Linkit One");
  Serial1.write(14);
  Serial1.println("  EV Charger Demo  ");
  delay(2500);   
  Serial1.write(25);
  Serial1.write(12);
  Serial1.println("EV Charger is Ready");
  Serial1.write(14);
  Serial1.println("Swipe Card to Begin");

}

void loop() {
   
          if( state == 3 ) 
          {     
              Serial1.write(24);
              Serial1.write(12);
              Serial1.println("      Welcome       ");
              Serial1.write(14);
              
            for(int o=0;o<namlen-1;o++)
             {
               Serial1.print(char(nam[o]));             
             }
             
             Serial1.println("");
             
             delay(2500);   
             Serial1.write(3);
             Serial1.write(12);
             Serial1.println("Charging in Progress");
             Serial1.write(14);
             Serial1.println("  2.0 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.9 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.8 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.7 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.6 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.5 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.4 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.3 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.2 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.1 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  1.0 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.9 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.8 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.7 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.6 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.5 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.4 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.3 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.2 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.1 Hours Remain");

             delay(360000);   
             Serial1.write(14);
             Serial1.println("  0.0 Hours Remain");

             delay(1000);   
             Serial1.write(4);
             Serial1.write(12);
             Serial1.println("Charge Time Complete");
             Serial1.write(14);
             Serial1.println("EV Charger is Ready");

             delay(2500);   
             Serial1.write(25);
             Serial1.write(12);
             Serial1.println("EV Charger is Ready");
             Serial1.write(14);
             Serial1.println("Swipe Card to Begin");

            numlen=0;
            namlen=0;
            state=0;     
          }
  
  if (Serial1.available() > 0) {
      SER = Serial1.read(); 

  switch(state)
  {
    case 0:if (SER==0x3B)  
               {
                 state=1;
               }
           if (SER==0x25)  
               {
                 state=2;
               }break;
               
    case 1:num[numlen]=SER;  
            numlen++;             
              if (SER==0x3F)  
               {
                 state=3;
               }break;
               
    case 2:nam[namlen]=SER;  
            namlen++;              
              if (SER==0x3F)  
               {
                 state=0;
               }break;
          
     default:break;
  }
 
  }

}

Credits

Robert Korn

Robert Korn

15 projects • 27 followers
I Made the Internet of Things before people had a name for it.

Comments