ElectricMotorcycleForum.com

  • November 23, 2024, 05:11:10 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Electric Motorcycle Forum is live!

Pages: 1 [2] 3 4

Author Topic: Another DIY Quick Charger  (Read 10416 times)

firepower

  • Hero Member
  • *****
  • Posts: 686
  • Hanoi, Vietnam
    • View Profile
Re: Another DIY Quick Charger
« Reply #15 on: April 23, 2015, 06:44:49 PM »

Yes I would like more info too on how to use the I2C as well.
Logged

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: Another DIY Quick Charger
« Reply #16 on: April 23, 2015, 11:07:25 PM »

You're correct. You can't use both I2C together or you would have to have an isolated I2C to I2C converter.

I just used the I2C information from one PSU. The current is exactly the same between the 2 PSU's as they are in series. The temperature is from the PSU the I2C is connected to. The voltage is measured by a voltage divider connected to an analog input on the atmel microcontroller. also read from the I2C bus. This way i can show temperature, current and total voltage (multiply the I2C value by 2) and calculate and show power to the Battery .

The power for the microcontroller comes from the 12V 0.25A auxiliary (isolated) supply the PSU generates. Be sure to use a 12 to 5 volt converter as the maximum voltage for the microcontroller is 5.5 Volts.

The wire gauge for the output wire is 10mm2 I believe, i'm not really sure as it was a piece of super flexible Car audio amplifier wire I had lying around. The wire gauge for the input cable is 2.5mm2 which is standard for a 16A 230V supply we have here.
You could do with less than 10mm2 on the output wiring but don't go below about 4mm2 as both the voltage drop over the wire would become greater than the sense-lines can compensate for and the PSU charges less than it can. Also anything less than 2.5mm2 can fry your wire if charging with 22A !

In the mean time i switched from the standard 230V 16A connector to a Mennekes type 2 connector to be able to charge from a charging point here in Holland. This is a three phase connection which allowed me to wire each PSU to one phase and connect the internal charger to the remaining phase. This distributes the current much better than using all three on a single phase.

As described above the total of 2 PSU's plus the internal charger asks about 4000 watt from the charging station and connecting it all to a single phase can lead to tripping of the breaker. Wiring it all to a separate phase prevents tripping the breaker.

« Last Edit: April 23, 2015, 11:17:46 PM by remmie »
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: Another DIY Quick Charger
« Reply #17 on: April 23, 2015, 11:15:52 PM »

Here is the complete code (in MIKROE BASIC for AVR, use similar code for other programming languages)
Also amended the previous post because the voltage is also read from the I2C (assumed is that the other PSU has exactly the same voltage)

[code start]

program ZeroChargerReadout

' * Description:
'     This code shows the voltage, current and temperature on n FPS1000-48 PSU
'     initialized, then some text is written, then the text is moved.
' * Test configuration:
'     MCU:             ATTiny28L
'                      http://www.atmel.com/dyn/resources/prod_documents/doc2466.pdf
'     Dev.Board:       EasyAVR6 -  ac:LCD
'                      http://www.mikroe.com/eng/products/view/321/easyavr6-development-system/
'     Oscillator:      External Clock 08.0000 MHz
'module ZeroChargerReadout v2
'                      http://www.mikroe.com/eng/products/view/277/various-components/
'     SW:              mikroBasic PRO for AVR
'                      http://www.mikroe.com/eng/products/view/226/mikrobasic-pro-for-avr/
' * NOTES:
'     - Turn on the LCD backlight on the EasyAVR6 board (SW10.7).
' *

' Declarations section

' LCD module connections
dim LCD_RS as sbit  at PORTD2_bit
dim LCD_EN as sbit  at PORTD3_bit
dim LCD_D4 as sbit  at PORTD4_bit
dim LCD_D5 as sbit  at PORTD5_bit
dim LCD_D6 as sbit  at PORTD6_bit
dim LCD_D7 as sbit  at PORTD7_bit

dim LCD_RS_Direction as sbit at DDD2_bit
dim LCD_EN_Direction as sbit at DDD3_bit
dim LCD_D4_Direction as sbit at DDD4_bit
dim LCD_D5_Direction as sbit at DDD5_bit
dim LCD_D6_Direction as sbit at DDD6_bit
dim LCD_D7_Direction as sbit at DDD7_bit
' End LCD module connections

' Software I2C connections
dim Soft_I2C_Scl_Output    as sbit at PORTD0_bit
dim Soft_I2C_Sda_Output    as sbit at PORTD1_bit
dim Soft_I2C_Scl_Input     as sbit at PIND0_bit
dim Soft_I2C_Sda_Input     as sbit at PIND1_bit
dim Soft_I2C_Scl_Direction as sbit at DDD0_bit
dim Soft_I2C_Sda_Direction as sbit at DDD1_bit
' End Software I2C connections

dim txt1,txt2 as char[16]
dim strvoltage as string[17]
dim strcurrent as string[17]
dim strtemperature as string[17]
dim strenergycalc as string[17]
dim strpower as string[17]
dim voltage as byte
dim current as byte
dim temperature as byte
dim channel4 as byte
dim voltagecalc as float
dim currentcalc as float
dim temperaturecalc as float
dim powercalc as float
dim energycalc as float
dim statusbyte as byte
dim displayrotation as byte

Main:
initialize:
    Lcd_Init()                                                                  ' Initialize LCD
    Lcd_Cmd(_LCD_CLEAR)                                                         ' Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF)                                                    ' Cursor off
    LCD_Out(1,1,"Zero SR Charger")                                                           ' Write text in first row
    LCD_Out(2,1,"V2 Made by RH")                                                           ' Write text in second row
    Delay_ms(2000)                                                              ' Display splash screen for 1 second
    LCD_cmd(_LCD_Clear)                                                         ' Clear Display
    Soft_i2c_init()                                                             ' Initialize I2C bus
    Soft_i2c_Start()                                                            ' Issue start signal
    Soft_i2c_Write(0x9E)                                                        ' Address PCF8591, see PCF8591 datasheet
    Soft_I2c_Write(0x44)                                                        ' Set analog output and auto increment channel
    Soft_I2c_Stop()                                                             ' Close I2C bus
    displayrotation = 1                                                         ' Set display rotation byte
    energycalc = 0
loop:
while TRUE
read_I2C_analog:
    Soft_I2C_Start()            ' Issue start signal
    Soft_I2C_Write(0x9F)           ' Address PCF8591, see PCF8591 datasheet
    channel4 = Soft_I2c_Read(1)    ' first channel4 because it's always the result from the previous input (by design)
    voltage = Soft_I2C_Read(1)     ' Read voltage byte
    current = Soft_I2C_Read(1)     ' Read current byte
    temperature = Soft_I2C_Read(0) ' Read Temperature byte and send not ack to indicate last byte read
    Soft_I2C_Stop()                ' Issue stop signal

read_I2C_digital:
    Soft_I2C_Start()               ' Issue start signal
    Soft_I2C_Write(0x4F)           ' Address PCF8574, see PCF8574 datasheet
    statusbyte = Soft_I2C_Read(0)    ' first channel4 because it's always the result from the previous input (by design)
    Soft_I2C_Stop()                ' Issue stop signal

Calculations:
    voltagecalc = voltage*2.0*60.0/255.0                 '8 bit resolution up to 60 Volts
    floattostr(voltagecalc,strvoltage)               'convert to a string
    strvoltage[5]=0                                  'truncate the first 5 characters of the string

    currentcalc = current*25.0/255.0                                            ' 8 bit resolution up to 25 Amps
    floattostr(currentcalc,strcurrent)                                          ' convert to a string
    strcurrent[4]=0                                                             ' truncate to first 4 characters of the string

    temperaturecalc = temperature*100.0/255.0                                   ' 8 bit resolution up to 100 degrees celcius
    floattostr(temperaturecalc,strtemperature)                                  ' convert to a string
    strtemperature[4]=0                                                         ' truncate to the first 4 characters

    powercalc = voltagecalc*currentcalc/1000                                         ' calculate power from voltage * current and divide by 1000 to get kW
    floattostr(powercalc,strpower)                                              ' convert to a string
    strpower[4]=0                                                               ' truncate the first 4 characters of the string
 
    energycalc = energycalc + powercalc/3600
    floattostr(energycalc,strenergycalc)
    strenergycalc[5]=0
    statusbyte =statusbyte or 96
 
 displayoutput:
    txt1 = "V=" + strvoltage + "V I=" + strcurrent + "A"                        ' first line of the LCD : always displays the Voltage and Current
    txt1[16]=0                                                                  ' truncate to 16 characters if neccessary to avoid weird screens
    LCD_Out(1,1,txt1)                                                           ' Write text in first row

    statusbyte = statusbyte and displayrotation                                 ' check 1 alarm each loop (displayrotation shifts one bit to the left each loop)
    Select case statusbyte
      case 1                                                                    ' output fail
        txt2="Output Fail     "
      Case 2                                                                    ' overtemp protect
        txt2="Overtemp Protect"
      Case 4                                                                    ' Temperature alarm
        txt2="Temp alarm      "
      Case 8                                                                    ' Fan Fail
        txt2="Fan Fail        "
      Case 16                                                                   ' Input Fail
        txt2="Input Fail      "
      Case 32
        txt2="E=" + strenergycalc + "kWh      "
      Case 64
        txt2="E=" + strenergycalc + "kWh      "
      Case else
        txt2 = "P=" + strpower + "kW T=" + strtemperature + "C"                 ' this line is displayed if
    End select
    txt2[16]=0                                                                  'truncate to 16 characters if neccessary to avoid weird screens
    LCD_Out(2,1,txt2)                                                           ' Write text in second row

    displayrotation = displayrotation *2                                        ' Shift displayrotation one bit to left
    if displayrotation = 128 then displayrotation = 1                            ' the second line shifts through 6 possible displays, 1 for each of 5 alarms and 1 for the power and temperature
    end if
    delay_ms(980)                                                                'rest of the cycle is about 20ms, this generates a more excact 1 sec timebase without using interrupts :)
wend
end.
« Last Edit: April 23, 2015, 11:20:07 PM by remmie »
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

firepower

  • Hero Member
  • *****
  • Posts: 686
  • Hanoi, Vietnam
    • View Profile
Re: Another DIY Quick Charger
« Reply #18 on: April 24, 2015, 04:41:29 AM »

Thanks for sharing your code and info of I2C.

The PCF8591 and PCF8574 are they the I2C devices in the Powersupply your monitoring?

http://www.nxp.com/documents/data_sheet/PCF8591.pdf
http://www.nxp.com/documents/data_sheet/PCF8574.pdf
« Last Edit: April 24, 2015, 05:33:57 AM by firepower »
Logged

MotoRyder

  • Riding innovative motorcycle machinery is a passion
  • Jr. Member
  • **
  • Posts: 80
    • View Profile
Re: Another DIY Quick Charger
« Reply #19 on: April 24, 2015, 10:03:59 AM »

Hey firepower,
(If I'm covering things you already know, then the following may help others on the forum.)

Those two devices (PCF8591  &  PCF8574) almost certainly reside on the  EasyAVR6  Dev  Board (I haven't checked the board schematic, but have seen many, so taking an educated guess).
 
The  EasyAVR6  is a general purpose Printed Circuit Board Assembly (PCBA) that the manufacturer (Atmel) devises for people to investigate their microcircuits and prototype with, such as the  ATTiny28L MCU utilized here (MCU stands for Micro-Controller Unit). 

The PCF8591  is  8-bit A/D (Analog to Digital) and D/A (Digital to Analog) converter.
The voltage is measured and then converted to a digital number (with the A/D portion of the chip) to obtain the value to display on the digital LCD display.

The PCF8574 Remote 8-bit I/O expander for I2C-bus
is a parallel 8-bit port that changes the 8-bits wide 'Voltage' data into a serial stream of data, because the data is transmitted on the I2C-bus to get it into the MCU to be processed.

If anything else other than this same circuit is used for processing the data for the display, then one would be able to use remmie's code as an example to generate their own program because it is commented very well so it can be 'ported' to a different processor.
« Last Edit: April 24, 2015, 10:26:46 AM by MotoRyder »
Logged
Traveling by motorcycle, one can experience the true ambience of the surroundings

zerovolt

  • Newbie
  • *
  • Posts: 29
  • Zero s 11.4 2014, volt 2013
    • View Profile
Re: Another DIY Quick Charger
« Reply #20 on: April 24, 2015, 10:51:11 AM »

hi Remmie,

how do you activate the contactor to begin the flowing charge? On the picture of you charger , i dont see nothing
at the small pins in the center of your anderson connector.

tanks !
Logged

frode

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Another DIY Quick Charger
« Reply #21 on: April 24, 2015, 03:01:02 PM »

You're correct. You can't use both I2C together or you would have to have an isolated I2C to I2C converter.

I just used the I2C information from one PSU. The current is exactly the same between the 2 PSU's as they are in series. The temperature is from the PSU the I2C is connected to. The voltage is measured by a voltage divider connected to an analog input on the atmel microcontroller. also read from the I2C bus. This way i can show temperature, current and total voltage (multiply the I2C value by 2) and calculate and show power to the Battery .

The power for the microcontroller comes from the 12V 0.25A auxiliary (isolated) supply the PSU generates. Be sure to use a 12 to 5 volt converter as the maximum voltage for the microcontroller is 5.5 Volts.

The wire gauge for the output wire is 10mm2 I believe, i'm not really sure as it was a piece of super flexible Car audio amplifier wire I had lying around. The wire gauge for the input cable is 2.5mm2 which is standard for a 16A 230V supply we have here.
You could do with less than 10mm2 on the output wiring but don't go below about 4mm2 as both the voltage drop over the wire would become greater than the sense-lines can compensate for and the PSU charges less than it can. Also anything less than 2.5mm2 can fry your wire if charging with 22A !

In the mean time i switched from the standard 230V 16A connector to a Mennekes type 2 connector to be able to charge from a charging point here in Holland. This is a three phase connection which allowed me to wire each PSU to one phase and connect the internal charger to the remaining phase. This distributes the current much better than using all three on a single phase.

As described above the total of 2 PSU's plus the internal charger asks about 4000 watt from the charging station and connecting it all to a single phase can lead to tripping of the breaker. Wiring it all to a separate phase prevents tripping the breaker.
Thank you for explaining this! I have a lot of experience in micro-controller dev and PCB-design, but not with voltage levels above 24V :)
And really nice of you to share the source code for the micro!

« Last Edit: April 24, 2015, 05:31:05 PM by frode »
Logged

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: Another DIY Quick Charger
« Reply #22 on: April 24, 2015, 09:25:27 PM »

The 2 pcf ic's are not on the easy avr dev board but integrated in the PSU. One is used to measure voltage, current and temperature (1 pcs 4 channel 8 bit a/d converter) the other pcf is for status of the PSU (see code or PSU datasheet for details)

i use the internal charger to activate the contactor and do not use the 2 additional pins on the anderson connector.

So the I2c part is really easy. 5v converter, microcontroller, lcd and  Enclosure.
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

frode

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Another DIY Quick Charger
« Reply #23 on: April 27, 2015, 02:47:17 PM »

So the I2c part is really easy. 5v converter, microcontroller, lcd and  Enclosure.
Do you use pin 10 (signal return) as ground reference for your 5v voltage regulator and microcontroller board?

Logged

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: Another DIY Quick Charger
« Reply #24 on: April 27, 2015, 03:41:06 PM »

Yes, correct

Also -sense is connected to this pin sigal return as -sense is the referencepin for the I2C

This is the reason that you cannot use  both I2C signal from 2 PSU's in series.
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

Ronen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Another DIY Quick Charger
« Reply #25 on: April 28, 2015, 04:11:17 PM »

Hi Remmie,

Thank you for all the information.
I plan to use your schematic and make that quick charger but without the I2C.
Did you use a 50K potentiometer to adjust the voltage? do i need a special potentiometer?
what do you mean when you draw 2 diodes together at the top of the schematic (connect to PSU1-1_V+)?
Can you please give more closer pictures?

Thanks, Ronen.
Logged

remmie

  • Sr. Member
  • ****
  • Posts: 318
    • View Profile
Re: Another DIY Quick Charger
« Reply #26 on: April 28, 2015, 04:17:49 PM »

Yes i used a 50k potmeter. I used a multiturn  trimpormetertype for more accuracy
The 2 diodes were because i used mbr1660 diodes with a max current of 16A. Therefore 2 to distribute the current. I had them lying around.

If you would use a diode with a higher current rating you would only need one.
Logged
Current : Red Premium Zero SR/F (ordered May 25, delivered August 23 2019) with Rapid charger for 12kW charging
Former : White Zero SR 2018 ZF14.4 kWh (17.500 km)
Former : Black Zero SR 2014 ZF11.4 kWh (25.000 km)
SR's outfitted with Homemade "Supercharger" 6x eltek Flatpack S (12 kW)

zerovolt

  • Newbie
  • *
  • Posts: 29
  • Zero s 11.4 2014, volt 2013
    • View Profile
Re: Another DIY Quick Charger
« Reply #27 on: April 28, 2015, 05:49:22 PM »

Hi Remmie,
Are these diodes very important, because there is no inductive load? probably never reverse current.... :)

Thanks
Logged

Ronen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Another DIY Quick Charger
« Reply #28 on: April 29, 2015, 12:39:24 PM »

Hi Remmie.

Thanks again!
Can you please give more closer photos?
Logged

Doug S

  • Hero Member
  • *****
  • Posts: 1631
    • View Profile
Re: Another DIY Quick Charger
« Reply #29 on: April 29, 2015, 08:25:58 PM »

Are these diodes very important, because there is no inductive load? probably never reverse current.... :)

Inductive kickback isn't the problem. The diodes prevent reverse voltage on the power supplies from occurring. When the supplies are turned off, you need to isolate them from the battery, or you'll have the battery voltage impressed on the power supplies instead of the other way around. Also, if you have a power supply fail, and for a brief period at turn-on (the two supplies are not going to turn on at exactly the same time), there will be just one power supply trying to apply 57 volts onto a 103V battery. The diodes are cheap insurance against that happening.
Logged
There's no better alarm clock than sunlight on asphalt.
Pages: 1 [2] 3 4