Author Topic: Need lots of I/O, what to do?  (Read 1298 times)

0 Members and 2 Guests are viewing this topic.

Offline sparksflying

  • Contributor
  • Posts: 28
Need lots of I/O, what to do?
« on: December 07, 2017, 10:35:46 PM »
Hello All,

I am trying to design a bulk battery discharger/analyser. I want it to be as simple as possible, so will be discharging using constant resistance (instead of the normal CC)

Basically, every cell will have it's own ceramic discharge resistor in series and I will measure the the voltage of every battery using the ADC in the micro controller (I'll use an 8-Bit PIC)

Ideally I want this device to handle at least 20 batteries at a time.

To test the voltage of each cell I will switch each battery onto a common ADC bus one at a time. This would require one ADC pin and 20 I/O pins. I also want the MCU to disconnect the battery once it is at low-voltage, this will require another 20 I/O. All the switching is done with MOSFETs.

I am already using 41 pins at this point and the MCU only has 36 I/O (44 pin PIC). None of the projects I've done so far have needed this much I/O, so I'm a bit lost.

I had an idea of using 7400 series chips, decoder/s to select each of the 20 batteries (74Hc154) and bistable transparent latches (74HC75) to keep the battery connected until disconnection is needed.

Logic chips are pretty outdated though, how would you do something like this now?

Thanks!

 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 5745
Re: Need lots of I/O, what to do?
« Reply #1 on: December 07, 2017, 10:53:45 PM »
Maybe rethink your design?  If you add a PIC12F1572 per cell, all communicating with your master PIC via an open drain serial bus (so it *MAY* also need a 'jellybean' small signal MOSFET, if the port open drain feature doesn't play well with the USART), you can PWM the cell discharge MOSFET. then all it needs is an inductor, a catch diode and a cap to smooth out the pulsing current to implement fully programmable constant current, constant resistance or constant power discharge.  It would be extensible to over 250 cells,  (above that you'd run out of 8 bit addresses for the serial bus and probably encounter fanout problems) .

 At under $0.60 for the PIC12F1572, its probably going to be no more expensive and may even be cheaper than the mess of logic and analog signal switching you are contemplating. There'd also probably be a cost saving if you are getting  PCBs made as 10x small boards usually works out cheaper than 1x large board of 10x the area.
« Last Edit: December 07, 2017, 11:19:09 PM by Ian.M »
 
The following users thanked this post: sparksflying, alexanderbrevig, woody

Offline fcb

  • Super Contributor
  • ***
  • Posts: 1197
  • Country: gb
Re: Need lots of I/O, what to do?
« Reply #2 on: December 07, 2017, 11:04:20 PM »
Use SIPO's for relay control, so these could be CD4094B's or a 74 equivalent driving ULN2803A's, or there are serial input relay drivers (UCN58somethingfrommemory).

Probably also use Nchannel MOSFET's instead of relays, easier drive, could be cheaper, etc..

I'd also use CD4051 or 74 equivalents to scan the cells, probably would sense both terminals of each battery, then either use a diff amp, or a differential configuration on the ADC - depends on how accurate you need to be.
 
The following users thanked this post: sparksflying

Online daqq

  • Super Contributor
  • ***
  • Posts: 1185
  • Country: sk
    • My site
Re: Need lots of I/O, what to do?
« Reply #3 on: December 07, 2017, 11:09:38 PM »
Quote
Logic chips are pretty outdated though, how would you do something like this now?
Why has no one told me!?
Quote
I am already using 41 pins at this point and the MCU only has 36 I/O (44 pin PIC). None of the projects I've done so far have needed this much I/O, so I'm a bit lost.
Analog muxes exist, both serially controlled or GPIO controlled. You can save a lot of GPIO by using this:
http://www.analog.com/en/products/switches-multiplexers/analog-switches-multiplexers/adg1606.html
or any of the other muxes available.

When you are low on digital output pins, consider shift registers (74HC595 and similar), of which you can cascade as many as you want.
Believe it or not, pointy haired people do exist!
+++Divide By Cucumber Error. Please Reinstall Universe And Reboot +++
 
The following users thanked this post: sparksflying

Offline sparksflying

  • Contributor
  • Posts: 28
Re: Need lots of I/O, what to do?
« Reply #4 on: December 08, 2017, 12:16:47 AM »
Thanks for the replies!

Maybe rethink your design?  If you add a PIC12F1572 per cell,
...
It would be extensible to over 250 cells,  (above that you'd run out of 8 bit addresses for the serial bus and probably encounter fanout problems) .

I think I'll go the multiple MCU route, but have a slightly larger chip that handles a few batteries. I've used the 14 pin PIC16F1503 before (so have a bit of stock) and will link them all together using I2C. I really like the idea that it can be extensible to many more cells without too much work. 
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1596
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Need lots of I/O, what to do?
« Reply #5 on: December 08, 2017, 01:24:28 AM »
How about the one MCU route, see attached screenshot PSOC.

This only uses part of the device resources.



For me what stands out is -

1) Routability
2) Fast 12 bit SAR A/D and slow 20 bit DelSig
3) DFB (Digital Filter Block) that is dual channel, handle FIR or IIR filters, or DFB
can be used as a GP fast processor block, similar to RISC block
4) MSI logic elements GUI based and/or the UDB Verilog capability. Eg. the FPGA
like capability
5) Onboard Vref
6) IDAC, VDAC, OpAmps (up to 4), comparator, mixer, switch cap, analog mux....
7) LCD,  COM, UART, I2C, I2S, One Wire, SPI, Parallel, LIN, CAN, BLE, USB
9) Custom components capability, create with schematic capture or Verilog
10) DMA to offload processes like filters, COM, Display
11) ARM M0 (PSOC 4) or M3 (PSOC  5LP) or 8051 core(PSOC 3) or M0+/M4 dual core PSOC 6
12) Extensive clock generation capabilities
13) All components supported by extensive prewritten APIs

https://www.element14.com/community/thread/23736/l/100-projects-in-100-days?displayFullThread=true

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

Great video library

Attached component list.  A component is an on chip HW resource.

Free GUI design tool with schematic capture, "Creator". Components have rich API library attached
to each component. Compilers free as well.

PSOC 4 is low end of family, consider 5LP parts as well. PSOC 4 also has arduino footprint boards (pioneer) as well. PSOC 6 dual core M0+/M4.

https://www.elektormagazine.com/labs/robot-build-with-cypress-psoc

http://www.cypress.com/products/32-bit-arm-cortex-m-psoc


https://brightcove.hs.llnwd.net/e1/uds/pd/1362235890001/1362235890001_5241352463001_2606504288001.mp4?pubId=1362235890001&videoId=2606504288001



Regards, Dana.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1596
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Need lots of I/O, what to do?
« Reply #6 on: December 08, 2017, 01:27:59 AM »
Basic kit to get started ($10) -





http://www.cypress.com/documentation/development-kitsboards/cy8ckit-059-psoc-5lp-prototyping-kit-onboard-programmer-and


One caution, this low end board does not bring out all pins, so I am not sure
you could do all 20 analog channels and get them routed. But its a great start.
The PSOC CY8CKIT-050 does bring out almost all pins.





http://www.cypress.com/documentation/development-kitsboards/cy8ckit-050-psoc-5lp-development-kit



Regards, Dana.
« Last Edit: December 08, 2017, 01:37:20 AM by danadak »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 5471
  • Country: us
  • DavidH
Re: Need lots of I/O, what to do?
« Reply #7 on: December 08, 2017, 01:29:57 AM »
Decoders like the 74138 and 74154 are one option where only one output is selected at a time.  They can even be driven by a counter to reduce the needed binary signals to two, one clock and one reset.

Serial I/O expansion with 74594s or cheap high pin count PICs is another option.  A 74HC594 costs 7 cents per bit and a PIC comes out to 5 cents per bit or less.  I like this solution because the I/O expanders may be placed where they are needed to ease signal routing.

A decoding matrix of 32 transistors can convert 10 outputs to 32 outputs.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1596
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Need lots of I/O, what to do?
« Reply #8 on: December 08, 2017, 01:57:15 AM »
I was able to route this on low end part, PSOC 4. Compromise is
no USB, less UDB digital blocks for GP logic, no DelSig or DFB
(Digital Filter).....


Board for this is Arduino footprint ($25) -


http://www.cypress.com/documentation/development-kitsboards/cy8ckit-042-psoc-4-pioneer-kit







Or the $ 4 board -


http://www.cypress.com/documentation/development-kitsboards/psoc-4-cy8ckit-049-4xxx-prototyping-kits






Regards, Dana.
« Last Edit: December 08, 2017, 01:59:43 AM by danadak »
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 1471
  • Country: fi
  • Embedded SW/HW.
Re: Need lots of I/O, what to do?
« Reply #9 on: December 08, 2017, 02:35:02 AM »
Buy Arduino Nano board, two 16->1 analog muxes 74HCT4067 or similar, 3 x 74HCT595 8-bit shift registers + 3 x ULN2003 relay drivers or similar. With a 5V Arduino you can measure the battery voltage directly using the muxes, and driving the relays using the 74HCT595 and ULN2003 is very simple. If you do not want to use relays, you can use MOSFETs instead, thus you do not need ULN2003s either.
 

Online NANDBlog

  • Super Contributor
  • ***
  • Posts: 3608
  • Country: be
Re: Need lots of I/O, what to do?
« Reply #10 on: December 08, 2017, 02:56:03 AM »
MCP23017 or MCP23S17. Because you only want to have one programmable part in your project. And they are too easy.
 
The following users thanked this post: sparksflying

Offline sparksflying

  • Contributor
  • Posts: 28
Re: Need lots of I/O, what to do?
« Reply #11 on: December 08, 2017, 03:39:37 AM »
MCP23017 or MCP23S17. Because you only want to have one programmable part in your project. And they are too easy.

I never knew these existed :o This is basically what I'm programming the other MCUs for. I just need to work out how to use them... Thanks
 

Online NANDBlog

  • Super Contributor
  • ***
  • Posts: 3608
  • Country: be
Re: Need lots of I/O, what to do?
« Reply #12 on: December 08, 2017, 04:23:05 AM »
MCP23017 or MCP23S17. Because you only want to have one programmable part in your project. And they are too easy.

I never knew these existed :o This is basically what I'm programming the other MCUs for. I just need to work out how to use them... Thanks
There are C libraries for it. Some of them will be labeled with Arduino.
To be clear, these are pre-programmed microcontrollers. And other manufacturers make similar ones too, TI, NXP just to name two.
 
The following users thanked this post: sparksflying

Online mariush

  • Super Contributor
  • ***
  • Posts: 3084
  • Country: ro
  • .
Re: Need lots of I/O, what to do?
« Reply #13 on: December 08, 2017, 05:23:41 AM »
There are I/O expanders with even more I/O pins, for example this Cypress part with 60 I/O pins, 16 of which can be configured as PWM outputs  (8 bit pwm sources) : https://www.digikey.com/product-detail/en/cypress-semiconductor-corp/CY8C9560A-24AXI/428-2017-ND/1640248

But there are cheaper solutions, like PGA9505 (40 i/o for <4$) : https://www.digikey.com/product-detail/en/nxp-usa-inc/PCA9505DGG118/568-11941-1-ND/5221872
or maybe more convenient parts like TCA6424 (24 i/o for ~1.5$ and easy to solder) : https://www.digikey.com/product-detail/en/texas-instruments/TCA6424ARGJR/296-27844-1-ND/2411683

You should also consider the one mcu per battery some more as it may simplify circuit board layout A LOT. You can probably do a circuit board with just two layers, but if you go to a 4 layer circuit board, all the savings you do with these i/o expanders may be lost.
A PIC16F1503 is 0.7$ if you buy 100 and has internal voltage reference, 10bit adc, i2c

Or you have the Silicon Labs EFM8BB10F2G , 36 cents each if you buy 100 ... 12bit adc, 16 i/o , 8mhz, i2c, smbus, spi, uart , 2KB flash , 256 bytes ram internal oscillator : https://www.digikey.com/product-detail/en/silicon-labs/EFM8BB10F2G-A-QFN20/336-3162-5-ND/5115719

You could use one of these for a set of 4 batteries since it has enough I/O, so you'd only need 5 such chips for 20 batteries.
« Last Edit: December 08, 2017, 05:29:18 AM by mariush »
 
The following users thanked this post: sparksflying

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 1355
  • Country: gb
Re: Need lots of I/O, what to do?
« Reply #14 on: December 08, 2017, 05:43:37 AM »
Why not use a micro with sufficient I/O and analog inputs to start with?  An STM32 with >20 analog and >20 digital I/O won't be very expensive.  If you don't fancy soldering the packages, then use one of the many Nucleo boards.
 

Offline fcb

  • Super Contributor
  • ***
  • Posts: 1197
  • Country: gb
Re: Need lots of I/O, what to do?
« Reply #15 on: December 08, 2017, 06:18:26 AM »
If you're familiar with the PIC - it would be madness not to use a PIC (unless you want to learn another system).  As I highlighted in my earlier post - i'd use I/O expansion.

You can build this with as little as 4 i/o (3 digital outputs and 1 analog input).

Here's how to do it with the minimum number of good old fashioned logic IC's, a few ULN2803A's and a PIC:
3x CD4051B 8:1 muxes, these are connected to your batteries to be sampled. The ABC select lines are tied together as is the analog I/O on the 4051. The enables go to the PIC seperatly.
3x CD4094B SIPO's, the 8 outputs of these connect directly to 3x ULN29803A's - these drive your relays.  Daisy chain the 4094's (see data sheet), you only need three PIC lines now.

So on your PIC you are now using:
A (mux select)
B (mux select)
C (mux select)
MUXOUT (analog input on PIC)
EN1-8 (analog 1-8 group select)
EN9-16 (analog 9-16 group select)
EN17-24 (analog 17-24 group select)
DATA (4094 data)
CLOCK (4094 clock)
STROBE (4094 load)
Total: 9 outputs, 1 input

You can reduce the pin count by 6, if you add another 4094 and use this to drive the A/B/C/EN1-8/EN9-16/EN17-24 lines, but you'll probably have plenty of I/O spare on all but the smallest PIC's. If you've got more analog inputs then you could read each 4051 and reduce the pin count by 1 by tieing all the 4051 enables high.

If you want to protect against accidental discharge, processor issues, etc.. connect all the ENables on the 4094's together and drive with whatever flavour of safety circuit you want.

Logic might be old school, but it's robust, cheap, easy to use and along with the PIC's will be around long after the PSOC's have gone EOL.
 
The following users thanked this post: sparksflying

Offline sparksflying

  • Contributor
  • Posts: 28
Re: Need lots of I/O, what to do?
« Reply #16 on: December 08, 2017, 07:21:16 AM »
You should also consider the one mcu per battery some more as it may simplify circuit board layout A LOT. You can probably do a circuit board with just two layers, but if you go to a 4 layer circuit board, all the savings you do with these i/o expanders may be lost.
A PIC16F1503 is 0.7$ if you buy 100 and has internal voltage reference, 10bit adc, i2c

I'll definitely be sticking to PIC as this project is meant to be fast and easy (Complex projects always seem to sit half done on the shelf...).

My main chip will be the PIC16F1939, 44pin TQFP. I've used it before so have the config all setup and layout ready.

As for multiple MCUs or I/O Expanders, I don't think it should matter as the I2C bus will need to join them all anyway.
 

Offline jmelson

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: us
Re: Need lots of I/O, what to do?
« Reply #17 on: December 08, 2017, 07:35:56 AM »
Serial-controlled analog multiplexers are available, such as the  MAX335.  That will solve your ADC-bus switching.  You could probably also use them to switch the gate for the power-switching transistors, too.  You probably only need 3 pins to run all the MAX335's.

Jon
 

Offline sparksflying

  • Contributor
  • Posts: 28
Re: Need lots of I/O, what to do?
« Reply #18 on: December 08, 2017, 07:42:39 AM »
Serial-controlled analog multiplexers are available, such as the  MAX335.  That will solve your ADC-bus switching.  You could probably also use them to switch the gate for the power-switching transistors, too.  You probably only need 3 pins to run all the MAX335's.

Jon

Nice, but they are like $10ea...
 

Offline suicidaleggroll

  • Super Contributor
  • ***
  • Posts: 1434
  • Country: us
Re: Need lots of I/O, what to do?
« Reply #19 on: December 08, 2017, 07:53:43 AM »
Serial-controlled analog multiplexers are available, such as the  MAX335.  That will solve your ADC-bus switching.  You could probably also use them to switch the gate for the power-switching transistors, too.  You probably only need 3 pins to run all the MAX335's.

Jon

Nice, but they are like $10ea...

https://www.digikey.com/product-detail/en/texas-instruments/CD74HC4067SM96/296-9226-1-ND/376978
$0.88 for a 16:1.  Need more than 16 channels?  Cascade them.
 

Offline RoGeorge

  • Frequent Contributor
  • **
  • Posts: 575
  • Country: ro
Re: Need lots of I/O, what to do?
« Reply #20 on: December 08, 2017, 08:11:26 AM »

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1596
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Need lots of I/O, what to do?
« Reply #21 on: December 08, 2017, 08:30:40 AM »
One other possibility is to use PSOC 4 BLE family, then you could Bluetooth the data/status to a
phone/tablet.

Attached example is single channel you could mod to 20 channels, and choose a part with the
additional I/O.

Then your main effort becomes the host side app programming.


One part does it all.


Regards, Dana.
 

Offline cdev

  • Super Contributor
  • ***
  • Posts: 2777
  • Country: 00
  • Friend
Re: Need lots of I/O, what to do?
« Reply #22 on: December 08, 2017, 11:47:04 AM »
There is no reason to use any of those fancy solutions because you only need to get a reading very infrequently.
"What the large print giveth, the small print taketh away."
 

Offline thermistor-guy

  • Regular Contributor
  • *
  • Posts: 51
  • Country: au
Re: Need lots of I/O, what to do?
« Reply #23 on: December 08, 2017, 12:18:54 PM »
...
You should also consider the one mcu per battery some more as it may simplify circuit board layout A LOT...

I have heard of this approach taken in a military battery charger, with a master mcu making sure that the slaves are performing correctly.
 

Online NANDBlog

  • Super Contributor
  • ***
  • Posts: 3608
  • Country: be
Re: Need lots of I/O, what to do?
« Reply #24 on: December 08, 2017, 08:34:13 PM »
People suggesting to buy Cypress or Maxim parts are obviously high on something.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf