Two atmega128's with one keypad/display?

Status
Not open for further replies.

Jman 31

Member level 2
Joined
Sep 18, 2009
Messages
49
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,675
Hey guys,

I have a circuit that has one atmega128 with a typical parallel 20x2 lcd display and a 5 button keypad. I have used all of the outputs on the first atmega128 and I would like to add a second atmega128 to handle some other applications, but use the same keypad and display. Is that possible and what would be a standard hookup between the two for that kind of interface with the capability to control both IC's with the same keypad/display?

Thanks for any advice,
J
 

Dear it is not recomended to connect keypad with two devices.
Easy way is to connect KEYPAD through ADC. Only one pin will be used.
used this connection with single ATmega and rest of the ports will be free.

here is the link:
Connecting a keypad to an AVR
 
Thanks Shahbaz it is very interesting.
we will have many I/O's available in this configuration for other purposes.
 

Hi,
You could also have the keypad connected to one ATMEGA and have that ATMEGA transmit the value of the key detected through serial communication to the other ATMEGA. If you use UART, you'll need only 1 pin for that - the TX pin in the transmitter micro and RX pin in receiver micro. This is good if you want quick detection. However, the ADC method works well, given your resistor values don't stray too much.
For display you can do same thing - use UART. Or you could have a small ATTINY14 or small micro driving the LCD and have 1 pin for receiving what to write to LCD through UART. This works as well, because, then your ATMEGA will only require one pin for sending data to LCD. You could also use serial LCDs but they tend to be quite expensive.

Hope this helps.
Tahmid.
 

Thanks Tahmid, that is pretty much what I was after. I thought that that would be the way to go, but I needed to be sure. I need to gain many more pins than I would get from a serial LCD or ADC Keypad so that is why I am trying to add another atmega. The IC's won't be sharing much information other than a midi signal, but it is important that I only use the one keypad/display.

Thanks for the replys!
J
 

If you upload your circuit we could see if there are another ways of getting more free I/O lines.
 

If you upload your circuit we could see if there are another ways of getting more free I/O lines.

Thanks, but I need a lot more than we can free up. I was using multiplexing, with an atmega328 but I simplified it by using a chip with more pins. I don't want to go back to muxes if I don't have to.

HERE is a link to the schematic as it stands now, but I am going to use one chip for all of the peripherals like the "guitar to midi" portion and the "acoustic piezo inputs" (I only show one piezo input, but there will probably be about 32 on the finished schematic)
 
Last edited:

Hi,
If you need a lot more pins and don't want muxes, uses two or more micros is the way to go. UART would be a good choice as I suggested. You could use the internal UART module of the AVR and/or PIC. Use UART to transfer from master to slave and use the slave to carry out the other tasks, using the master only for control. You could use the ATMEGA as the control and send data down one wire to a slave that sends the data to LCD and senses from keypad and sends this back to the master using another wire (RX and TX used). The master does whatever control needed and sends data back to the slave(s) for more operation.

If you're interested other serial protocols you can look at are SPI, I2C(TWI). You can take a look at RS485 as well.

Hope this helps.
Tahmid.
 

The TL072 opamp will not work properly with a 5V supply. You should use a rail to rail opamp instead. You are wasting many I/O pins driving transistors. You can use one port to load a register (five in your case) and a few logic pins to controll (chip select them). This will give some additional I/O pins. Also (as posted above) using a resistive divider connected by the keys to an A/D input will bring you more pins. Up to 16 keys are feasible using 2% resistors.
 

Thanks Tahmid. Sounds like what I am after!


The TLO72 portion of the circuit works fine as designed. I borrowed that circuit from another source and have not had any problems with it's functionality. As far as why I used the transistors on individual pins the way I did, it is because I an controlling RGB LED strands and in order to get infinite color combinations I need PWM on each color of every strand. Is that possible with the method that you describe? (charlieplexing is it?)

Thanks for the advice,
J
 

Hi,
You could use a port expander for IO operation. Using MCP23S17 and 5 pins you can have 16 IO lines. For example, take a look at this:


Hope this helps.
Tahmid.
 

I suggest your using something like ... **broken link removed** or **broken link removed**
 

Thanks guys. As I said before, I am trying to stay away from multiplexing or shift registers and the like (although I may look into the port expander). I appreciate all of the comments and advice. I think we will go the route that Tahmid suggested and just use the serial communication between the two chips. I may be back though as I need to talk to the programmer and see if he can work with any of the options for expanding the single chip.

You guys Rock!
J
 

I have another question concerning this same schematic. I built a prototype with out the peripherals just for test purposes. The guy that is programming it for me is having issues getting the **broken link removed** to talk to the chip. Could someone possibly look over the ISP and Atmega128 portion of my schematic to see if maybe I made a mistake in my design? Any advice would be greatly appreciated. (I used the footprint from an atmega103 to draw the schematic, but the pinout is the same).

Here is a photo of the board:

 

When using uart or usart communication between two AVR IC's (atmega644 and atmega128 ) do you just connect TX to RX and vice versa? Or do you need any other circuitry? I can't find any schematics that do what i am trying to do.

Thanks for any advice,
J
 

Yes the UART can be connected directly, you just need to swap the pins (Tx to Rx), the level of both MCU is the same so there is no problem ,
I assume they use the same core voltage, you also have to connect the grounds too to have a common reference for the connection,
the MAX232 chip is only needed to interface with the pc which needs a higher voltage level (the gnd is also connected in that case between the pc and mcu).
If you have the option an SPI connection would be much faster.

Alex
 

I thought about doing that, but I am using the SS, mosi and miso pins for output on the atmega128. Can they be used for both or are they dedicated once you use them for SPI? HERE is a link to my latest schematic, I have it drawn for UART, but could it be used for SPI without changing any of the output pins on the atmega128?

J
 

The pins either work as I/O or SPI , you can change the operation between SPI and I/O in your code but I'm not sure if there will be a problem with the resistors
connected to the pins, it will probably work.
You also need the clock and another pin to enable the slave, this enable pin can't be connected to anything else because when you turn on/off a transistor you will also enable the slave.
Also the miso/mosi/clk with also turn on the transistors while sending the signals if they are connected to the same pins.
I think it would be complicated.

Alex
 
OK. I think I will try UART first and see if we can make that work. We will be transferring a midi signal so I hope it can handle that. Thanks a lot for the info! 8)
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…