What MCU Chip to Use for a 8-Cell individ. NiMH Roundcell Charger/Analyzer? - Page 1
Forum section: electronics / general

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 07, 2023, 06:08:27 pm
content: Due to the MCU part nofindum crisis of the prev. two years I had to make do with parts on hand.I decided to spend a few days building a 2x9V plus 4x roundcell NiMH cell charger/analyzer in my spare time, but failed to have on hand a single MCU that could handle the number of I/O, A2D, PWM, User GUI required.So, I built a chimera of three MCU's working together. One Infineon 5V PSOC4200 ARM (>40 I/O if not using 16-chan 12-bit A2D) stamp for PWM and charging, One 16F 28-pin PIC for monitoring cell temperature, and finally a 40-pin 18F PIC for GUI to achieve a ticker tape 7-digit x 7-seg Bubba Mplx'd LED display and also deal with the many button switches, 10-status LEDs, and 9V charging status. All three chips communicate with each other using RS-232 links with the 40-pin 64mHz PIC18F45K22 being the Master.I finished this task in free-time over a month or so and now it works 100%, works exactly as I wanted, but I would like to try to first use a approx 100-pin or so single MCU to handle the job to(but also now 8 round cells +2x 9V)eliminate the communication problem and simplify any debug/modify pgm process.My Analyzer device will:1) measure/setup/change/display charge mAH, Discharge mAH, charging temperature rise/limit, charge time, also meas. cell internal Res. Also want to have a two way charge status indication, test cells. For charge, monitor voltage, current, temperature of each of the 8-roundcells. 9V rect. bats are easy to charge and analyze when charging is accomplished slowly.2)Develop a simple(maybe just same multi-7-seg LED) display, quick view status LEDs plus use a multi-touch sw. GUI.I know nothing about working with STM or NTX MCUs, but maybe a dirt cheap dev. board(stamp?) on Alibaba that fit the bill. It will be a small challenge just to make a decision to select the best chip and a greater challenge to learn how use the tool chain.3)I find it so easy to work with PDIP 5V Vdd MCU's, have no experience on how to migrate to 3.6V max Vdd MCU's.What is the best/easy way:1)Trying to work with PIC's pay for use compilers and just use a PIC32 chip?2)Spend months learning how to be able to understand how to competitively choose and use (very different from PIC's) STM or NXP tool chains to config a STM or NXP chip?

author: kripton2035
author_rank: Super Contributor
timestamp: December 07, 2023, 06:20:50 pm
content: there are PSOCs with 100 I/O pins ...

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 07, 2023, 06:35:09 pm
content: 100 pins or so..But I need to get to charge any one or multiple size cell individually and asynchronously of others.8x 12-bit A2D for round cell voltages2x min 10-bit A2D for 9V NiMH batteries8x min 10-bit A2D for cell current9x min 10-bit A2D for cell temp7 I/O for 7-dig 7-seg LED disp. common anodes8 I/O for 7-seg LED Segs incl decpoint9 I/O for touch Sw's1 I/O for Power ON12-single LEDs for quick-at-a-glance blinking indicators of charging status, etc.Be able to develop 100-pins using a single mini dev bd/ dev stamp?

author: David Hess
author_rank: Super Contributor
timestamp: December 08, 2023, 01:00:03 am
content: Is there some reason that it must be a single chip design? I would add external I/O expansion to a more limited microcontroller. I find it advantageous to locate I/O closer to where it will be used.

author: IOsetting
author_rank: Regular Contributor
timestamp: December 08, 2023, 01:35:41 am
content: Quote from: SuzyC on December 07, 2023, 06:35:09 pmSince these won't need high speed, maybe you can use something like 74HC595 and 74HC165 to expand these IO?Then you need only 6 pins to drive these 37 IOs.

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 08, 2023, 02:53:20 am
content: DavidHess/Amyk..I have much examined your expansion idea very carefully.It is not too much a pin count nor cost jump to replace a 74HC595 SR with an actual PIC/STM/NXP 14 to 40-pin MCU footprint to get better results with much easier to follow coding to achieve 7-seg multiplexed 7-digit displays, but I want to put all my eggs in onesmallbasket. I am quite aware that adding non-mcu dumb peripheral chips requires carefully attention/balancing in regard to code loop execution time, task scheduling and interrupt servicingto achieve flicker-free many-dig mtplxed displaysand quickly responsive control buttons with debounce code. I also want a smaller PCB footprint, means less parts on a smaller PCB.Of course, since I have already have the working code for a 3-MCU solution for simultaneously async charge/analyze 4-NiMH roundcells plus 2 9V bats, I could just use two <100 pin MCUs and modify code to make a virtual all-in-one device for a 8-roundcell + two 9V analyzer, thus eliminating the two other slave MCUs I am using now and their associated data/cmd syncing with the master MCU.CON: The existing mult-7 Seg display would have to be shared by the two MCU's.

author: amyk
author_rank: Super Contributor
timestamp: December 08, 2023, 03:14:52 am
content: Do you really need at least 27 ADC channels on the MCU itself? An analog multiplexer or two would be sufficient.

author: kripton2035
author_rank: Super Contributor
timestamp: December 08, 2023, 08:31:10 am
content: you could use i2c to talk to a display with some TM1638 chips, and so remove a lot of I/Oand it would still be flicker free...

author: Sacodepatatas
author_rank: Regular Contributor
timestamp: December 08, 2023, 04:12:01 pm
content: Quote from: SuzyC on December 07, 2023, 06:35:09 pmIf I were going to design such an appliance, I'd go using the KISS principle. There's methods for reducing interface pin count, thought for low pin count MCUs but also valid when you have a high amount of signals interfacing a mainstream IC.But, your design has certain constraints that I won't tie to. For example, I would get rid of the vintage Bubble thing and fit 7 single digit 7seg display, no matter whether common anode or cathode (but all of them of the same type). Then you can control the full set of leds, both display and single indicators. Using Charlieplexing with 9 GPIOs (something somehow easy to achieve throught code) you can control 9 sets of 8 leds at 1/9th duty cycle per set, that means controlling full segments of 7 single digit displays plus 2 groups of 8 individual leds = up to 16 indicators.You know? If you don't need multiple keypresses, you can use just one IO for reading all switches by using a very simple resistor matrix and an analog ADC read. In fact, you can adjust resistor values to be able to read 2 or more simultaneous keypresses.Assuming you don't need to share grounds of NTCs, you can use the already used IOs for the charlieplex scanning as multiplexed ground references for all the temperature sensors, then you will need just one ADC input...Take a look at these tricks. You might know many of them as you have already programmed PICs.https://ww1.microchip.com/downloads/en/devicedoc/01146b.pdf

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 08, 2023, 04:52:02 pm
content: Krypton2035: Thanks for helping:PRO: I see clearly how adding a dedicated TM1638 chip for the LED display reduces the master MCU I/O pin count use.CONs:1) Added cost of chip.2) Flickering problems if a 7-Seg x 8 dig display is actually a tickertape display.3) Addition PCB layout time cost of TM16384) Increases overall size of PCB5) Rather than use the TM1638, for the same cost, a MCU using a single serial pin makes a flicker free display(but still has CONs 1,3-4)6) Would have to spend the time to debug/tune/rewrite a fine-tuned tickertape display code already perfected.

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 08, 2023, 05:12:14 pm
content: Sacodepatatas: Many thanks for your detailed advice!I am not sure exactly what you mean by Charlieplexing, a circuit drawing (even on a piece of a dinner napkin) is worth a thousand words!Right now I am using BubbaPlexing, simply means I connect each Common Anode to a MCU pin, one resistor needed.All LED disp digits segment connects directly to its own MCU pin, no resistor needed.Is this what you mean?Works perfectly and truly difficult to see brightness variations due to number of segments active.----Analog Key Mtplxing:PRO: Only requires one A2D pin to read up to about 10 SW's.CONS: I built an UV scanner using this technique and after about a few months the resistance of common miniature though-holeswitches(like the type used in VCR's etc) developed a very high contact resistance requiring me to press really hard repeatedly to get some SW's to work, but even so, some of the switches would not work at all.----Charlieplxing A2D: Cannot understand exactly what you describe here. Again, a simple schematic posted would disambiguate what you are describing.-----Finally, I want everyone to know that I want to make devices that are high-quality, reliable, and long lasting.I choose to fab my own individual roundcell analyzer because the cost of an industrial unit was very high(and I like building my own projects).I want my custom equip. to be of greater quality and performance than stuff sold to consumers.I try not saving pennies in parts only to lose dollars in performance, capability, ease of repair and operation, and reliability.I will use novel circuits that can achieve my goals to reduce BOM size and cost without sacrificing performance and reliability.

author: kripton2035
author_rank: Super Contributor
timestamp: December 08, 2023, 05:57:49 pm
content: 10 x TM1638 cost around $2 shipped ... so they will not increase the BOM that much ?and I don't see how you can have flickering problem with this chip: it handles all the refreshing for you...

author: David Hess
author_rank: Super Contributor
timestamp: December 08, 2023, 06:15:49 pm
content: Quote from: SuzyC on December 08, 2023, 02:53:20 amI am considering replacing simple expansion using the 74HC595 SIPO and 74HC165 PISO shift registers with a moderate pin count microcontroller like the PIC or AVR which is actually less expensive.

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 08, 2023, 06:47:05 pm
content: Krypton2035: My bad, actually I should say the smooth tickertape display char pacing/char stepping could be affected(slightly out of a constant char shift step rate), not dig brightness.Again, adding an additional chip only leads to greater PCB footprint/complexity and cost and goes against a goal of eliminating 2 of the MCU's.

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 08, 2023, 06:59:36 pm
content: I did find some Infineon >64 pin ARM M0+ MCU's maybe in hand-solderable batwing flatpack pkg in stock at Mouser that could do the job, even if there is future availability questions. Not to mention a single piece price ~35 USD not including 30USD special charge penalty to ship a small order.Does anyone know of a 5V STM or NXP dev board available?

author: nali
author_rank: Frequent Contributor
timestamp: December 08, 2023, 07:03:00 pm
content: Quote from: SuzyC on December 08, 2023, 05:12:14 pmYour switch problems here sound very much like awetting currentissue where you're not breaking through the oxide layer on the contacts. You can mitigate this with small value capacitors across each switch to provide a current surge when contacts close.

author: SuzyC
author_rank: Frequent Contributor
timestamp: December 08, 2023, 07:08:18 pm
content: Nali: Thanks, I have tried that, but this is a fixup rather than a design choice and this fixup allows me to futz around for minutes to "freshen" the Sw's. I'll pass on that!The idea does work for a while, the few the Sw's the better, but I don't want to design in likely goofy Sw operation into my analyzer.I would really like to migrate my design to only use perfect touch switches and Infineon MCU's claim to be best at this.

author: Sacodepatatas
author_rank: Regular Contributor
timestamp: December 08, 2023, 08:11:50 pm
content: Quote from: SuzyC on December 08, 2023, 05:12:14 pmWhat you depict is a classic matrix multiplexing. By other hand, Charlieplexing takes advantage of the tristate capability of MCU IO ports (Hi output state, Lo output state, High Z input state), so you can turn on/off many more LEDs with just a few lines. But also it can be used for implementing many touch switches. Wikipedia has a very detailed page regarding Charlieplexing so that whatever i can write in here is much loose than what it is writen there. The manner of connecting individual digits is in a spiral fashion, that's why a multidigit display matrix can't be used (because they have all A segments, B segments, and so on, tied to the same pin). One can use 8 lines to drive up to 8 digits (without dot) or 9 lines to drive up to 9 digits with dot segment.Here is how i did some years ago when i modified the popular 50MHz PIC16F628 frequency meter firmware to unfold the 5 digits display to control 8 digits by using just PORTB.Quote from: SuzyC on December 08, 2023, 05:12:14 pmCharlieplexing is not just for LEDs, a diode is required (because GPIOs will be forward or reverse polarizing some diodes while others can be left floating). But they can be BE diodes of NPN transistors. Let's figure out that NTCs are conected as the low side of a resistor divider (the middle point is what you connect to the ADC). Just put one electrode of every NTCs connected to that ADC port, the other electrode of each NTC connected to the collector of each individual transistor that is going to be controlled by the charlieplexed matrix throught the respective B-E diodes. The transistor that is set as active, instead of lighting an LED, it leads the NTC to ground while the rest of NTCs are floating, not disturbing the measuring.https://en.wikipedia.org/wiki/Charlieplexing

author: JPortici
author_rank: Super Contributor
timestamp: December 09, 2023, 06:39:10 am
content: Quote from: SuzyC on December 07, 2023, 06:08:27 pmwhy? you have -O2 in free mode, that's more than enough

author: bookaboo
author_rank: Frequent Contributor
timestamp: December 09, 2023, 08:47:16 am
content: Solid advice in this thread, just to add my experience.... Don't underestimate the hassle of switching devices and toolchains, unless you want to migrate anyway. I'd steer clear of jumping around platforms.Also the Microchip compiler paid version (if you even need it which you probably don't) isn't that expensive monthly, just unsubscribe when the code is done. Of course if you want to mod then you have to sub again. Pain in the ass, but better than losing months of time on ST or NXP learning curve.

author: Ground_Loop
author_rank: Frequent Contributor
timestamp: December 09, 2023, 12:34:13 pm
content: A MAX7219 will drive 8 7-seg digits flicker free with only 3 IO (SPI clock, data, and chip select). They can also be daisy chained to basically an unlimited number of digits without additional IO. SPI can be up to 10 MHz which will provide a very smooth ticker tape display. Further, you can use these to also drive your status LEDS. All LED IO can be reduced to 3 IO. Cons 1, 3, 4 and 6 apply.

author: 8goran8
author_rank: Contributor
timestamp: December 09, 2023, 08:30:03 pm
content: There are many microchip PIC32 microcontrollers that meet your criteria.Check out, for example, the PIC32CX SG41/SG60/SG61 family of microcontrollers.

author: nctnico
author_rank: Super Contributor
timestamp: December 10, 2023, 12:20:32 am
content: Quote from: SuzyC on December 07, 2023, 06:35:09 pmFor the LEDs you could consider 'smart RGB LEDs' like these:https://www.lumex.com/digital-led.htmlYou only need 1 data line from an SPI interface (sending 3 bits for each bit of LED data to meet the pulse width data modulation scheme).