I battled with the calibration inside the STM8 for too long and decided to abandon it. Instead I now created a calibrate.py script that can be used with a serially connected multimeter to do automatic calibration. ...
Baruch, it is interesting comparing notes with you since you are going the native STM route whereas I am trying for an Arduino based control board.
Yeah, serial connect automation is the way to go... I was just about to do that to update my hardcoded calibration... an old demon came back - I am reminded when I collected data for the current sense resistor, I had some ground-level issues with the serial.
If I recall, RS232 is one of your primary objective, Part II here may interest you.
I. I have my Arduino-based control board working (on a breadboard and not yet ready to commit to solder). My "calibration" is hardcoded. I am still setting output Voltage/Current by tac-button setting the PWM count directly. I have a couple of issues I need to solve before I can think of committing it to soldered proto-board.
I also have good luck with increasing PWM resolution - to 15 bits PWM. I have
Vout adjustment down to +-1mV with +-2mV stability. For example, I set Vout to 11.010V and get Vout at 11.008 to 11.012V. Of course there is the much bigger (60mV+) high frequency noise that the DMM doesn't see. I get this +-2mV stability down to Vout=20mV. I have not tested it at > 16V out yet.
I suppose if I want to, I could spend more time to try to reach the max PWM (16bit). Since +-1mV is good enough for me so I went on to "fry bigger fish".
Now part II, USB/RS232 issuesII. I am left with two interesting issues, Bluetooth looks like a solution that may solve both.
II.1. The build in XL1509 output (around) +5V to the control board. @Flex shows it is only 4.92V on his schematic, mine is about the same at 4.91V. If I use that low voltage as +V for the Arduino, it is a bit low even when I bypassed the VIN voltage regulator. With such low V,
presence or absence of USB affects my calibration. I solved it with another power source of +7V to Arduino VIN for now.
For example, at a particular PWM setting:
Without USB, Vout=11.061V
With normal USB, Vout=11.081V
(I made a custom 3pin USB to test if I take out USB's +5V, would voltage go back as if no USB)
With USB but USB’s +5V is not connected, just GND, D+, D-. Vout=11.088V
This 0.02V delta hols with all the Vout I managed to try.
With my +7V external source, the Arduino is supplied by the internal regulator and I don't see this issue any more. This could be related to II.2 or merely an independent problem due to low voltage. Either way, the Bluetooth may be a good solution for this as well.
II.2. Ground levels
Assume you have a device with RS232 power by the B3603. You cannot do RS232 with this device and do RS232 with the control board at the same time.
You cannot communcate RS232 with the B3603 and the devices it powers at the same time. It does not work without isolation.The ground for the B3603 load is on the high side of the current sense resistor, but the control board ground is on the low side of the current sense resistor. If RS232 is connected to both the control board AND the load, the current sense resistor is effectively shorted.
So, I am thinking about getting a Bluetooth card for the control board's Arduino.
In truth, being reminded of the ground level issue again, I am not so committed with making my experimental/temporary Arduino Control board a permanent thing. Learning enough to have the Arduino-based control board working on breadboard may be enough for me.
My big thing is to enable logging. The issues with the UI are smaller issues to me. Now to do logging I will have to get a Bluetooth RS232 on that Arduino. Beside, I am not sure I want to assign my Adafruit ADS1115 to this job. The Adafruit ADS1115 itself is more expensive than the whole B3603!
I like +-1mV Vout adjustment, I like being able to modify voltage better than the slow/stock 4-button interface. But doing those things more than double the original cost of the B3603… I will get a Bluetooth to resolve the ground level issue just to benefit from the learning. After I solved all the known problems, I may end up stopping at a working breadboard control board instead of committing the whole thing to soldered. I will have a replacement B3603 installed soon and I may use that as is but now with much better understanding of what is going on under the hood.
Either way, I will get it working. I just am not sure I want to commit so many of my modules to this job permanently.