OpenEVSE DEV: Detecting three-phase using single CT sensor

I noticed the datasheet says that due to hardware limitations the EmonEVSE will overestimate the kWh charged when a 1 phase vehicle is charging on a 3 phase unit.

Did I see correctly that the openEVSE controller v4 has 3 ADC pins unused? And that there is no voltage sensing other than the L+N vs L1+L2 test for determining service level?

If it was possible to compare the phase of the voltage and the current, then 1 phase or 3 phase could be detected by running all 3 phases through the CT (the one that supplies the controller and 1 phase vehicle) once, the other 2 phases twice. Assuming resistive impedances a 1 phase vehicle would give a current in phase with the voltage, while a 3 phase vehicle would deliver a current 180 degrees out of phase on the CT.
Does that make sense?

Can phase be inferred from the AC test digital inputs?
EDIT: I think we can. The AC test digital inputs are connected to a MID400 AC line monitor, which are connected to the AC lines through diodes.
Because of the rectifier diode, the output should be low for about 10 ms, and then high for about 10 ms (assuming 50 Hz). So comparing the relevant AC test input to the ADC value should give a good indication if the current is in phase with the voltage, or 180 degrees out of phase.
This would require flashing new firmware to the controller, but I think it is doable with current hardware. What do you think?

So I had a go at detecting if a one phase EV is charging on a three phase EmonEVSE. It was more difficult than I thought when I started. Now I have the software working in a proof-of-concept setup. :slight_smile:
The main difficulty was figuring out what the input from the AC test circuit looks like. The openEVSE controller board I got is a v5 board, that uses a HCPL-2731 optocoupler instead of a MID400. The application notes I found either didn’t mention using it as an AC line monitor, or they were short on detail about how the device behaves typically under those conditions. I ended up using the serial debugger to print out a string of ones and zeroes, 1 char for every sample:

Current: 0000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111110000000000000000
Voltage: 0111111111111111111110000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111110000000000000000
Samples: 143
Current: 0000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111111111111111111111100000000000000000
Voltage: 0111111111111111111110000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111111111111100000000000000000
Samples: 142

(I programmed it so that when voltage was detected on AC_TEST2, a zero was printed, otherwise a one. Current is 0 for positive value, 1 for negative value)

As you can see, current en voltage do line up at the center of the half cycle. Once I knew that, all I had to do was write the code to measure when the center of the positive half of the current and the voltage appear, and compare them to calculate phase difference.

My proof-of-concept setup uses a 3 phase EmonEVSE on a one phase power supply (230V), and a space heater as the “EV”. When I mount the CT inside the EmonEVSE in one direction around the L1 wire, the unit counts the power as one phase power (current in phase with voltage). When I put the CT the other way around the L1 wire, it counts the power as 3 phase power (current in counter phase with voltage).

I uploaded my code to GitHub - janherrygers/open_evse: Firmware for OpenEnergyMonitor OpenEVSE

Next steps are

  • to connect the unit to a 3 phase socket to see if it still works as intended. My current plan is to run L1 and L2 through the CT, connect the space heater to L2, and see if it counts 3 phase. I haven’t thought of a way to simulate a 3 phase load yet (L1+L2 should shift the center of the current half wave in between L1 and L2), so suggestions are welcome.
  • I’d like to get some 3rd party review on my setup and code. I am a software developer by day, but I don’t program microcontrollers professionally.
  • Finally, now that I have 3 phase detection, it would be nice to get some feedback on the display about how many phases are used. Maybe even on the web page.

Nice work, this is really clever.

Let me know if you would like any more into about the HCPL-2731 on the V5 I can put you in touch with the designer Chris Howell.

Could actual EV 3-phase? This will obviously be the best test. Let me know how you get on

Sure, Sam (lincomatic) is the principal maintainer for the openevse firmware. I’m in regular contact with him, I can get him to review the code. We will struggle to test 3-phase since he is in the USA. He will be responsible for merging any changes into the firmware. Any pull requests should be directed to his dev branch GitHub - lincomatic/open_evse at development. We are getting quite close to the memory limit for the Atmega328.

We can definitely do this. We would probably need a RAPI command or status to donate the fact the unit is operating in three-phase mode. Making changes to the WiFi-gateway firmware is not an issue. In fact it’s already been discussed:

I must say, the resources on An Introduction to AC Power — OpenEnergyMonitor 0.0.1 documentation help a lot. If only to refresh the things I was taught in electrodynamics class in university.

I think I learned enough from debugging the actual hardware.

I’m not sure I have access to an EV that does 3 phase charging. I mainly wanted a 3 phase unit to feel more future proof.

I wonder if my boss’ Audi PHEV charges on 3 phases. Then there is the question of casually asking my boss if I can hook up his car to my experimental EVSE. :sunglasses:

I noticed that about the memory limitation. Especially when I had added the serial debugging code.

I feel like I could improve on the executable size for my solution, but I was so excited I got something to work, that I wanted to share.
I would appreciate it if he wanted to have a quick look at Determine phase angle difference between current and voltage to decid… · janherrygers/open_evse@1daf48b · GitHub and say if I’m on the right track or not. Should I create an issue in Sam’s repository, or can you put me in touch with him?

Interesting. I definitely have to look at that when I’m confident that the detection part is finished.

Yes creating an issue on his repo is probably best. Let me know if you do and I’ll make sure he sees it and give him some background.

I’m sure you could work it! However it’s only 3kW I’m afraid :open_mouth:. Most. Phevs charge slowly since they don’t have a real need to charge fast Audi A3 TFSI e (2021) Charging Guide | Pod Point. For three phase you will need a Zoe, i3, Tesla or some Mercedes. Nissan leafs are all single phase