Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to optimise pin requirement of ATmega 128 controller?

Status
Not open for further replies.
I am making a line follower robot in which I require 20 sensors. Outputs of these sensors are digital (0V on black and +5V on white). The problem is, if I connect directly these 20 ops to ATmega 128 controller I need 20 pins. This in turn leaves lesser no of pins for driving motors and other circuitry. So what should I do? I am thinking of using some MUX or DMUX so that these outputs can be multiplexed on lesser no of pins.
 
Parallel in Serial output Shift register.
https://www.electro-tech-online.com/custompdfs/2011/09/74HC_HCT166_CNV.pdf is one example I found.
You read the serial output then strobe the clock for each successive element when you're done with the array you then just trigger the master reset (to avoid desychronization if a glitch occurs) Y ou can daisy chain as many of them as you need and I'm sure there are other similiar parts out there from different makers.
 
Parallel in Serial output Shift register.
https://www.electro-tech-online.com/custompdfs/2011/09/74HC_HCT166_CNV-1.pdf is one example I found.
You read the serial output then strobe the clock for each successive element when you're done with the array you then just trigger the master reset (to avoid desychronization if a glitch occurs) Y ou can daisy chain as many of them as you need and I'm sure there are other similiar parts out there from different makers.

I had thought about the same but I don't want any synchronization problems. In this case every time I have to strobe clock to get output of one sensor. Also in order to read one sensor output parallel data must be shifted my one place. It will be difficult to establish such synchro between input clock and clock strobe input.
 
As I stated before, there are no sync issues if you strobe the master reset after each line has been read. You read them all in series one at a time or not at all, if you want to address them individually your problem is MUCH more complicated, you'd need more micro controllers.

You could look up SPI based Digital Inputs. Same issues though.
 
Last edited:
As I stated before, there are no sync issues if you strobe the master reset after each line has been read. You read them all in series one at a time.

But how can I achieve the same? See, the IC you suggested has 8 parallel i/ps and one serial output. It also has clock i/p. So in 8 clock cycles all the data will pass serially through Q7 o/p. So, you mean to say that I should strobe master reset after every 8 clock cycles? This also means that controller HAS TO read data within one clock period of the register. This may lead to problem if controller is busy performing some other tasks(interrupts).
 
This also means that controller HAS TO read data within one clock period of the register.
How is that an issue? The MCU itself is what will provide the clock.....
If you have interrupts that overlap then that's a separate issue altogether. Even if the I/O pins are local all other interrupts will have to be disabled until the entire sensor array is read which is a multi instruction event, same with the external PISO buffer. The wait time with a PISO buffer is longer than directly reading the I/O pins, but you can only read I/O register at a time so in the case of 20 I/O lines you're looking at a minimum of 3 instructions to read it. The PISO buffer offloads the I/O lines but increase the time it takes to read them, either way you'll have to determine if your other required interrupt events will still occur, otherwise you have to use multiple pics.

If you need this degree of timing with a micro controller it gets complex fast.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top