B3606 is a cheap MCU controlled power supply, I'm reverse engineering it and writing software to add serial port and more features.
I decided that the flash size is not sufficient to allow internal calibration logic and now resorted to external calibration with a script and a sigrok-enabled multimeter. This allows for very accurace Least Squares Estimation and gets the accuracy to be pretty much spot on.
I'm happy with the project as is even though I can see many improvements that are possible to it but for now it is sufficient for my needs and I have other projects to attend to so I don't think I'll work on it so much from now on.
I'll still appreciate comments and especially patches or merge requests if someone fancies to work on this further.
I figured a way to get the full 13 bit resolution of the PWM and now I get the full value range. I figured that my timer counter being 8192 is just a shift of 13 so I can avoid overflow by not shifting up 13 and down 10 but rather just do the entire calculation with an additional shift of 3.
The ADC on the face of it is a lost cause, it is only 10bit accuracy so I only get a change every 8 values of the PWM. I need to look at ADC averaging, I started to think about it and wonder if it's worth spending time to do it. I currently take a snapshot of the ADC and need to average it out anyway but originally wasn't planning to use fractions in that average.
I did some code size reductions and the code is now at 7860 bytes. It was at 8100 beforehand and got down to 7600 and then the new PWM accuracy took more space. I kinda like the serial text interface but not sure how long I can hold on to it in its current verbose state.
I've started to work on the calibration feature. It is shaping up nicely and improves somewhat the accuracy of the measurements but I'm still not getting to the level of accuracy that the original unit boasted (i.e. 0.01V and 0.001A).
The unit is however already usable as is, the alternative firmware can receive commands by serial and exhibit good control of the device that makes it possible to use it just fine.
The buttons still do not work and I don't do a great job with the display for now but these are features for interactive work and my main goal is the serial control anyway.
Today I worked on improving the code and adding small but important (to me) features.
The first is automatic and manual commit of settings. It is now possible to tell the device not to auto-commit and then be able to change both voltage and current in a single motion by setting the voltage, then the current and then commiting both into action.
A configuration of the device options is now done automatically so it will be easier to deploy the firmware. This is an option that is required to be able to PWM control the voltage and current and it took me a while to figure out how to program the flash.
The last feature of today is saving the configuration to flash for persistency. This is a small feature by itself but important to make calibration of the device worthwhile since otherwise it would be needed to calibrate it every time it is started.
Along the way I improved the code to make it more manageable.
Next up, calibration of the device.
I can now set the voltage and current through the serial and it actually sets the output to the right value (haven't validated current limit yet).
I needed to do proper calculation of the PWM values and for that there was a roadblock with integer overflows in the fixed point calculations. The initial setup for the current and voltage control was reversed.
I also had a roadblock where out of the two units I have both have some issue now with the top board, one doesn't display properly and the other can't control the output properly.
The fixed point parsing was incorrect due to an overflow, I had to set the variable to uin32_t to get it to work properly. I also needed to fix a rounding error that made the numbers off by just a little bit. Now it works very well.
Now I need to work on the PWM calculation it is way off and makes no sense right now. Once I have the PWM working I will have essentially a working power supply that is serially controlled.
I still don't know how to read the buttons in their weird setup. But that will wait a bit more. Once I get the PWM working I'll work on getting the display properly sorted to display the different values.
I got the 7-segment display to work today, it lights up nicely and I have the bit patterns for all 10 digits done. It took some play to figure out how exactly to drive it even with the schematics that were reverse engineered by flex.
To fit the code I needed to also get rid of the floating point so I worked to convert all such operations to fixed point arithmetic and it saved me some 3KB of space.
Still need to work on the output power parts, I have an problem driving the output enable pin properly. Still not sure what I'm doing wrong.
Board schematics for the B3606 top and bottom boards were done by user flex on the EEVblog forum. This should help immensely with figuring how to drive all the components.
I've already managed to drive the CV/CC leds, partially successful with the 7-segment display. Still unsuccessful with the output enable part and the buttons.
I did manage to get the PWM sorted but without the output enable it doesn't help.
I got the PWM code to start working, at least when viewed in a logic analyzer. When I tried to put the top board on the bottom board and see if it works nothing comes out. The output pin is toggled, the PWMs are running but no output comes from the device.
This may be also due to me wiring it once in reverse (the top board was upside down) so I may have destroyed it somehow. I'll try to debug this tomorrow with another unit that I have and see if and which part is damaged.
Solder a four pin female header to the connect at the bottom of the top board
Connect the STLink V2 device to the header
Use the windows STVP programmer, verify it is read-out-protected, if not, please save the flash and eeprom
[this comment has been deleted]