Gen 3 inverter converter control software

Topics concerning the Toyota and Lexus inverter drop in boards
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

Hello! Help is needed. In the bustle of affairs, I got to the charger and before applying the mains voltage - I would like to clarify a few questions that have arisen. To begin with, my Aqua inverter G9200-52010.
1st question: Wrong measurement of DC BUS voltage 1. In the absence of voltage, the terminal was -47~-50v.
In this case, both microcontrollers MG 1 and MG 2 show the correct voltage on the buses
A change has been made to the Atmega code from Bexander
#define DCBUS1_OFFSET_BITS 0// It was 100. Changed it to 0, did I do the right thing? Doesn't bang? )))
#define DCBUS1_V_PER_BIT 0.553
#define DCBUS1_V_PER_BIT_x1024 566 // (DCBUS1_V_PER_BIT * 1024)
Image
2nd question: Wiring diagram - did I do everything right?
Image
HV _CON - Resistor required in parallel? Did I understand correctly?
3rd question: Is communication with bms via CAN bus mandatory? (SimpBMS is planned) I don't have bms yet and I'm still doing experiments on lead batteries from UPS.
Well, I repeat the post above - will it work in one phase? And possible consequences.
Thanks to all!
Attachments
Charger_aqua.png
console_atmega.png
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Gen 3 inverter converter control software

Post by bexander »

Q1) If I remember correctly, adjust offset, with zero voltage present, until you read 0V. Then adjust gain (v/bit) with voltage present until ypu read correct voltage.
Q2) Looks correct. No resistor required in parallel with HV_CON.
Q3) Don't think it is mandatory but adds another layer of protection/safety.

Will work in 1-phase but does leave quite a lot of disturbance on the grid, less disturbance with 3-phase. With 1-phase you also get lower voltage and you can only buck in one direction and boost in the other so input voltage must always be higher then battery voltage, with AC-input connected to MG1.
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

Gain and offset adjusted. Now the voltage readings are correct. It makes me happy!
Now, while I'm looking for a suitable contactor for the AC circuit, I check everything again - and a couple of questions arose.
What are your options for controlling the main contactor "MAIN_CONN" ?
With a transistor (on my diagram below) - also a question: It opens when HV_CON is turned on and pulls EMCY_STOP to 0, which blocks PWM generation for the motor. Or I misunderstood something?
Well, in fact, in the debugging and configuration mode, I run it all through the arduino console. And how best to manage this charger?
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Gen 3 inverter converter control software

Post by bexander »

Yahha777 wrote: Fri Feb 10, 2023 6:39 pm What are your options for controlling the main contactor "MAIN_CONN" ?
I don't understand your question? The main conctactor is controlled by the inverter. It will activate when you send "start" signal (via CAN or direct on start pin) if dc bus voltage is above "udcsw". There are no other options to my knowledge.
Yahha777 wrote: Fri Feb 10, 2023 6:39 pm With a transistor (on my diagram below) - also a question: It opens when HV_CON is turned on and pulls EMCY_STOP to 0, which blocks PWM generation for the motor. Or I misunderstood something?
No diagram attached to your post but I guess you refer to this section:
image_2023-02-11_063746817.png
image_2023-02-11_063746817.png (9.45 KiB) Viewed 2881 times
I never used that part but I agree, it's not good to activate "EMCYSTOP" when HV_CON is on as that is the driving mode. This function should be inverted, i.e. controlled by "HV_CON" and not "HV_CON_CTRL".
Yahha777 wrote: Fri Feb 10, 2023 6:39 pm Well, in fact, in the debugging and configuration mode, I run it all through the arduino console. And how best to manage this charger?
I think it is intended to be controlled via the arduino console. It is also possible to control via CAN, that's how I did it.
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

I don't understand your question? The main conctactor is controlled by the inverter. It will activate when you send "start" signal (via CAN or direct on start pin) if dc bus voltage is above "udcsw". There are no other options to my knowledge.
Should the charging current go through it? Right? And it is controlled by the STM-32 controller. Or make an external control of MG2_DCSW_OUT_2 or send a START signal to MG2_START_IN_58.
I never used that part but I agree, it's not good to activate "EMCYSTOP" when HV_CON is on as that is the driving mode. This function should be inverted, i.e. controlled by "HV_CON" and not "HV_CON_CTRL".
Yes that's right. HV_CON shorts the low side of the voltage to the high side. And when it is active, the STM-32 controllers should generate PWM for the motor. And in this version they are blocked. Do you suggest connecting the base of the transistor to the HV_CON pin?
Thanks a lot for the replies! I will try.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Gen 3 inverter converter control software

Post by bexander »

Yahha777 wrote: Sat Feb 11, 2023 10:22 am Should the charging current go through it? Right? And it is controlled by the STM-32 controller. Or make an external control of MG2_DCSW_OUT_2 or send a START signal to MG2_START_IN_58.
Yes, I ran it with all current going through it, controlled byt the STM32.
Yahha777 wrote: Sat Feb 11, 2023 10:22 am Yes that's right. HV_CON shorts the low side of the voltage to the high side. And when it is active, the STM-32 controllers should generate PWM for the motor. And in this version they are blocked. Do you suggest connecting the base of the transistor to the HV_CON pin?
Correct, that is my suggestion, to connect the base of the transistor to HV_CON via the 1k resistor (instead of HV_CON_CTRL). Note, I have not tested this my self. When I used the inverter as a charger I never noticed this functionality was on the board...
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

That's right. This is how the lock in charging mode will work correctly.
Image
Attachments
блокировка STM.png
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

Everything stopped for me because of the annoying message of the current sensor.
Image
how to set it up? I tried by selecting a voltage divider resistor R2 (12kOhm) - but there is such a narrow resistance range .... And when the inverter is turned on again, this divider parameter is no longer suitable. At the 3rd output of the Atmega 4.25 volts. Maybe there is an opportunity to fix this in the Atmega code?
Attachments
messageUART_Charger.png
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Gen 3 inverter converter control software

Post by bexander »

What does your HW setup look like? Are you running an extra mod-board with op-amps, like in the schematic in your screenshot?
The log implies that the 328p receives approx 3,5V at the current sensor inputs and the standard SW expects 2,5V.
When running the above mentioned op-amp you should have a 2,5V input with zero current if everything is ok.
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

Image
These are the voltages around the operational amplifier. :?
Attachments
OU.png
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Gen 3 inverter converter control software

Post by bexander »

The current sensor output voltages seem low, should be closer to 5,0V when there is no current?
What are the supply voltages to the current sensors, +5V, -5V and 26V?
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

instead of 26 volts - 11.5. This is a fiasco. :(
I will understand the problem of powering the 26 volt circuit. Here the problem with the -5 volt power supply caused trouble. For some reason, the LM2776 does not want to start when the inverter is running on battery power. If I connect the power supply - it starts.
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

26 volts - there is an unsoldered resistor in the strapping of the converter chip. For some reason, the 5 volt to -5 converter stopped starting at all under load. :roll:
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

With good help - the problem was quickly solved!
Image
and the annoying LM2776 chip in the next edition of the printed circuit board was replaced with a MAX735CSA + T. We continue to continue! :D
Attachments
mes_Ok.png
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

My actions:
1 I supply 12 volt power to the inverter board - "PRECCHARGE_RELAY" is turned on, as well as "HV_CON"
2 button start I start the inverter - turns on "MAIN_CONN"
3 I pull EVSE_PROX to the ground, in the terminal I give the command "aca 3" - "HV_CON" is turned off, that's it.
what conditions must be met to enable "AC_Precharge" and further start the inverter?
Image
Attachments
Precharge.png
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Gen 3 inverter converter control software

Post by bexander »

Looks like you need a CAN-bus connected between the charger and BMS.

Code: Select all

HANDLE_CHARGER_STATE(WAITING_CANBUS, [&](){
		if(CANBUS_ENABLE){
			if(canbus_alive()){
				log_println_f("CANbus detected");
				charger_state = CS_WAITING_CHARGE_PERMISSION;
			}
			EVERY_N_MILLISECONDS(5000){
				log_println_f("... Waiting for CANbus");
			}
		} else {
			// Skip ahead, we don't need no CANbus!
			charger_state = CS_WAITING_CHARGE_PERMISSION;
		}
	});
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Gen 3 inverter converter control software

Post by celeron55 »

You need to edit the code to your liking for the CAN part. Either make it understand your BMS, or disable the CAN requirements.
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

I don't have BMS yet. I'm experimenting with lead batteries
turned off the kanbus and saw - 10:27:39.662 -> 23.112s: >> digitalRead(AC_PRECHARGE_SWITCH_PIN) = TRUE :D
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

Hello! So I got back to my charger. So - my configuration: battery - lead 10 * 12 volts(120 volt). The mains voltage is 235 volts, 1 phase is supplied to the rectifier terminals with current sensors. The whole cycle is worked out - but there is no charging current. :( What can be recommendations?
Не заряжается(.png
#define EVSE_FORCE_INPUT_AMPS 0 // I tried to change - this did not give anything ...
Here is the terminal output:
Charge.txt
(9.37 KiB) Downloaded 54 times
Mhs
Posts: 41
Joined: Fri Jul 26, 2019 8:06 pm
Location: Bahrain
Has thanked: 130 times
Been thanked: 7 times

Re: Gen 3 inverter converter control software

Post by Mhs »

Yahha777 wrote: Sun May 21, 2023 11:17 am Hello! So I got back to my charger. So - my configuration: battery - lead 10 * 12 volts(120 volt). The mains voltage is 235 volts, 1 phase is supplied to the rectifier terminals with current sensors. The whole cycle is worked out - but there is no charging current. :( What can be recommendations?
Не заряжается(.png
#define EVSE_FORCE_INPUT_AMPS 0 // I tried to change - this did not give anything ...
Here is the terminal output:Charge.txt
Hello,
I think your EVSE_FORCE_INPUT_AMPS 0 should be your charging AMPS if not using an EVSE
what is your INPUT_CURRENT_MAX_A?
Prius gen3 inverter
Outlander rear motor
Pajero 1990
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

Mhs wrote: Tue May 23, 2023 2:35 pm Hello,
I think your EVSE_FORCE_INPUT_AMPS 0 should be your charging AMPS if not using an EVSE
what is your INPUT_CURRENT_MAX_A?
#define EVSE_FORCE_INPUT_AMPS 3
#define INPUT_CURRENT_MAX_A 25
Mhs
Posts: 41
Joined: Fri Jul 26, 2019 8:06 pm
Location: Bahrain
Has thanked: 130 times
Been thanked: 7 times

Re: Gen 3 inverter converter control software

Post by Mhs »

Yahha777 wrote: Tue May 23, 2023 3:36 pm #define EVSE_FORCE_INPUT_AMPS 3
#define INPUT_CURRENT_MAX_A 25
I believe 3 is low,
Did you pull PP to ground? Your terminal output suggest something going wrong with the signals
Prius gen3 inverter
Outlander rear motor
Pajero 1990
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

I think that the program expects EVSE CP PWM
#define EVSE_FORCE_INPUT_AMPS 3 //set to 10 - nothing changed
01m51.162s: Command: r
01m51.163s: >> BATTERY_CHARGE_VOLTAGE = 140
01m51.164s: >> OUTPUT_CURRENT_MAX_A = 20
01m51.171s: >> disable_pwm = PWM_ENABLED
01m51.178s: >> wanted_output_voltage = 140.00 V
01m51.186s: >> wanted_output_current = 20.00 A
01m51.195s: >> wanted_pwm = 100.00 %
01m51.201s: >> digitalRead(AC_CONTACTOR_SWITCH_PIN) = TRUE
01m51.211s: >> digitalRead(AC_PRECHARGE_SWITCH_PIN) = FALSE
01m51.221s: >> digitalRead(CONVERTER_SHORT_SWITCH_PIN) = FALSE
01m51.233s: >> boost_t1_c = 26.00 C
01m51.239s: >> boost_t2_c = 24.00 C
01m51.245s: >> evse_pp_raw = 400.00 raw what does this mean?
01m51.252s: >> get_max_input_a() = 3
01m51.258s: >> charger_state = CS_CHARGING
01m51.265s: >> charger.fail_reason = CFR_NOT_FAILED It's the same that confuses me
01m51.275s: 100.0% I 0.0A 322V O 0.0A 122V 0W
WARNING: Too little time for main loop detected
Mhs
Posts: 41
Joined: Fri Jul 26, 2019 8:06 pm
Location: Bahrain
Has thanked: 130 times
Been thanked: 7 times

Re: Gen 3 inverter converter control software

Post by Mhs »

Yahha777 wrote: Tue May 23, 2023 5:34 pm
01m51.245s: >> evse_pp_raw = 400.00 raw what does this mean?
evse_pp_raw = analogRead(EVSE_PP_PIN);

Are you connecting "EVSE_PP_PIN A7 on the Arduino or Pin 30 on the AMPSeal " to ground?
Prius gen3 inverter
Outlander rear motor
Pajero 1990
Yahha777
Posts: 52
Joined: Wed Feb 27, 2019 7:03 am
Location: Belorussia. Borisov
Has thanked: 15 times
Been thanked: 1 time
Contact:

Re: Gen 3 inverter converter control software

Post by Yahha777 »

Mhs wrote: Tue May 23, 2023 6:43 pm evse_pp_raw = analogRead(EVSE_PP_PIN);

Are you connecting "EVSE_PP_PIN A7 on the Arduino or Pin 30 on the AMPSeal " to ground?
yes :?
Post Reply