To MCU or not to MCU

Discussion in 'General Electronics Chat' started by sirch2, Feb 9, 2014.

  1. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    I am planning a project that has 4 ultrasonic transducers. I want to connect them alternately to act as transmitter and receiver. So assuming there are two pairs A-B and C-D I want to have A transmit and B receive and then B transmit and A receive and then do the same for C-D.

    I am using a micro-controller for the project but the MCU is doing other things and I am running out of pins to drive/receive the ultrasonics. Apart from getting an MCU with more IO pins (which I don't want to do for a variety of reasons) one obvious answer is to use a second MCU.

    But.. it kind of feels like there ought to be a neat solution to switching over the transducers without another MCU but anything I can think of has a higher component count and costs more.

    So is there a simpler way of doing it?
     
  2. crutschow

    Expert

    Mar 14, 2008
    13,006
    3,232
    Options to increase I/O pins are to add a serial-in parallel-out shift register, an addressable latch, or a multiplexer. How many spare pins do you have available on the MCU and how many independent signals do you need to generate at the output?
     
  3. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    Thanks for the reply, ideally I'd like to use 4 pins, one to generate the ultrasonic, one to receive the signal, one to control which transducers are selected and one (a bit bizarrely) to monitor the ultrasonic drive pin.

    I am aware of shift registers, mux's etc. but they all seem to have a higher component count than just one more MCU. 4 transducers can be connected to 4 pins with 4 more pins to monitor the u-sonic drive.

    The whole thing seems to be something that could be done with a few mechanical switches so it feels like there must be a clever solution...
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,387
    1,605
    I do hope you realize that while you may be able to drive the transmitter direct off a micro's pin the receive signal is very low and will need amplification. That amp makes it harder to turn the sensors around, and I'm at a loss what extra information that will provide.

    There is an ultrasonic sensor board called "ping)))" that in at least one implementation only needs 1 pin to enable it and take the reading, but it does require you to time pulses.
     
  5. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    one 16f59 does the trick.

    it has 30 IO.

    You can use a 4bit parallel port via IO from the master MCU.

    So you just put a command, and dont need all the efforts for a software serial port.

    Or a 16f1824- upto 32 MHz, and hardware serial port.

    Both const only $1.
     
  6. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    ErnieM- yes I am aware of that. But imagine I have a 2 pole 4 way rotary switch I can arrange that so that in one position A is connected to the drive pin and B is connected to the amplifier, then next position B is connected to the drive pin and A is connected to the amplifier. This is for an ultrasonic anemometer so the speed in the direction A-B and B-A will be different in a moving air flow (upstream is slower than downstream).

    takao - yes there are plenty of chip options but I already have a design that I want to use for logging the data and I don't have the time or inclination to redesign the whole thing.
     
    Last edited: Feb 10, 2014
  7. takao21203

    Distinguished Member

    Apr 28, 2012
    3,577
    463
    it would not take me long since i have exp. with it, but it can take considerable effort to use multi-mcu for the first time.
     
  8. Potato Pudding

    Well-Known Member

    Jun 11, 2010
    684
    92
    Adding another MCU is a great choice in most cases where it feels like an option.

    It forces breaking a project down in modules that will be easier to develop and troubleshoot.

    It increases your processing power without the problems of dealing with a higher clock speed where everything matters in terms of capacitance and inductance.

    2 cheap MCU's often provide a Cost Benefit advantage over one higher power MCU.

    Two lower pin count MCU's with wider traces are often less trouble to manufacture than one MCU with 100 pins at 0.5mm pin pitch. This is not nearly as much of an advantage as it used to be, but for a hobby or prototype project it can be important.
     
  9. Potato Pudding

    Well-Known Member

    Jun 11, 2010
    684
    92
    It is a skill worth developing.

    For abstracting some sensors like this project would use them for, I would guess that multi MCU's will make things much easier.

    The ultra sonic sensor arrays should be worthy of their own MCU.
     
  10. Gibson486

    Member

    Jul 20, 2012
    199
    12
    Whenever I am in such a situation, I just add another MCU. I do not work in at a place where adding $1 to a BOM is killing anything, so I might as well add the thing that makes it easier and more flexible. I would imagine PIC has some chip that can do what you want for VERY cheap...like .90 cents. If you want an easier programming experience, just get the Arduino Uno chip. The chip is $2.50 and you will probably be up and running in 10 minutes.
     
  11. sirch2

    Thread Starter Well-Known Member

    Jan 21, 2013
    1,008
    351
    Thanks guys, looks like it's another MCU then.
     
Loading...