- Written by Teemo
- Category: Electronic projects
Open source hardware universal balancing charger.
This project aims to create open source hardware platform for the ever popular cheali-charger software.
It is inspired by the fact that I managed to get one of those clone Imax B6 chargers and it was unfortunately one with the unmarked CPU and so uncompatible with the alternative cheali-charger firmware. Well the original firmware this was not sadisfactory for me also. In fact I was looking for it to cycle some NiMh packs for me, but it failed miserably to do so, I was lucky it did not burn down my house.
But the enclosure of the charger is so fine extruded aluminium, and a good design, so I did not have the heart to just throw it out , but also did not stand the useless brick laying around. Probaly it would be possible to reverse engineer it and get running somehow, but closer inspection showed that the hardware probably is not so perfect to bother messing with it, plus the results would be quite unrepeatable, becuse when ordering the charger from the ebay.com it is quite random what version you get. Much better to make one own hardware! The enclousres for those chargers seem to be quite indentical though. So it would be nice possibility for many people to be able to swap out the internals of the charger with the good fully customizeable open source hardware and software. Currently unknown where those enclosures come from and weather it is possible to order custom variants, but for the price (about 15USD) it seems completely viable to just buy whole charger for the project, throw out the original guts, and reuse the case.
For designing the circuit and board my choice of tool is very good free and open source electronics design suite KiCad (currenty ver5.0).
I found some circuits from around the web that is originally known to be compatible with cheali-charger.
The most basic seems to be this:RC-Power_BC6_Charger.pdf
Another almost same example:rc-power_bc6_imax_b6_hobbyking_eco06_digital_charger_voltcraft_b6_digital_balanced_charger.pdf
The one I had in my hands in most parts represented the following circuit, good ideas from there, also this is notably good source for component choice because uses most readily available and affordable components:ImaxB6_clone.pdf
In this version I tried to follow the concept of SMD balancer resistors. Other circuits have seen some improvements, so it is a redesign from basically BC6 cicruit mentioned earlier. Would no recommend using this version directly but only maybe the base for better redesign. Shown here for reference purposes. Also I am not completely sure weather to completely abandon the SMD balancer resistors.
Warning! Discharger section of this version is flawed, directly drawn down from the original, but do not have low pass filter in it, so can not work! This version was never prototyped.
KiCad 5.0 project files:TBmax_ver1.5.zip
Schematic in pdf for quick viewing:TBmax_ver150.pdf
Snapshot from 3D rendering:front150.jpg
Quite big redesign again. Went to through hole resistors for the balancers as I found out that 2W resistors are readily available.
Discharger circuit also fixed. And of cource when at it I added some of my own touch to it (complete redesign).
This is currently production candidate version. Not prototyped as 11.10.2018
Kicad(5.0) project files:TBmax_ver1.8.zip
Scematic in pdf for quick viewing:TBmax_ver1.8.pdf
Snapshot from 3D rendering:TBmax_front180.jpg
Snapshot from 3D rendering backside:TBmax_back180.jpg
Gerber files for PCB production:TBmax_Gerber.zip
- Improved "Battery reverse polarity protection" -now it should be safe to connect also battery first to the charger.
For some thoughts: http://blog.deconinck.info/post/2017/12/22/18650-Battery-charger-reverse-polarity-protection
Although we have higher voltages (up to 6cell battery) so had to improve that further.
The original was using LM324 inputs, but LM324 is suspectible to output phase reversal. https://www.google.ee/search?q=op+amp+output+phase+reversal+lm324&ei=qM2tW52FDKyZlwTqi6HQAg&start=10&sa=N&biw=1309&bih=689
So better avoid using LM324 inputs outside their maximum allowed voltage limits.
Also the new circuit should make it safe to connect battery first to the charger. No matter correct polarity or not. Prevously there was problem that battery reverse protection opamp itself needed supply connected first.
- Redesigned cell2 individual voltage measurement. Now uses also diff amp. same as cells 3...6.
Used the extra opamp that is freed from the battery reverse protection. Prevously it was only 4x voltage divider. This should improve accuracy on that.
Needs software calibration adjustment, so need to figure that out.
- Redesigned main converter circuit slightly. Now the current error limit is compared with comparator(U3A). This makes it definite current limit 6.5A by default.
Formula for current limit: I= 5V/15,47/0,05 (comparator treshold[V]/current measurement amp. gain/current sense resistor value[Ohm])
- MOSFETs in the sell balancer load switches.
- Through hole resistors for balancer loads.
- Redesigned discharger circuit. Now uses two darlington NPN transistors to dissipate the heat. And larger value resistors. TIP120 is suitable for analog non-switching applications in compared to previous IRFZ44 that is designed for switching applications. Pinout is compatible. Can still also use MOSFETs without modifications. Assume max 20W dissipation, then IRFZ44 maximum allowable heatsink temperature calculates to 175-40= 135C. For TIP 120 max heatsink temperature at 20W is 150-40=110C. MOSFET may still be slightly better. Must conduct testing.
Maximum estimated discharge power is 2x2=4W on the resistors plus 2x20W on the transistors, total 44W. Probably good idea to use thermal sensor.
- Upgraded voltage reference to 5V.
Recalculated all circuits for 5V ADC reference. Should have the benefit of added accuracy. Also it is nice to use all same value resistors in the cell voltage measuring opamp circuits. Differential amplifiers gain is now increased to 1. As circuit components are all adjusted accordingly so no major firmware rewriting nessesary. Need to check discharger calibration in software and also main voltage measurement -- ADC input dividers might be slightly off, so probably needs new calibration values.
- Atmega32 microcontroller
- In general should still be compatible with the cheali-charger imaxB6 atmega32 version.For further details of how to find the hex files for flashing:https://github.com/stawel/cheali-charger/tree/master
- holes in the board at the places where power transistors tab holes are, this makes possible to screw mount thansistors to the baseplate.
This is the enclosure front panel for the project:
3D rendering of the board:
Board with with display:
- Written by Teemo
- Category: Electronic projects
DIY traffic light with PIC microcontroller.
Open source hardware project.
- Automatic cycle of lights.
- Super simple boost converter driven from PIC microcontroller for LEDs supply.
- Easy construction.
- Lights speed adjustable by potentiometer
- Powered by 4xAAA or AA batteries. In theory can also be powered by LiPol cell.
- Very small current consumption. Long battery life.
- Push button for power ON/OFF and manual advance of lights.
- Controlled by PIC16F1824 microcontroller
- Fun thing to play with
This project was inspired by my daughters kindergarten. One day they showed up with some electronic parts including 555 timer and one led for each color and wanted a traffic light for the kids game. I was not happy with that design, and wanted some more power, so I designed a completely new circuit and printed circuit boards. Of cource with a PIC microcontroller. Fortuantely I found out at the time that it is possible to order the PCB-s of 3 different colors just suitable for traffic light. So I managed to come up with very nice circuit and overall design, that I am happy with. And hopefully children are also happy with it.
PIC microcontroller generates PWM signal for boost converter circuit (Q1;L1;D3). It is mainly constant frequency and constant duty cycle. Software only corrects the duty cycle a little for different lights so that all lights seem equal intencity. The 36V stabilitron D4 is important component for safety, it clamps the maximum voltage to 36V in case the leds are disconnected. The boost converter for LEDs do not need much output capacitance because LED-s are not sensitive to current fluctuations. Also the output current is limited by inductor current, so all suits very well.
Q1, Q2 and Q3 are used for switching between the lights. Microcontroller again takes care of the timing.
RV1 potentiometer is used for adjusting the lights cycle speed. Microcontroller reads the potentiometer position and adjusts the cycle duration accordingly.
Circuit as a pdf here:trafficlight.pdf
The latest code uses the state machine approach for easily managing the lights sequence. I actually had to measure the real traffic light changing speed from the video made on the cross section. Interesting thing is most people do not know that for a period of time the red and yellow lights are both on before the green appears! Even those who have driven in the city for years!
PWM signal is generated by the PIC built is PWM module so that is really easy too. Only configure the parameters and go! PWM values are fixed values found out during testing so no difficult feedback system there. All plain and simple.
The one button is coded as follows:
- Short push (when off) -- Power on. Actually wake up from sleep
- Short push (when on) -- Advance to the next color manually.
- Long push (hold button for little longer) -- Power off. The microcontroller is in sleep during OFF state. All other things turned off.
Firmware assembler source code here:mainfoor.asm
Compiled hex file for directly programming into PIC16F1824 here:valgusfoor.hex(rename downloaded the file -- remove .txt from the end)
Originally compiled under the MPLAB IDE v.8.92 but also MPLAB X should work very well.
Note that in the circuit diagram it shows PIC16F1823 but this is repaced with newer PIC16F1824 in the final circuit!
And yes the firmware is quite state of the art and maybe a little overkill for so simple application but I had a good time coding and recoding it ;) Eventually I am happy with it!
Printed Circuit Boards:
Here is how the board looks in the Kicad Pcbnew.
The original Kicad files here (and also Gerber files for ordering PCB-s from PCB manufacturer):Trafficlight_Kicad+gerber.zip
The boards need to be cut open with saw. Could be made with V-groove but I did not use it because the V-groove panelizing is at extra cost for the prototype PCBs. So design is originally for cutting the boards with hacksaw (later I turned to small narrow kerf circular saw).
Enclosure is most easy to make form empty carton juice containter. Holes cut and boards glued in with hot glue gun. All covered with black or gray carton. Sun shades also forom carton glued to the lights. Hatch made to the back to access the boards and the batteries. With pin headers soldered to the boards the components are then easily wired together with jumper wires.
- Written by Teemo
- Category: Electronic projects
DIY Metal detector project with PIC12F1572 (or PIC12F1840) microcontroller.
This is open hardware DIY project. It is possible to make either pinpointer or a full size metal detector based on this circuit.
Ported to the PIC12F1572 at 6.08.2107. PIC12F1840 still usable also.
Figure 1. This is the circuit:
- Very easy to build.
- Search coil is simple monocoil with no adjustment needed. Just use standard inductor or wind some turns of wire yourself and start detecting.
- Moving mode detecting, search algorithm automatically adapts to the coil parameters and detects as those change in time. So there is no manual tuning.
- Discrimination between different metals. Non-ferrous result in lower tone than ferrous metals.
- Led "power on" indication.
- Push button ON/OFF switch
- Low power consumption 20-50 mA
- Runs directly from 4 NiMH cells
- Basic discrimination features. Gold makes slightly different sound from iron.
- In circuit programming (ICSP) connector for easy firmware uploading. NEW!
I keep pursuing my original goal, to keep the schematic as simple as possible with as few components as possible, yet to have good sensitivity. Reason I publish all details is that I want others also benefit from the hard work I have already done.
- Schematic pdf file here:metaldetector.pdf
- Black and white version of the schematic (better for printing): metaldetector_bw.pdf
- Parts list:partslist.pdf
- Kicad project files (circuit and PCB Ver3.00):Kicad_project_files
Quick link to the PIC12F1840 datasheet:41441B.pdf
This circuit has been tested to work with different coils. Software algorithm automatically adapts to the coil parameters.
Basic coil is 20cm diameter, and 27 turns of 0,74mm2 copper electrical installation wire. Regular 0,5mm or less diameter insulated solid copper coil wire is also good. There are many good coil making instructions in the internet.
Coil inductance in the circuit is given as a guide only. You can use variety of coils with different inductances. Circuit must still work. Possibly the reasonable range is 150μH to 470μH. Coil resistance in the range of 0,25 to 2 ohms.
For pinpointer it is preferred to use off the shelf ferrite core inductor for the coil. I've found that 470μH and 1,8A 0,28Ω rating works fine.
One day I decided that I need a metal detector. Motivation to that came from repeatedly sawing into hidden metal inside wood with my chainsaw mill, and ruining my saw chain. So logical step was to get a metal detector. Then I researched market for metal detectors. And of course found out that cheap ones are probably crap and better ones I can´t afford. Then searched web for DIY metal detectors. I soon realised that all available circuits are not for me. Well, microcontrollers have been around now forever and those small ones are so cheap and relatively powerful. So why bother building some ancient design metal detector with several opamps and bunch of resistors and other components. Surely we can do better nowadays -- We can do it with one 8 pin PIC microcontroller and very few external components! I guess I make separate article about my sawmilling system some day.
So here is, how to build build good metal detector for only microcontroller cost, all other components and coil wire can be obtained from electronics crap laying around everywhere, and if you want to program PIC yourself, you need some programmer device compatible with PIC12F1840. I personally use PICKIT3. I bought PICKIT3 because sadly i discovered that PIC12F1840 was not supported by my JDM and Parallel TAIT programmers. If you do not have programmer you can purchase preprogrammed microcontroller from my shop.
I call this “Pulse oscillation decay” type detector or just "Pulse oscillation" detector. In principe it is inspired by commonly known pulse induction detectors. Current pulse is sent to the coil and then response is measured. In my detector circuit the coil is not dumped by dumping resistor as found in common pulse induction detectors. High current pulse is applied to the coil and after the pulse is cut off, oscillation occurs in a tank circuit formed by search coil and capacitor in parallel with it. This oscillation is by the way relatively HIGH VOLTAGE. So all circuit must be well isolated to avoid electric shock! Oscillation is then of course decaying fast, because of losses, and because energy supply to the circuit is cut off. Mainly there are constant resistive losses in oscillator circuit, and apart from that there are EDDY CURRENT losses in possible metal target. Microcontroller just have to measure the decay time, to detect differences in oscillator circuit losses. And by all means, if resistive losses are constant, any other decay time change means there is METAL TARGET near the coil.
Coil oscillation frequency is roughly set by coil inductance and parallel capacitor value. And frequency also changes slightly depending of the target metal properties. The ferromagnetic metal target objects decrease free oscillation frequency and non-magnetic metals increase oscillation frequency. So it is even possible to discriminate between targets with this method, and this function is included in latest firmware.
Oscillation maximum voltage is also dependent of the C1 value. Capacitor C1 is chosen so that voltage at the coil never exceeds about 150v, the MOSFETs rated voltage. Mosfet I use in latest working rig is IRLI630. Most logic level drive and 150V mosfets should work. Mosfet avalanche must be avoided, it is possibly not very stable woking region. Higher voltage mosfets have always larger on-state resistance which in turn limits maximum current for given supply voltage. It is reasonable to choose 200V maximum voltage mosfet transistor, if supply voltage is 4,8V from 4 NiMH cells.
Figure 2. Search coil one pulse voltage.
In my design pulses occur at 2 millisecond intervals. Pulse duration is 140 microseconds. Pulse timing is taken care by PIC microcontroller and MOSFET is directly driven by PIC output pin trough R3. Coil Pulse current is limited only by MOSFET on-state resistance and search coil resistance. This makes pulse current as high as possible – more sensitivity. At the same time, as pulses are very short, circuit average current consumption is very low – no need to carry huge batteries with you.
Use ONLY 4 NiMH or NiCd cells to supply this circuit! There is no supply voltage limiting circuit and four Alkaline batteries voltage will be 6V, which is too high for PIC microcontroller!
I repeat: This circuit is designed to use 4 NIMH cells(AA or AAA) in series for power supply.
Figure 3. Receiver side block diagram:
This is equivalent circuit about what is happening inside PIC12F1840. The PIC internal features are configured in the way shown. Input pin is configured to comparator -input, comparator +input is internally connected to Digital to Analog Converter which supplies reference, 32 voltage levels between V+ and V- possible. Comparator output is internally connected to TIMER1 gate. This valuable function only lets the Timer1 to count when comparator output is high. Program then activates Timer1 just after the coil pulse is ended and reads the value from the timer before starting the new pulse. And this is our measurement. Timer1 runs at system frequency of 32MHz and so has resolution of 31.25nsec.
Of course we can not let the high voltage signal reach the microcontroller. This is why there is limiting circuit of R4,D2,D3. Schottky diodes D2 and D3 dump the excessive voltage to supply rails. So voltage reaching PIC input is always in the range of supply voltage. Diodes D2 and D3 must be Schottky type, regular diodes are not fast enough and microcontroller likely gets damaged. To be exact I also tried the circuit without the diodes D1 and D2 and it seemed to work well because of the PIC internalt protection diodes, but there is too few testing to reccommend that.
Figure 4. Limited voltage waveform at Microcontroller input.
Notice how upper part of the oscillation is almost completely limited out, and lower part is limited to negative supply V-. Oscillation center point is positive supply V+.
PIC firmware is now written in assembler using MPLAB X environment. When I started the project I used MPLAB IDE v8.83.
Firmware pushes this little microcontroller to its limits regarding speed and takes full advantage of the PIC´s on-board peripherals. Using PIC microcontroller superior power management capabilities it made possible to eliminate physical power switch form circuit. All functions are controlled only by one push button. When circuit is turned off PIC is in sleep and current draw is virtually none. Much less than NiMH batteries self discharge anyway.
Sound generator just uses timer2 to toggle speaker outputs. Speaker is connected between two outputs because this creates sort of bridge circuit, voltage is doubled, sound is stronger, and signal do not have DC offset.
PIC resources used:Interrupts, Interrupt-on-change, Sleep mode,DAC, Comparator, all Timers(Timer0,Timer1,Timer2).
Active version 2.00:
- Slight discrimination between different metals. The non-ferrous metals make lower tone than ferrous metal(iron).
- Single button push turns detector on.
- Double push on the button changes operating mode.There are 4 modes:
- discriminating mode, standard on/off sound
- gradual beeping(distance indication), now with discrimination
- discriminating mode, less filtered than mode1
- silent mode, only LED on/off
- Longer push on the button turns detector off
Source code version 2.00 (for PIC12F1572) whole MPLAB X project:PIC_program_12F1572.X.zip
Older versions (no discrimination yet):
Button double push activates the serial rs232 sending, single push returns to normal mode, longer push turns power off.
Printed circuit board (PCB):
Currently there is three versions of PCB-s designed.
V1.00 First version was one sided board.
V2.00 version was two sided board (actually by design may work with only bottom layer) but when I designed second version I converted to newer Kicad version and redraw the schematic, and did accidentally swap the LED connection and piezo speaker connection to PIC pins (5;6). So ver.2.00 need slightly modified firmware. But I already managed to order bunch of those boards from the PCB factory. Non of those boards shipped from my shop.
V3.00 is two sided board. Compatible with version 1.00 with following improvements:
- C2 and Q1 mounted horizontally to enable mounting the circuit inside the tube.
- now has mounting holes in the corners
- switch mounting in the center position, to enable better button shaft mounting
- ICSP connector
I recommend that PIC should be socketed, although ver.3 board have "In Circuit Serial Programming"(ICSP) possibility. PCB dimensions 30 x 60 mm.
PCBs and kits of parts are also available in my shop.
Here is exellent article by Robert Batey KF7FTQ of his coil and detector construciton. With his kind permission the pdf file:my_md_article.pdf (5,5Mb)
Discussion and information backup in the forums:
for general electronics and microcontrollers:http://www.eevblog.com/forum/
Thanks for everybody who participates in those forums, it has helped me a lot to go forward with this project.
Now I hope this site contains all needed information to sucessfully build working metal detector.