Using multiple MCUs to replace discrete components

Thread Starter

smp4616

Joined Oct 31, 2019
31
I'm working on an interesting controller project that involves overcurrent monitoring of 8 outputs, I have solved the main problem of current spiking in incandescent loads, but that involves 1/2 of an op amp chip and some caps and resistors, which when multiplied by the 8 outputs, winds up being a mess of routing, more parts to place etc. I am running the main controller that handles the user interface on an atmega2561, but have used some really tiny attiny45 chips in the past and have been impressed with their functionality and lack of any other components needed to run them. What I'm wondering is, is it good practice to replace the discrete overcurrent monitoring components with an attiny45 chip at each output? It could monitor the shunt resistor easily in software and integrate the current x time that my discrete parts are doing now. The cost hardware-wise would go down, the number of board components would go down, routing would get easier... seems like a no brainer, just wondering if there's a downside I'm not seeing....
 

jpanhalt

Joined Jan 18, 2008
10,087
I am not familiar with those specific MCU's. With PIC's you generally have a choice whether to program before or after installation. The latter could be complicated with a lot of small (e.g., 10Fxxx) devices. That consideration alone would not prevent me from doing it since one can buy the chips already programmed.
 

Thread Starter

smp4616

Joined Oct 31, 2019
31
I was planning on preprogramming, would probably build a tester to validate their functionality before assembly too.
 

MrChips

Joined Oct 2, 2009
21,664
Your approach is a reasonable one and doable. I offer the following suggestions.

1) MCUs (microcontrollers) are powerful enough to handle all eight inputs. You do not need a dedicated MCU for each input. Do not get fixated on any particular MCU chip or manufacturer. Find the right MCU to get the job done.

2) IC packages are increasingly available in SMT (surface mount technology), through-hole packages becoming less often available. SMT provides a more compact design.

3) With (2) in mind, you have to plan how you are going to develop the software and mount the MCU on to the PCB (printed circuit board). For a simple process you can develop the code and program the MCU chips on a programmer and then install the chip on to the board. For more complex designs, you need to incorporate an ISP (in-system programming) port on the PCB. In either case, you may want to create a test bench that will allow you to develop the code without having to remove the MCU chip.
 

Thread Starter

smp4616

Joined Oct 31, 2019
31
the main mcu can handle all 8 (outputs), but doesn't have enough differential ADC inputs to measure each high side shunt resistor, it requires 8 current amps and 8 adc channels, or 8 current amps, some op amps and discretes, and 8 INT inputs. the benefit of running 8 very small mcu's to control each individual output overload protection is also that the main mcu can go from a $10 part with 64 pins to a $2 part with 32 pins. based on the number of individual tiny mcu's, it seemed to me the best way to implement the design would be to program the chips off board, otherwise I'd need 9 separate icsp ports, I'd be okay with programming the main MCU icsp, but each output monitoring chip seems excessive.
 

John P

Joined Oct 14, 2008
1,819
Whoa there, "high side shunt resistor"--how high is high, and what shifts the voltage down to the range that the processor can deal with?

And you'd be taking some amount of risk if you can't program the processors in place. If you want to change the code (never happens, right) you'll be up the creek.

Extra components are to be avoided, of course, but board routing? I just toss it at my autorouter and it never complains.
 

Thread Starter

smp4616

Joined Oct 31, 2019
31
system voltage is 13.8, with a bad regulator it might go as high as 18. That's a good point I hadn't thought much about, I'm using the differential input of the ADC which I assumed would allow for comparison of the two inputs regardless of their relationship to vcc or gnd of the chip... now that I look at what I wrote, it seems to need more investigation. The datasheet doesn't seem that clear to me about how much higher than vcc the inputs to the differential ADC could be...
 

John P

Joined Oct 14, 2008
1,819
I've looked it up:
Absolute Maximum Ratings
Voltage on any Pin except RESET with respect to Ground ................................-0.5V to VCC+0.5V

If you'd consider resistors acting as a voltage divider, I think you'd need 4 of them per channel, and then you have to worry about maintaining accuracy of one side of the shunt versus the other, and how much current flows through the resistors. Then there's probably a spec for maximum impedance of the input to the ADC pins.
 

Thread Starter

smp4616

Joined Oct 31, 2019
31
I also just read that... I redrew my diagram based on running a current amp into an attiny25 and with that, I'm still looking at a huge reduction in components and still have the ability to port down from a 64pin $10 main mcu to a $2 32 pin mcu, which makes up the cost of the current amps... still looks like a good solution. crazy the things you can do when a $1 chip the size of a pin head has more power than my first ibm pc...
 

dendad

Joined Feb 20, 2016
3,595
What about using Hall current senors?
https://www.allegromicro.com/en/insights-and-innovations/technical-documents/hall-effect-sensor-ic-publications/high-power-density-cb-package-current-sensors
Or some high side current sensors, like these?
INA219. Adafruit have boards ready for you to play with.
https://www.adafruit.com/product/904https://www.ti.com/lit/ds/symlink/ina219.pdf
As these chips are addressable, an I2c port will drive 4 sensors directly.
These are I2C, but the ones I have used have analog out, so that is an option too.
 

Thread Starter

smp4616

Joined Oct 31, 2019
31
I'm basing the design on ina181/ina180 sensors, based on cost and simplicity, the i2c is a nice feature but having a direct analog output to trigger an interrupt in a few microseconds is required, a low impedance load (screwdriver) can cause a lot of damage to a FET if it's not shut off real quick-like
 

danadak

Joined Mar 10, 2018
4,057
If you use Cypress PSOC you can do all analog on one chip. The 8 diff channels I show are
done with its DelSig A/D and the 8 single ended channels done with SAR. Both onchip as well
as Vref (+/- .1%).

The DelSig has a property it can common mode 100 mV outside its rail, so you can do high
side sensing directly. However I think your design has to offset your CM as I am guessing its
a lot more than Vdd PSOC + 100 mV. Still property might be useful.

Core is 32 bit ARM.

Also 4 OpAmps and other analog on chip for use.

The board to do this would be $ 10, tool (PSOC Creator) and compiler free.

https://www.cypress.com/documentation/development-kitsboards/cy8ckit-059-psoc-5lp-prototyping-kit-onboard-programmer-and
https://forum.allaboutcircuits.com/threads/using-multiple-mcus-to-replace-discrete-components.165043/

Looking at right hand window you can see resources used/unused. Lots of digital
and other analog. Each resource is called a component, attached is a catalog of onchip
components. Onchip you have Digital Filter, Comparators, Mixer, Counters, lots of COM,
random logic, PWM, LCD, LUT, DAC.......

You drag and drop the components onto design canvas, use wire tool to wire up internally
and to external pins. Then use each components API libraries (f() calls for manipulation)
to do the coding.

1574819713048.png

Tons of projects and videos for learning. The tool has many internal projects, and there
is this -

https://www.cypress.com/documentation/code-examples/psoc-345-code-examples

https://www.element14.com/community/thread/23736/l/100-projects-in-100-days?displayFullThread=true
https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days

PSOC 4 is low end family, 6 high end dual core, also supporting BLE. The above is the 5LP
family.


Regards, Dana.
 

Attachments

Last edited:
Go for Atmel 328P, any of the Tiny's. Far more support available than PIC's etc.
Don't worry about DIP packages being phased out - there are still loads available and even with SOIC packages, plenty of adaptors as well. Once you get used to using them, you won't look back. No more fiddling around with 555 timers and resistor/capacitor values to end up with an inaccurate timer etc. - delay() or millis() does it in one line, plus some others. Tiny 85 can do some remarkable things.
 

Thread Starter

smp4616

Joined Oct 31, 2019
31
thanks! I am already well underway in designing the distribution architecture for the unit, I am going with the 328p for the main controller and using a synchronous serial bus to communicate with the 8 attiny chips, they'll handle the overcurrent protection and also handle things like pwm, since the outputs have a finite number of modes (i.e. flash, pwm intensity 0-4, fade in-fade out) I came up with an 8 bit packet that sends the address of the chip (only 8 so 3 bits) and the command (32 possible commands). this means the 328p is very underloaded in terms of computing overhead, and all the attinys can run the same program with the exception of a different address hard coded. really happy with how simple this is turning out once I got over the idea of highly centralized architecture
 

danadak

Joined Mar 10, 2018
4,057
Just a for your info there is a Basic Language support for ATTINY85 and an IDE
for that use. That IDE supports Basic.

Bascom Basic

https://www.mcselec.com/index.php?option=com_content&task=view&id=14&Itemid=41
If you ever get around to doing a redesign or similar keep in mind the PSOC solution is
a 1 chip solution as all the analog and all the digital and COM you required is on 1 chip instead
of the 9+ chips you are working with now. You get greater reliability for the design, much lower
power, less interconnect, much lower cost......



Regards, Dana.
 

mjaa

Joined Dec 11, 2011
5
Thank you for raising an example of new possibilities in using small powerful cheap micros to perform the role of multiple relative dumb analog/hybrid/digital interfacing. The answer to your question is that your initial suggestion is most certainly an option worth exploring. I have found multiprocessor solutions especially using fast serial comms (e.g. SPI) can simplify, reduce or eliminate the need for discrete circuit components in the design.
In regard to in circuit programming I would certainly include ISP for the main controller. The channel slave controllers should have it retained until the channel slave software is reduced to configuration parameters. For production runs the ISP for slaves would be removed and those devices would be considered as configurable hardware blocks. Those incredibly functional and powerful tiny 6 or 8 pin micros are going to replace more and more discrete interfacing components and will drive more distributed control in our embedded designs.
Good luck! Mark (Old Guys Rule)
 
Top