-
Some software improvements
08/20/2021 at 20:22 • 0 commentsOne thing that can happen is that USB voltages can vary quite a bit. Given that we're scaling a 24 volt range into a 5 volt range for the ADC, even a half a volt difference in reference means a 10% error in the voltmeter readings.
We can calibrate the reference voltage by comparing it to the ATTiny's internal bandgap reference of 1.1v. Measure that with the ADC and you can indirectly measure the reference voltage. With that, we can scale the ADC readings against our measured reference voltage and make the voltmeter readings a bit more accurate.
Additionally, if we set one of the timers to free-run and trigger timer capture with the AC output, we can actually measure the duty cycle against the system clock with a very high (16 MHz) granularity. We can also count the number of times the AC output changed during the sampling period to perform the frequency counting, as before.
With these two improvements, plus the impedance buffer hardware change, the whole system has been pretty much perfected.
-
Yet another issue
08/13/2021 at 02:23 • 0 commentsWell, I thought I had solved the previous issue nicely by adding a near-zero volt reference and using the analog comparator. Alas, we're not completely out of the woods.
Here's a view of the ADC input pin with the sim in state D:
That little 0.5V downward tick is caused by the ADC sample-and-hold. The issue is that the impedance of the divider network is quite high, and the datasheet recommends no higher than 10 kΩ of output impedance into the ADC. That 3 volt level (coincidently) represents a 3 volt input. Dropping a half volt from that drops the ADC sample voltage down to 2.5 volts, which is the reference for the analog comparator. The result is screwy duty cycle readings.
It's probably adequate to work around this by simply reducing the reference voltage, The little downward ticks don't really have any ill effect beyond this. Another solution would be to add an op amp impedance buffer. I'll probably build a board to see what that looks like, but for now I suspect I'll lower the reference voltage just a little bit.
EDIT: I lifted the analog input pin and tacked in a GP SOT23-5 op amp wired as a buffer. With that, the effects of the high impedance on the ADC disappeared and it works perfectly.
I have some inventory of the boards without the amp footprint and will go ahead and use those up with a slightly lower-than-zero AC reference input, but with the op amp I think it's essentially perfect.
EDIT #2:
The correct voltage divider for the AC is 10kΩ high and 12kΩ low. With a 5 volt Vcc, that results in 2.71V, which is very close to an input side voltage of 0V. Swapping those two results in 2.27V, which represents -3V, but is low enough to work around the "ticks" seen above. While lowering the AC comparison like that is somewhat less than perfectly accurate, it won't do any harm when working with compliant systems, as the expectation is that the negative should stay close to -12 volts. The worst case scenario is that mode D with a missing diode may not hit both sides of the comparator, but that's two unlikely circumstances (missing diode and mode D) happening simultaneously.
-
An issue has come up
07/21/2021 at 05:30 • 0 commentsUnfortunately, a small issue has been brought to my attention. When the duty cycle is either very low or very high, the frequency measurement may be incorrect. This happens when the duty cycle is less than about 12% or greater than about 88%.
It takes about 128 microseconds to perform an ADC conversion. Since the frequency is 1 kHz, that means one whole cycle is 1000 microseconds. 12.8% of that is... 128 microseconds. That means that any duty cycles where the positive-going or negative-going portion is shorter than that might wind up getting skipped over. That means that two transitions won't be counted, and the frequency will read low.
The fix for this is to configure the analog comparator to be the frequency counter using interrupts. Unfortunately, this can't be done without some changes to the hardware, since the only available internal comparison source is the bandage reference, which equates to an input voltage of something like -10.5, which is way too low. Additionally, for the ATTiny84 (used on the display variant), you can't use the ADC MUX output for the analog comparator while the ADC is enabled.
The only fix is to free up the two analog comparator pins and provide a reference on the negative input that corresponds to something close to zero volts. As it turns out, this is around 2.75 volts or so, which we can make with a 10kΩ/12kΩ voltage divider. AIN0/00 can be configured as both the positive input to the comparator and the input to the ADC. The ISR can just increment the high, low and change values in the ISR as appropriate.
We can still perform ADC operations to determine the high and low peak voltage. The ISR of the AC will insure we never miss a transition, and with something like 7000 samples per second, the changes we will miss both the positive and negative edges is minute for any legal J1772 duty cycle.
-
EV Sim Remote build report
12/08/2019 at 07:26 • 0 commentsThe first prototype looks like it may wind up being the final version. It works perfectly (after a handful of firmware fixes).
-
A new iteration
11/18/2019 at 02:42 • 0 commentsSomeone shared with me today that they were using the EV Sim for automated EVSE testing. That inspired me to think of a way to replace the display with a connection to a computer so that interactions and measurements could be automated.
The result is the EV Sim Remote. It swaps out the ATTIny841 for the ATTiny84. The upgrade gives us a USART for serial I/O. That's connected to a CY7C65213 USB UART and then to a micro USB connector. Instead of the DIP switches, the 3 resistors are switched in and out of the pilot line with N MOSFETs controlled by GPIO pins on the controller.
The serial port will be set up for 9600 8N1. The output format will be printable and consist of the measured frequency, duty cycle, minimum and maximum voltage. To change state, you simply send an "A", "B", "C" or "D". Unlike the backpack variant, there is no mechanism to remove the diode.
EDIT:
Yes, this could be done instead with USBTiny, but then I'd have to make a CDC device and this is just easier.
-
v4.0 now available
11/07/2016 at 08:39 • 0 commentsThe version shipping from the Tindie store is now version 4.0. This version has a button that will switch the display from showing the duty cycle and ampacity to showing the positive and negative peak voltage.
-
v4.0 coming soon
01/03/2016 at 22:12 • 0 commentsThe version of the EV Sim that's in the store today has the comparator, but the one thing the comparator loses is the voltage levels.
OpenEVSE traditionally uses a three transistor network to sample and scale the ±12 volt range of the pilot to 0-5 volts, and then feeds that into an ADC pin of the controller. However, OpenEVSE has no need to attempt to divine the duty cycle of the pilot (after all, it's the EVSE generating it). I designed the comparator circuit originally because I was unsure that the duty cycle could be reasonably sampled given the extra latency required by the analog to digital conversion.
It turns out, however, that my fears were unfounded. An EV Sim based on the same sampling circuit works just fine. What you get from doing this is not only the ability to read the duty cycle, but you can also display the minimum and maximum voltages. The v4.0 EV Sim includes a button to switch between multiple display modes - the original one that shows the ampacity, and a new one that shows the minimum and maximum voltage. The voltage readings are not spectacularly accurate, but it's quite convenient, and the duty cycle measurements are just as accurate as it was with the comparator.
This version will go into the store as soon as stock of the current version runs out.