I'm somewhat fumbling on this topic but what would be the best way to control the PWM vs the voltage/current setting vs the output sense?
Should I do a feedback loop between the outputs and the pwm? Find some calibration and let it be?
@Rick Law or anyone else with an scope: Could you check the PWM frequency at pin 4 and 5? I don't have any scope nearby.1.293K Hz based on my Rigol DS1052E
@Rick Law or anyone else with an scope: Could you check the PWM frequency at pin 4 and 5? I don't have any scope nearby.QuoteIn an earlier post (where I purposed using header pin numebrs) I said no visible TxD/RxD connects HeaderPin 15 and 16 (Rx/Tx) to the MCU's Rx/Rx. I found the traces connecting them to UART1 RxD and TxD. I reedited that reply also to avoid confusion.They are also in my schematicQuoteSo, in so far as I can see, your schematic for the buttons is confirmed; AND they are indeed strange.thx for checking. This is an interesting design choice.
@flex, in the schematics the formula seems to involve a mA value and what seems to be fractions of a volt. Am I reading it right?
For example the Iout says: Iout_sense = 16 * (10mV + 0.05 * Iout),
The code translation for me would be: Iout_sense = 160 + 0.05 * Iout
I hope I'm not mixing up units...
I built some code to drive the 7-segment display and hit again the 8K limit, the floating point code I currently use takes about 4KB of that so I'm now reeducating myself on fixed point arithmetic and converting the code from float to fixed point. I'm also incorporating already the defaults as you calculated, we'll add actual calibration as well so the parameters above (16, 10) are values that can be changed online.
@Rick Law that sounds interesting. The position of the shunt is too bad. Otherwise we could try to put something like the MP915-0.050-1% as shunt.
(@Flex, what is extra D stands for in the "other ground" GNDD vs GND)
I also didn't manage to control the on/off led button and as such can't really enable/disable the output properly.
I also didn't manage to control the on/off led button and as such can't really enable/disable the output properly.In theory, all you have to do to enable the on/off led and the regulator is to set PB4 to output GND.
@Rick Law or anyone else with an scope: Could you check the PWM frequency at pin 4 and 5? I don't have any scope nearby.
1.293K Hz based on my Rigol DS1052E
I have been wanting to replace the interface on that module. with the pinout mapping provided I think I can do it.
my Ideal interface would include OLED display to display Vset,Iset,Vout,Iout. one rotary encoder with built in switch to vary the set voltage and current ( switch to change from voltage to current and vice versa) . one push button to switch the output on & off. 2 leds for CC & output ON.
EDIT: I have two units, one supposedly damaged in parts but where OE is 5V and one supposedly good where OE is always at 0V. I'll try the new firmware on the old and supposedly damaged unit and see what happens, this will happen tomorrow. The damaged unit had been injected 17V to the top board and then once plugged in reverse. the 7-segment display doesn't seem to work properly and there was some problem with output regulation after it was plugged in reverse.
the frequency doesn't matter that much as far as I know as it will be filtered to an average voltage that will control the Iset & Vset.
tmp *= 73<<10
since sizeof(int)=16, this will overflow. Try this instead:tmp *= 74752;//73<<10;
The same fortmp += (33<<10)/1000;
it also overflows 16 bit signed int. Instead use:tmp += 34;//(33<<10)/1000;
Fix integer overflow issues
The default type is uint16_t and some of the fixed numbers were
overflowing that, giving the explicit number makes the compiler use a
larger integer type and corrects the calculation.