Open demianbadin opened 5 years ago
Hi @demianbadin, First, congratulations on your progress!
Any Ideas?
if you look at the original BC6 charger schematics (I assume your charger is very similar): http://www.rcgroups.com/forums/showatt.php?s=df7049bcbafdb5d7d06765c264e5c4bb&attachmentid=3693125&d=1293732709
The first 2 balance port inputs are connected directly (without an opamp) to the multiplexer (4051) through R75-R76-R78-C23, R60-R61+R62+R63-R79-C25, R71-R72+R73+R74-R80-C22, and to the ADC pin trough R103-C33. The R60,R72+R73+R74 resistances are relatively high compared to C33, since we are switching between the inputs quit fast the C33 has not enough time to discharge trough R72+R73+R74 for balance port B2. You also seems to have a similar issue on BAL3, maybe your charger is missing an opamp on BAL3?
Cheali-charger deals with this problem by discharging the C33 capacitor manually, see: https://github.com/stawel/cheali-charger/blob/master/src/hardware/nuvoton-M0517/generic/50W/AnalogInputsADC.cpp#L39 and: https://github.com/stawel/cheali-charger/blob/master/src/hardware/nuvoton-M0517/generic/50W/AnalogInputsADC.cpp#L134-L158
what we do:
I assume your charger has higher resistor and/or capacitor values mentioned above.
so:
Hope this helps, Best regards
Hello @stawel ! Thank you for the response.
I've checked the balancer port circuit and it differs from imaxB6 standard. There are 6 OpAmp. (4 in the LM2902 + 2 in 2904) All 6 cell inputs comes from an OpAmp circuit. Attached is a (very ugly) drawing. There are no capacitors... The OpAmp outputs goes directly to the mux. Also I've tested to duplicate the discharge time with no result. Maybe because there is no C to discharge?
Best regards, Demian
Just for test, I've tried to disable the discharge function by changing these lines in AnalogInputsADC.cpp
void setMuxAddressAndDischarge(int8_t address) { if(address < 0) return; _setMuxAddress(address); }
With the same results. Eith 3 cell battery I get 1,569V at CELL 4 measure. Maybe is a real voltage at the analog input and can be just ignored. I must change the minimum valid cell voltage to the charger not recognise this cell as connected. I'll try 1,8V as minimum cell Voltage.
so your chargers balance port is similar to the turnigy 2x200: https://drive.google.com/file/d/0B1RXXTatsA1cb1R5NHM3MEtsakE/edit
This is actually a good thing (measurements should be more consistent), and You don't need the "discharge" part of my code (it should look like your code above),
Now I'm a little confused, your charger shouldn't have these issues. I'm also wandering why you have correct voltages when using AnalogInputsAnalyzer-50W, this helper uses exactly the same AnalogInputsADC.cpp code.
We probably need some more investigations:
#undef ENABLE_SIMPLIFIED_VB0_VB2_CIRCUIT
to HardwareConfig.h#ifdef ENABLE_SIMPLIFIED_VB0_VB2_CIRCUIT
#error "SIMPLIFIED_VB0_VB2 is still enabled"
#endif
I know, It's a lot of measurements, it shows how confused I am ;)
Maybe is a real voltage at the analog input and can be just ignored.
Your measurements should give us a clue, but I doubt those are real voltages.
Ok. This will take me some days. I'll prepare a 6S Lipo. (I only own 4S and 3S) Also I'll prepare a set of wires from charger to a universal pcb to easily change test points. Thank you for take the time to respond.
@stawel , CHARGER and HELPER showed the same values...
I only write down the values with Charger firmware.
Thanks for the measurements!
There are 3 things that worry me:
for 1: I assume You did the measurements with main battery wires disconnected? could you connect only the negative main battery wire (black) and check if the "BAL 0" voltage goes to 0V for 6 cell batteries?
for 3: could you measure the voltage on MUX output (4051 pin 3) and also voltage on CPUs ADC pin (not sure which pin this is, but should be connected to MUX output through a resistor. Do this two measurements without any battery connected, relative to GND and when the LCD shows 0.675V.
for 2: to be honest I don't have a clue, maybe supply voltage of the op-amps is wrong? could you measure voltages on pin 4 and pin 11 relative to GND? if you have access to an oscilloscope, check if voltages are flat. If you have a different power supply check if changes anything.
could you do a picture of your main board? (both sides if possible) also could you show me changes you've made to the cheali-charger code? (preferable in your repo)
for 1: I assume You did the measurements with main battery wires disconnected? R: yes
could you connect only the negative main battery wire (black) and check if the "BAL 0" voltage goes to 0V for 6 cell batteries? R: yes, "BAL 0" goes to 0V when Batt- is connected
for 3: could you measure the voltage on MUX output (4051 pin 3) and also voltage on CPUs ADC pin (not sure which pin this is, but should be connected to MUX output through a resistor. R: the OpAmp outputs are connected through resistors to MUX inputs.
Do this two measurements without any battery connected, relative to GND and when the LCD shows 0.675V. R: I've used Osciloscope to measure MUX output (picture 1), and then measured MUX inputs (picture 2) It's very strange what I get... I've noticed that this pulses are bigger on MUX side than in OpAmp side (separated by the resistors)
Pic 1
Pic 2
for 2: to be honest I don't have a clue, maybe supply voltage of the op-amps is wrong? could you measure voltages on pin 4 and pin 11 relative to GND? if you have access to an oscilloscope, check if voltages are flat. R: yes, pin 4 of LM2902 is Vin and is a clean power supply. Pin 11 is GND, flat 0V.
could you do a picture of your main board? (both sides if possible)
also could you show me changes you've made to the cheali-charger code? (preferable in your repo) R: ok... I'll upload to my repo soon.
I've just uploaded my files to repo. Compare
And... can confirm that charging is not working. But is another story. First I want to solve analog read issue.
Interesting, I had a teorii that you are doing something additional on ADC pin (m0517 pin 1) besides measuring but looking from your code I was probably wrong (the MUX (Multiplexer) is bidirectional, so everything on Mux output (pin 3) will affect its inputs)
so, I'm not sure what to do next, here are possible scenarios:
you could measure the voltages on red point's (see picture) relative to ground with your oscilloscope, with no batteries connected (I think fixing the ~0.65V with no batteries should be our priority) if voltage on MUX site is bigger then MUX is broken, otherwise it's something on the CPU site. but I'm not sure if the voltage difference will be significant enough, so you could also temporary remove the resistor.
If you have any other ideas, please let me know.
ps. What was the time division on your oscilloscope?
Hi, ok, I'll remove resistor and measure CPU and MUX points.
Here is a picture of a complete cycle with no battery on cheali:
And, as this charger is 4 in 1, and the rest of the chargers works "fine" as original, I've measured MUX output. The turnigy firmware samples BALANCE port every 1 second. And only during operation. In idle mode the Turnigy firm does not sample balance port values. 3 cell battery: 4 cell battery:
I'm not able to test the turnigy firmware with no battery, because it doesn't start to monitor balance port.
If you look at 3 and 4 cell, there is also a 680mV after last cell.
Also, I can flash another charger. The risk is mine... of course I trust this will work... =)
Also, I can flash another charger. The risk is mine... of course I trust this will work... =)
this can wait ;)
Ok, I've check what my LCD voltages are in my M0517 charger - (in "calibrate"->"voltage" menu, battery disconnected) result: 0.005V. With 3cell battery connected the voltage on cell 4 was 0.065V (a little bit higher but yours are 10x higher)
picture: 3 cell battery, MUX pin 3
interestingly I have only 9 voltage "changes" per full cycle (not taking into account the small discharge fazes) and your output has 17 (?), It looks like your piking up also the "interlaced" measurements (shouldn't be possible (??)). https://github.com/stawel/cheali-charger/blob/master/src/hardware/nuvoton-M0517/generic/50W/AnalogInputsADC.cpp#L94-L111
could you also connect a 3 cell battery (balance wire and negative main wire) and show me your oscilloscope output on MUX pin 3?
could you also measure the voltage on AVDD, AVSS pins on M0517 (pin 6, pin 42)
If you look at 3 and 4 cell, there is also a 680mV after last cell. hm.. interesting... but the 5 and 6'th cell is still 0V.
site note: your quartz is 12MHz (if I see it correctly) and the firmware assumes 16MHz (needs to by fixed in the future)
could you also connect a 3 cell battery (balance wire and negative main wire) and show me your oscilloscope output on MUX pin 3?
Picture: 3 cell & battery -
could you also measure the voltage on AVDD, AVSS pins on M0517 (pin 6, pin 42) Pin 6 = 0V Pin 42 = 2.487V
I've pulled out the resistor between MUX output and CPU AIn (1). And here is something interesting...
Picture 1 MUX side:
Picture 2 CPU AIn side:
hm... there is clearly a bump on each measurement, this is definitely a bug in the code (or M0517 is broken, but in my opinion this is very unlikely)
some paint "art", please ignore ;)
ok... I have another idea, maybe this code works (in my charger) because I'm using a different compiler then you are, I'm using an old gcc:
$ /usr/lib/ccache/arm-none-eabi-g++ --version
arm-none-eabi-g++ (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
could you try this firmware, and check if the bumps disappear (during 3cell battery measurement with resistor :) ) targets.tar.gz (I was not sure which target you are using, so I've compiled all of them) It's your master branch compiled with my compiler.
One more thing, tomorrow I'm going for 3 weeks to Korea and I wont have any computer with me, besides a tablet, so You will be on your own :/ , I can only support you with ideas :-)
Thank you for the support. Tomorrow I'll test your file. I'm using "cheali-charger-imax B6-50W-BOA6" target. Have a good trip! (Without computer?? = S)
I've tested your compiled file. Same result. I'ld like to disable parts of the program. For example, puting a return in outputPWM function, until find the source of this pulses. It's possible? Any suggestion?
I found a point inside AnalogsInputsADC.cpp where the analog input pin1 rises to 3V. Original lines: void setADC(uint8_t pin) { ADC_SET_INPUT_CHANNEL(ADC, 1 << IO::getADCChannel(pin)); }
If I break the execution like this: void setADC(uint8_t pin) { while(1) {} ADC_SET_INPUT_CHANNEL(ADC, 1 << IO::getADCChannel(pin)); } the result is Picture 1:
If I break the execution like this: void setADC(uint8_t pin) { ADC_SET_INPUT_CHANNEL(ADC, 1 << IO::getADCChannel(pin)); while(1) {} } the result is Picture 2:
So, after several tries, my conclusion is that I have no idea what appens. I've tested 2 analog inputs, with same initialization, and same code, just changing pinout in imaxB6-pins, and the two AIns have different results. AIN5 (pin1) has square pulses signal (outputs from charger) that seems to have relation with the execution of ADC_START. Picture 1
AIN7 (pin3) has a curved signal, like a charging / discharging capacitor. Picture 2
And the MUX output, disconected from CPU, is a razonable signal in relation to the cell inputs. Picture 3
I've flashed a second unit, same results. I've purchased a Nuvoton replacement to test, M0516LDN. Hope it comes ASAP. My head is burned out.
Picture 1 Picture 2 Picture 3
Hello. Hope there is some one can help with this issue. I've flashed Cheali on a TQ4 and inmediatly it get briked. I've followed the steps from this thread: https://github.com/stawel/cheali-charger/issues/207 (Talked with Ralim who help me in some steps)
And now I can get a partially working firmware. Tested:
If I connect a 1 cell batt in balancer port, I get 1.7V on BAL 2, even if I make a short on BAL 2 port. if I connect a 2 cell batt, I get 1,7V on BAL 3. Even if I make a short on BAL 3 port. The same for 4 cells.
So, I think the problem resides in the analog read method because the HELPER firmware works fine and the charger firmware doesn't.
I saw that HELPER firmware makes real time reads from ADC, but charger firmware makes Burst reads and average from analog inputs.
Any Idea?