Author Topic: B3603 DC/DC Buck Converter mini review and how the SET key could be fatal...  (Read 162873 times)

0 Members and 1 Guest are viewing this topic.

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
One thing to note is that different point pairs will generate a different linear function and some may have more errors than others. The right way to solve this is to use more than two pairs, probably at least five and probably the optimal number is 10 pairs and use a least squares estimate and find the best match with the least error for all collected points.

The problem with this is would be that it is time consuming and takes quite a bit of effort, both from the operator and the code. I will easily get into overflows and may even trigger watchdogs. I think I'll leave that to the user to perform so I will support the two point calibration for those who don't mind the accuracy too much and if someone wants full accuracy I'll provide an external script that will take all the different measurements and do the right thing and feed the final answer to the device.

In fact, it should be possible to write yet another script that will communicate with the B3603 alternative firmware and with a serial-capable multimeter and perform the calibration completely automatically. It can even measure it at the full range and with all data points to get the lowest possible error.

You are describing exactly what "my gut feel" is.  It needs more than 2 points.  I will do a more detail analysis with your data.  I am guessing (we will see after an analysis).  My gut feel is, at the low end, I probably need more points.  I am bias already (from having worked on a 4-channel ATMEGA volt logger) I am thinking 8 data points with these separation:
- 4 lines for bottom 1/4 of ADC 0, 1/16, 2/16, 3/16, and 4/16
- 2 lines for 1/4 to 1/2 of ADC   4/16, 6/16, and 8/16
- 1 line for the top half of ADC   8/16 to 16/16
8 data points total (data points at 1/4 and 1/2 are used twice)

If math is faster, I would borrow from the o'scope's well tested formula of sin(x)/x.  I will be testing that out for speed first.  I also suspect another good way is to estimate the slope for adc=x as:
slope_at_x = n+(m/x)    [where n and m are constants, x would be the ADC count]
Some one who do ADC design work would probably know off the the back of his head, but I will have to test that experimentally by doing some analysis with the data.

As to actual calibration, it should be something that is done rarely.  So I would trade troublesome for accuracy any day.
 

Offline baruch

  • Regular Contributor
  • *
  • Posts: 78
  • Country: il
We are not talking about the same thing.

You are talking about splitting the range into several regions and let each one use a different function. I show in that attached graph that a single function is very close approximate to the entire range.

My point about the multiple points is intended to help find that one perfect line that is closest to all points at once.

EDIT: I seem to have misread initially your comment. It does talk about different points on the line. I somehow misread it to be like the ADC you wrote about previously where you used different functions to different regions.
« Last Edit: March 07, 2015, 08:05:59 pm by baruch »
 

Offline baruch

  • Regular Contributor
  • *
  • Posts: 78
  • Country: il
I've just run an experiment where I've taken the full data, calculated the optimal a&b values from it with LSE and then chose 20 times a set of 10 points out of that data (600 points) and calculated the LSE result for each, the results are pretty good so 10 points would be plenty enough for a good accuracy. You can spread them evenly around or not the main point of elimination of the noise out of the equation you will already get.

Ofcourse, the more points you take the lower the error, but unless you have it all automated having more than 10 points is going to be very cumbersome and gain you only at most a 10mV improvement.
 

Offline Asim

  • Regular Contributor
  • *
  • Posts: 171
I wasn't planning to post my progress, but I thought let's revive the post (wouldn't hurt).

The main reason why I want to make another top board is to replace the user interface that I am not liking. So I decided to tackle the project from a different angle. that is figuring the user interface then concentrate on the ADC,DAC and calibration ( the angle that Rick Law & baruch tackling).

My user interface contains:
1) 128x64 OLED display (SPI)
2) ONE rotary encoder with a built in push button
3) Push button for Power on/off

currently I have a smaller OLED display so I am squeezing everything as seen in the picture, this to be solved with the bigger display.
The  ONE rotary encoder is used to control the set voltage and current, if the built in push button is pressed for 1 SECOND( meaning long press)  it will switch to control the other parameter( voltage or current). if the push button is pressed for a short period( short press) this will control the multiplier used to increment/decrement the set parameter.
 10^-3 V  in the picture means each movement of the encoder will increment/ decrement the set voltage by 0.001 V.
if 10^-1 A is showing, this means each movement of the encoder will increment/ decrement the set current by 0.1 A.   

so this number is showing me two things:1. what am I controlling.
2. each movement of the encoder = to what increment/decrement  (1,0.1,0.01,0.001)

The system will have a push button for switching the output on/off, and I found the perfect push button for this job( shown below)
it has a built in LED, so when the output is on the led will be on and vice versa. So the button will serve as an indicator too!. 
 
The % shown in the top right corner tells you the charge% ( as I said in another post. this is to be a portable power supply).

There are still more things to figure out, I tackled the user interface because it motivates me + I am waiting for the ADC+DAC to arrive :-DD

as always,open for suggestions  ^-^

---------

any news from the other guys?
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
Is your OLED dot addressable?  Does it use RAM for the display buffer?

I am stalled by two things I want to figure out:

1. I am using the Nokia 5110 type display.  Uses RAM for display buffer and SPI.  SPI is what I want but the RAM buffer is squeezing my RAM needs.

2. Physical config - I want to use the Nano (at least for now), and the Adafruit ADS1115 (16 bit ADC).  But I just can't get that
    onto a single top board.  I am going to have too much overhang making air flow even worst.

So, I am playing with that.  I have a first try which I am (will be) soldering up shortly.

By the way, I decided to use push button only - I tried just adjusting numbers with four tac buttons: Use the OK and SET to double-duty as FAST and SLOW.   When I holding the UP or DOWN, it auto repeats at 1sec interval.  Each FAST/SLOW pressed while UP/DOWN are held will double or 1/2  the speed.  I found that to work rather well.  This allows me to skip the encoder for physical space reason.

 

Offline Asim

  • Regular Contributor
  • *
  • Posts: 171
Is your OLED dot addressable?  Does it use RAM for the display buffer?

I am stalled by two things I want to figure out:

1. I am using the Nokia 5110 type display.  Uses RAM for display buffer and SPI.  SPI is what I want but the RAM buffer is squeezing my RAM needs.

2. Physical config - I want to use the Nano (at least for now), and the Adafruit ADS1115 (16 bit ADC).  But I just can't get that
    onto a single top board.  I am going to have too much overhang making air flow even worst.

So, I am playing with that.  I have a first try which I am (will be) soldering up shortly.

By the way, I decided to use push button only - I tried just adjusting numbers with four tac buttons: Use the OK and SET to double-duty as FAST and SLOW.   When I holding the UP or DOWN, it auto repeats at 1sec interval.  Each FAST/SLOW pressed while UP/DOWN are held will double or 1/2  the speed.  I found that to work rather well.  This allows me to skip the encoder for physical space reason.

it does,,  http://www.adafruit.com/product/326.
Arduino pro mini would be my solution for the space. it is a NANO-FTDI. The rotary encoder will hang on 90 degrees from the top board. so it doesn't take space and won't block the OLED view. The encoder is a must for me, it caused me a lot of problems but all are solved now. + in a single movement I can increment 0.001 V or 1 V(faster & less hastle).

BTW, are you using a library for the nokia display? if yes, some libraries are faster/takes less space than the others.
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
Is your OLED dot addressable?  Does it use RAM for the display buffer?

I am stalled by two things I want to figure out:

1. I am using the Nokia 5110 type display.  Uses RAM for display buffer and SPI.  SPI is what I want but the RAM buffer is squeezing my RAM needs.

2. Physical config - I want to use the Nano (at least for now), and the Adafruit ADS1115 (16 bit ADC).  But I just can't get that
    onto a single top board.  I am going to have too much overhang making air flow even worst.

So, I am playing with that.  I have a first try which I am (will be) soldering up shortly.

By the way, I decided to use push button only - I tried just adjusting numbers with four tac buttons: Use the OK and SET to double-duty as FAST and SLOW.   When I holding the UP or DOWN, it auto repeats at 1sec interval.  Each FAST/SLOW pressed while UP/DOWN are held will double or 1/2  the speed.  I found that to work rather well.  This allows me to skip the encoder for physical space reason.

it does,,  http://www.adafruit.com/product/326.
Arduino pro mini would be my solution for the space. it is a NANO-FTDI. The rotary encoder will hang on 90 degrees from the top board. so it doesn't take space and won't block the OLED view. The encoder is a must for me, it caused me a lot of problems but all are solved now. + in a single movement I can increment 0.001 V or 1 V(faster & less hastle).

BTW, are you using a library for the nokia display? if yes, some libraries are faster/takes less space than the others.

Yeah, I am using a modified version of the GFX library.  The modification was for me to support those little tools I have which allows me to do quick tests like "an integer input" utility which I am using for testing.

I am running out of RAM now.  I expect to need to strip down as much as I can just to fit into the 32K flash.

Once my prototype works well, I may turn the 2x8 pins upside down, so the bottom-board will have pins sticking downward to plugs into a bottom-bottom board with my stuff.
 

Offline Asim

  • Regular Contributor
  • *
  • Posts: 171
I see, I have a question though, is using the display(SPI) + ADC(I2C) causing any speed issues?
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
I see, I have a question though, is using the display(SPI) + ADC(I2C) causing any speed issues?

Since I the replacement of the 20x4 I2C-LCD by the 5110 on SPI, the oscillation noise of +-6mV is removed.  That extra +6mV at peak and -6mV valley is gone even with the I2C-ADC running.

The I2C-ADC could still be generating some noise.  If it is, it was buried in with the base noise and not enough to create an extra peak/valley.  This base noise is Amperage-dependent and seem higher than I recall.  I have a new B3603 coming.  At that point, I can check if when the LED died, did any thing else went wrong.


Classic example of not reading carefully - I answered about noise instead of about speed which is what you asked.

Depends on what you consider a speed issue.  The speed of the 5110 display on SPI or bit-bang beats out the LCD2004 on I2C.  Recalling from prior detail tests, the update speed for 4 lines of text is around 30ms for SPI and about 38ms for bit-bang whereas the I2C LCD2004 was in the 40-50ms range.  So the SPI 5110 is a speed improvement for sure.

I am not too happy with the speed of the I2C ADC1115 however.  It is not unexpected as I have been using this ADC for a while and know it is slower than I like.  I use the ADC in 1 shot mode expecting to implement auto-range for the PGA.  It takes about 10ms per ADC read on average.  So 4 channel all active will take about 40ms to finish reading all four.   Since the actual time would depend on the voltage being read, my numbers are all low numbers (counts to about 300 - 2000 of 32767 counts), so I can expect it to be much slower still.

« Last Edit: March 14, 2015, 12:53:28 am by Rick Law »
 

Offline cnc4less

  • Newbie
  • Posts: 3
 Thank you Baruch for the great spirit you have to go through such project and share your ideas,  also Asim,  very interesting efforts i see here, will u share your arduino code with us?
regards
salim
 
« Last Edit: March 18, 2015, 07:17:06 am by cnc4less »
 

Offline baruch

  • Regular Contributor
  • *
  • Posts: 78
  • Country: il
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. For now I implemented the Vout ADC and PWM control and it works very nicely. The Cout controls should follow once I get some 0.1R resistors to be able to generate meaningful load currents. Right now I only have a few 100R and the currents I can sustain with them are too low to make a meaningful calibration.

The calibration is within 0.01 volt of the requested voltage and I guess I could get better if I added a few more decimal points to the calculation. I'll try that later on. The accuracy is better in the higher voltages (>4.5) and is not so great (within 0.02v) below that.

I was planning to add more features to the firmware but I really have to get back to another project I'm doing with a friend so I won't spend so much time on this anymore as the unit now does exactly what I want from it, i.e.: a serially controller psu.

Ofcourse, if someone is up to adding features I'll take patches and merge requests happily and will continue to frequent this forum post.
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
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 issues

II. 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.
 

Offline baruch

  • Regular Contributor
  • *
  • Posts: 78
  • Country: il
I tested now the output with and without USB-serial and I get the same value. I use a CP2102 dongle and only connect the Tx/Rx/Gnd lines from it to the B3603 and it works and the output is the same either way.

I can't really understand your comment about two different devices connected with serial, there is a shared ground to them all but current from the B3603 doesn't flow directly on the Rx/Tx/Gnd lines of the serial, this is controlled by the MCU of the board that terminates the serial on its side. I haven't yet tried anything like that but will probably test it soon as I plan to use the PSU to power my other projects.

I'm only geting 10mV accuracy and I don't need more than that, my multimeter can't measure better than that anyway so I wouldn't be able to calibrate it better.
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
I tested now the output with and without USB-serial and I get the same value. I use a CP2102 dongle and only connect the Tx/Rx/Gnd lines from it to the B3603 and it works and the output is the same either way.

I can't really understand your comment about two different devices connected with serial, there is a shared ground to them all but current from the B3603 doesn't flow directly on the Rx/Tx/Gnd lines of the serial, this is controlled by the MCU of the board that terminates the serial on its side. I haven't yet tried anything like that but will probably test it soon as I plan to use the PSU to power my other projects.

I'm only geting 10mV accuracy and I don't need more than that, my multimeter can't measure better than that anyway so I wouldn't be able to calibrate it better.

This is what I figured out, I am not absolutely positive but I am fairly sure I am right.

Regarding RS232 on both the controller and the load at the same time:

The current sense resistor is R050, so I will use R050 to make this more readable.

The B3603 load's ground is connected to the R050 top (higher voltage) end.  The bottom end of R050 is connected to the controller's ground.  If the load is 1Amp and R050 is 0.05ohm, the top end should be +50mV over the bottom end.  So the load's ground differs from the controller's ground by 50mV.

The LM2596 actually seats a little lower than the controller's ground due to resistance of the PCB trace, the Vin Gound connector is the lowest point on the whole board.

If you have USB/RS232 (say COM1) connected to the controller
  - COM1 ground is the ground of the controller ground which is the bottom end of R050.
If you have USB/RS232 (say COM2) connected to the B3603 load
 - COM2 ground is ground of the B3603 load ground which is the top end of R050.

At the PC end, COM1 ground and COM2 ground are connected.  So the TOP end of R050 connects to the BOTTOM end of R050 via the common ground between COM1 and COM2.  This creates a short across R050 which renders the current measurement useless.  The change in the ground level also renders other voltage measurement by the ADC inaccurate and the PWM level (from a changed ground) also changed.

This issue affects me even with 2 machines connected via KVM.  The KVM creates a common ground between the machines.

Regarding with/without USB calibration issue:

That is because of the Arduino is running below 5V from the 4.92V that the XL1509 gives.  The STM runs at 3.3V is not affected by that.

With the ATMega at 4.8/4.9V-ish, when the USB is connected, the USB's D+ from the PC some how caused a very small increased the ATMega's PWM's voltage (or decreased rise time).  The resulting increase in the integrated output of the PWM is used as V-out-set.  This small increase in V-out-set changed Vout by the 0.02V increase I saw in Vout.  The external 7V power for the Arduino solves that problem.  But I don't like having to provide another power source to the B3603.  I will have to work on an alternate solution.

For the Arduino, the faster PWM (even at 14 bit) is very touchy.  With fast PWM and low duty cycle (say below 1%), the pulse is so short that it has problem reaching the top (5V).  At very low duty cycle, I saw with the scope some random cycles of the "square wave" not rising fast enough to reach the top of the square before it is time to fall again.  So this changing rise time is distorting the square wave.  I had to come up with a solution to stabalize the resulting 100mV+ jitter due to this.  My solution is to use a zenor to lop the 5V square wave at 3.3V.  It has a much easier time reaching 3.3V reducing the distortion of the square wave.  With this solution, I managed +-2mV jitter with Vout.  This works up to 15 bit PWM.  At 16bit PWM, the pulse (even with moderate duty cycle like 5% or 10%) is so short any small change in rise time distorts the wave too much to create a stable voltage.  The jitter I see at 16 bit PWM even with the zenor exceeds >100mV at Vout.  There is no point in +- 0.5mV adjustment if it introduces an instability of >100mV.  That is why I don't even want to waste time with 16 bit when 15 bit is already giving me fine enough control (and it stable to +-2mV from the DMM's view which is way more than the noise the scope is showing).  Frankly, I think +-1mV adjustment is finer than the B3603 can hold anyhow.
« Last Edit: March 19, 2015, 06:58:19 am by Rick Law »
 

Offline Asim

  • Regular Contributor
  • *
  • Posts: 171
@ Rick, you can get the input voltage of the device ( the terminal input voltage ) to the top board. This will eleminate the need of another external supply. If you check pin 3 of the top module, this pin is connected to Vin through a voltage divider. So desoldering the divider resistors and removing them, and short the top resistor smd pads. Will give you your input voltage through pin3. Do whatever you like with that voltage( create a stable 5v).
 

Offline Asim

  • Regular Contributor
  • *
  • Posts: 171
@ Salim, thank you. My code in no way, shape or form is ready. It is only a user interface. I don't mind posting the code, but it is ugly.( work in progress)
 

Offline baruch

  • Regular Contributor
  • *
  • Posts: 78
  • Country: il
@Rick, I think that you can use a CP2102 or FT232 and connect it to the hardware serial pins instead of the direct USB connection and then you will skip on the added voltage input and just have the communication path. This should avoid your extra power supply need as you won't mix two power supplies (B3603 and PC-via-USB).

I currently have only one CP2102 and will order soon a few more so I can test the issue of the multiple serial connected devices. I guess that the effect will be mostly on the ADC but I'll be mindful of that when I try it. If it becomes a real issue I'll also take a look at radio.

My other projects use the nRF24LE1 so I could use that as my radio control, I have a few spares there.
 

Offline Asim

  • Regular Contributor
  • *
  • Posts: 171
@ Rick, you can get the input voltage of the device ( the terminal input voltage ) to the top board. This will eleminate the need of another external supply. If you check pin 3 of the top module, this pin is connected to Vin through a voltage divider. So desoldering the divider resistors and removing them, and short the top resistor smd pads. Will give you your input voltage through pin3. Do whatever you like with that voltage( create a stable 5v).

I just came back home, the voltage divider resistors are R2&R1, desolder both and short R2 pads, this will provide you with Vin at pin 3 . You can reuse the voltage divider at the top board if you care about the input voltage
 

Offline cnc4less

  • Newbie
  • Posts: 3
@Asim  i understand it is not finished code as Baruch ( he is just great , very kind  and helped me  alot)  but am making a hopy project that needs some of your  arduino code in it at least the c++ code for the volt in out and I in out calculations. the rest I can wrap it up and might help closed this code for you in a week or so. regards
salim
« Last Edit: March 19, 2015, 03:50:06 pm by cnc4less »
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
@ Rick, you can get the input voltage of the device ( the terminal input voltage ) to the top board. This will eleminate the need of another external supply. If you check pin 3 of the top module, this pin is connected to Vin through a voltage divider. So desoldering the divider resistors and removing them, and short the top resistor smd pads. Will give you your input voltage through pin3. Do whatever you like with that voltage( create a stable 5v).

I just came back home, the voltage divider resistors are R2&R1, desolder both and short R2 pads, this will provide you with Vin at pin 3 . You can reuse the voltage divider at the top board if you care about the input voltage

Hey, thanks for pointing that out!  I will keep that in mind.

I just got my Bluetooth module.  Not initially intended for this project so it is an HC5 instead of an HC6.  HC5 should work as client also, so I am going to try that.  BT should allows me to use Serial on the control board AND a Serial on the B3603-powered device.  If that works, I am in good shape with the (less than) +5V from pin13/pin14.  If not, I will have to figure out what I use to power the Arduino based control board.

So far, I found this to be possible with my limited skill.  I am sure others with more experience can do better:
- Improve resolution in volt setting (yeah, I can go to 15bit PMW)
- Improve display V/I resolution
- Display Vout, Iout, Vset, Iset simultaneously  (Nokia displays Vout/Iout in size 2 and Vset/Iset in size 1)
- Calibrate better with given higher resolution
- Faster/Fast/Meduim/Slow/Slower in the auto-increment of V/I setting
- logging (right now, isolated laptop if a load powered by the B3603 is grounded to external such as my PC ground)

So far, I know this should be possible but I have not actually try
- Do both on the same PC: serial at the control board and a Serial on a device powered by the B3603
  (bluetooth is my target solution right now.  Controller's onboard USB will be for program loading only.  BT allows me to isolate the control board's ground with the load's ground)
- Single power source.  Bluetooth may just make it OK to let the Arduino run with 4.9V.  If not, I know how to get a 7V source to the board some how.
- Oversample to get about 13 or 14 bit ADC with the onboard ADC (to free the ADS1115 16 bit adc)
- Auto calibration

So far, I have these concerns and like-to-do's, but will deal with them later
- The noise is heavier right now than the stock controller.  I suspect it is because my controller is on breadboard so things are too spread out and poor layout.  I like to see if I can get the noise to be closer to stock controller by moving this to a soldered prototype board.
- I like to have the Arduino auto-compensate for load regulation.  At high load, I see the Vout dropped.  With the Arduino, can I compensate for this.
- What other enhancement is feasible?  I have to experiment more.

This has been fun and educational at the same time.
 

Offline baruch

  • Regular Contributor
  • *
  • Posts: 78
  • Country: il
I changed my code to use a higher precision fixed point for the constants and calculations, now I use a 32bit fixed point fraction with 16 bits for the whole part and 16 bits for the fraction, up from 3.13. This gets the accuracy of the millivolt measurement in the 0.01mV range and the output is very stable as well.

I've ordered 0.1R resistors and a 10W led so I can play with the current limit control, it will take a month or so for the parts to arrive. For now I don't have the ability to sink 1A to be able to get any reasonable calibration. I can barely sink 100mA.

I started generating releases for the software and the latest one is 1.0.1 with the increased accuracy. I also switched from NumPy for the LSE calibration to a more specific implementation for the single variable optimization I need here so there are less dependencies. LSE is Least Squares Estimate and is used to set the linear formula parameters for the PWM and ADC, it gets the best parameters possible that give the least amount of error across the entire range.

A sample output of my calibration script:
Code: [Select]
OPEN "MODEL: B3603"
PSU Input voltage is 8.77, will use 20 steps between 1.0 and 7.77
Setting voltage to 1.0
Multimeter samples vary too much, stddev=0.527693, data: [4.23, 3.44, 2.949]
Failed to read stable value, trying again, maybe
Multimeter samples vary too much, stddev=0.237628, data: [1.783, 1.462, 1.202]
Failed to read stable value, trying again, maybe
Step 0 Set voltage 1.000000 Read voltage 0.996333 PWM 278.0 ADC 279.0 (1.0)
Setting voltage to 1.33
Step 1 Set voltage 1.330000 Read voltage 1.328000 PWM 337.0 ADC 337.0 (1.32)
Setting voltage to 1.66
Step 2 Set voltage 1.660000 Read voltage 1.659000 PWM 396.0 ADC 396.0 (1.66)
Setting voltage to 1.99
Step 3 Set voltage 1.990000 Read voltage 1.990667 PWM 455.0 ADC 455.0 (1.99)
Setting voltage to 2.32
Step 4 Set voltage 2.320000 Read voltage 2.316000 PWM 513.0 ADC 513.0 (2.32)
Setting voltage to 2.65
Step 5 Set voltage 2.650000 Read voltage 2.647333 PWM 572.0 ADC 570.0 (2.64)
Setting voltage to 2.98
Step 6 Set voltage 2.980000 Read voltage 2.979000 PWM 631.0 ADC 629.0 (2.98)
Setting voltage to 3.31
Step 7 Set voltage 3.310000 Read voltage 3.310000 PWM 690.0 ADC 688.0 (3.31)
Setting voltage to 3.64
Step 8 Set voltage 3.640000 Read voltage 3.636000 PWM 748.0 ADC 745.0 (3.63)
Setting voltage to 3.97
Step 9 Set voltage 3.970000 Read voltage 3.967000 PWM 807.0 ADC 802.0 (3.96)
Setting voltage to 4.3
Step 10 Set voltage 4.300000 Read voltage 4.300000 PWM 866.0 ADC 863.0 (4.3)
Setting voltage to 4.63
Step 11 Set voltage 4.630000 Read voltage 4.630000 PWM 925.0 ADC 920.0 (4.62)
Setting voltage to 4.96
Step 12 Set voltage 4.960000 Read voltage 4.960000 PWM 983.0 ADC 978.0 (4.95)
Setting voltage to 5.29
Step 13 Set voltage 5.290000 Read voltage 5.290000 PWM 1042.0 ADC 1036.0 (5.28)
Setting voltage to 5.62
Step 14 Set voltage 5.620000 Read voltage 5.620000 PWM 1101.0 ADC 1096.0 (5.62)
Setting voltage to 5.95
Step 15 Set voltage 5.950000 Read voltage 5.950000 PWM 1160.0 ADC 1154.0 (5.95)
Setting voltage to 6.28
Step 16 Set voltage 6.280000 Read voltage 6.280000 PWM 1218.0 ADC 1210.0 (6.26)
Setting voltage to 6.61
Step 17 Set voltage 6.610000 Read voltage 6.610000 PWM 1277.0 ADC 1270.0 (6.6)
Setting voltage to 6.94
Step 18 Set voltage 6.940000 Read voltage 6.940000 PWM 1336.0 ADC 1329.0 (6.94)
Setting voltage to 7.27
Step 19 Set voltage 7.270000 Read voltage 7.270000 PWM 1395.0 ADC 1386.0 (7.26)
['OUTPUT: OFF', '']
ADC
(5.666595409010677, -585.2406566240919) 371365 38354331
['CALIBRATION SET ADC VOUT A', '']
['CALIBRATION SET ADC VOUT B', '']

PWM
(0.17797037089326911, 100.78828376431484) 11663 6605260
['CALIBRATION SET PWM VOUT A', '']
['CALIBRATION SET PWM VOUT B', '']

The interesting part is at each step to see what was the set voltage (voltage we want out), the read voltage is what the multimeter shows (MASTECH MS8250B) and in the brackets is the ADC calculation which the unit will show as its measured output.
 

Offline baruch

  • Regular Contributor
  • *
  • Posts: 78
  • Country: il
I'm wondering, is there anyone else that plans to flash his unit? (i.e. not just hook another mcu instead of the current top-board). I'd be interested to know about the calibration results and also if someone would try the same firmware on another board with the same top-board.
 

Offline cnc4less

  • Newbie
  • Posts: 3
@baruch yes i am working on it now and will hook it  on  arduino and energia, , my application is not power  power supply but integrating PID with it so i can have it working in different way, i need few weeks and will list my code. also will hook the USB meter too as u see it in http://www.ebay.com/itm/OLED-USB-Charger-Current-Voltage-Capacity-Power-Detector-Tester-Meter-Voltmeter-/261670045269?pt=LH_DefaultDomain_0&hash=item3cecc00655

Thank you again you have excelled in your work.
Salim Safran
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
Your B3603 could be giving out more noise than it should...

The XL1509 supplies 5V (4.92V) to the bottom board and the control board.  This 5V supply could damaged and cause the noise.  If you shorted this even for a very brief time, your unit appears to be working but it will generate a lot more noise and may eventually fail.

I shorted it by mistake for a very brief time, (could happen any number of ways - mine was a screw driver blade rolled under the bottom board shorting pin12 and pin13 where the top board gets its 5V).

Something smoked, the unit appears to survive it.  Prior to this mishap, I was working on my Arduino based control board.  I was getting +-1mV Vout adjustments with +-2mV Vout stability (DMM reading Vout with slow +-2mV jitter).  Scope shows <100mV high frequency noise but DMM/ADS1115 reading were solid.  Rare to see more than +-3mV jitter except purposely changing the load rapidly.

After the mishap, while it appear to have survived, I notice it was not holding voltage stability like before - now DMM is showing +- 200mV Vout jitter.  The scope was showing Vout noise a lot higher than I recall.
I put a scope to the 5V, this is what I see - frequent ~1V spike on top of the 5V.
144183-0

I tested my original B3603 (with dead LED).  It has much worst Vout stability.  I know I shorted its 5V once also and thought it survived.  The 5V has frequent 2-3V spikes on it.  This may be the cause of the dead-LED.  The 74HC595 electrical max is 7V, a 5V with over 2V spike is over the 7V limit.  I will order a couple of 74HC595 to see if I can revive the dead LED.



To confirm the 5V was the problem, I removed the XL1509, and supplying 5V via another LM2596 - With that, I am back to +-2mV stability, and Vout noise return to what I recall (100mV range) verses at times over 800mV with the bad XL1509 circuit.

So, both my B3603 has damaged 5V circuit.  One spikes at just below 1V and the other spikes at 2-3V.  Looking at that part of the circuit, when 5V is shorted, the only thing that could go are the XL1509 and the 100uH inductor.  I have both parts coming.  I will see if I can repair them.  The smoke could be from the 100uH inductor with the wire turning into heater coil.  Since the XL1509  is already removed and ready to receive a new chip, I would prefer that being the problem than the 100uH.  But the XL1509 may not be the fault as it is suppose to auto-cutoff at 2A.  So, we will see.

So, if you seem to have a bad noise problem - or a dead LED, put a scope to the 5V, see if that is your problem also.

Keep you guys posted if I can successfully repair the two units with bad 5V, and let you know if it is the inductor or the XL1509.

Rick
« Last Edit: March 29, 2015, 05:23:32 am by Rick Law »
 

Offline Rick LawTopic starter

  • Super Contributor
  • ***
  • Posts: 3423
  • Country: us
Your B3603 could be giving out more noise than it should...

The XL1509 supplies 5V (4.92V) to the bottom board and the control board.  This 5V supply could damaged and cause the noise.  If you shorted this even for a very brief time, your unit appears to be working but it will generate a lot more noise and may eventually fail.

I shorted it by mistake for a very brief time, (could happen any number of ways - mine was a screw driver blade rolled under the bottom board shorting pin12 and pin13 where the top board gets its 5V).
...
...
Keep you guys posted if I can successfully repair the two units with bad 5V, and let you know if it is the inductor or the XL1509.

Rick

It is the inductor.  The xl1509 I removed from unit1 was lost, so I have to wait for the XL1509 before I can do experimentation - I got the parts today.

The new XL1509 on Unit 1 did nothing - the spikes were as it was before I removed the XL1509 (and lost it).

I only have a 200uH though-hole at hand, and the inductor shipment is way overdue.  Replacing the inductor with a though-hole 200uH I have at hand, both unit1 and unit2 came back to life.  Unit 1 was spiking to over 7V and unit 2 was spiking to around 6V.    Unit 2 had a screw driver slid under it and shorted the 5V.  I noticed it immediately so the time for additional damage was minimal.

With the new inductor, Unit 2's performance matches that of before damage - as compared using scope captures I had for noise-display for various Volt and Current setting.

Unit 1's performance is 20-30% better than before but still worst than unit 2 - which leads me to conclude unit 1 must have been damaged already when I took the original scope displays used to start this thread.   It was not until the LED on unit1 died that I begun hunting the issue.

Unit 1 has 1/3 more noise than unit 2 for the same settings.  I must have ran unit1 with the 7V+ spikes for a while, so I think it was more than the LED that suffered.  The MCP opAmps are rate to 6V only.  I think they might have been damaged as well.  Even with the "better performance, it is about 1/3 more noise than unit2.  Where unit2 has 60mV noise, unit 1 would have 80mV-85mV noise.

So, once I get the SMD inductors (100uH), I can repair them properly.  For now, I can use them with an though-hole inductor sticking up/out.  Unit 1 with more noise will be used for less demanding things (like feeding my TP4056 USB charger).

By the way, Baruch, how is your program coming along?  I like to compare notes with you.  While I got the Arduino to control the volt/current well, it has more noise than the stock controller.  I also have big noise problem when serial is active....
« Last Edit: April 11, 2015, 12:42:04 am by Rick Law »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf