0

I´m building a system that has two arduinos (like the image on the botton) linked via ICSP. The "Programer" programs the second one, called "Worker"( with a .hex file in the SD card of the Programer).

The Worker controls a LCD 16x4 and displays messages to the user.

What I´m tring to do is when the Programmer is programming the Worker it also displays a message like "Programming, wait" in the Worker LCD. But in code, just telling to the Worker displays a message is not going to happen because when it has been programmed it displays garbage in the LCD.

Q So is it possible the the Programmer takes control of the LCD before it begin to program the worker and displays its message?

The LCD works with normal 4-bit mode comunication and I would rather not converte it to I2C if it´s possible.

enter image description here

9
  • 4-bit mode @jsotola – Dale queiroz Aug 4 '19 at 23:35
  • master / slave? – tony gil Aug 5 '19 at 1:18
  • On the ICSP - Controler master, worker slave. On the LCD the conection is made exclusively by worker (Via Hardware). @tony gil – Dale queiroz Aug 5 '19 at 2:28
  • Have you thought of using I2C for the arduinos as well? It works pretty well for me and, apparently, would work for you in this application as well. If you want, I can post an answer expanding on that. Please advise, otherwise the CONTENT POLICE will shout me down. – tony gil Aug 5 '19 at 9:48
  • 1
    @tony gil, yes i did, but for programing is way batter to use ISCP – Dale queiroz Aug 5 '19 at 13:34
2

There are two solutions that come to my mind, one more HW based and another more SW based.

Solution 1

The HW way is to let the programmer control the LCD through 2:1 multiplexer(s). You will need to connect the LCD pins to the common pin of the multiplexer, the Programmer's ones to one of the two inputs and the Worker's to the other. Then the programmer can choose who controls the LCD through the additional pin. An example of the multiplexer you can choose is the 74LS157, but there are virtually infinite part numbers. The disadvantage of this approach is that you need to write the whole LCD control stack in the Programmer.

Solution 2

An alternative, more relying on the SW, is implementing a way to let the slave know that you want to program it. For instance, when a programming is needed the Programmer raises a pin; the Worker writes the string on the LCD, then stops working, raises another pin and waits to be cleared. The programmer then proceeds to flash the Worker, and the message will remain on the LCD. It may happen that garbage exits from the Worker's pins when being programmed. If so, change the enable pin or find a way to temporarily detach it from the Worker to avoid signals reaching the LCD. This schematic illustrates this concept:

schematic

simulate this circuit – Schematic created using CircuitLab

When the Programmer wants to program the unit, it sets the DL_Req pin to high. The Worker sees this, and performs accordingly. I think pins are not moved then, but if for instance some noise appears on the signals during programming (and the LCD displays this noise as weird chars), try changing the pin associated to the enable pins (LCD2 in the example above) or put something to prevent noise on that wire only, so that LCD content is not modified.

Personally I'd go with the second solution, but this depends on how much you can change the behavior of the worker and programmer

5
  • I rlly liked the second aproach, but will not generate conflict between the boards?, because the worker needs acess to the enable pin as well, or the enable pin is set to high all the time that the worker is sending information? what i understant is to leave the enable pin to the controler and data bus and RS pin in common to both boards, right? – Dale queiroz Aug 5 '19 at 13:47
  • @Dalequeiroz no, in the second approach the Programmer does not have access to the enable or any other pin of the LCD. I'm not sure if in the programming phase the arduino pins are moved (I think only pin 13 - connected to the onboard led - is changed during programming). I will add a sort of block diagram to the answer for the second solution to explain better – frarugi87 Aug 5 '19 at 14:32
  • i liked that aproach, in this way i can control when to display the message that i what and when to activate the controller, i will try and give it a feedback, but i think it will work firne. – Dale queiroz Aug 5 '19 at 15:35
  • 1
    If you let the worker pull up the enable pin only with it's internal pullup resistor (not actively driven high), the programmer can pull it down without doing any harm, disabling the LCD. If the logic is inverse (LOW for enabled), you could do this with an external pulldown resistor – chrisl Aug 5 '19 at 19:12
  • 1
    @chrisl this is a good solution if all the Worker's pins are moving randomly during programming. Or even using a series resistor to let the Programmer decide whether to control the EN pin or not. In any case I think it will not be necessary, since usually pins remain to a stable state when programming – frarugi87 Aug 6 '19 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.