I have a 20x4 character display part number LCD-09568 for which I have attached an Arduino Uno to via the serial output.
In my code, I setup the baud rate to 38400. The first thing I do is set the serial port to 9600. Then I send (0x12) to the display to make sure it is set to 9600. Then I wait about a second to let the display set itself up. Then I change the baud rate to 38400 by sending (0x7c) and then (0x10) to the display.
It seems to work and the baud rate does get to 38400. I am not sure though that the 9600 baud reset command I send (0x12) is working.
I found that after several power on off cycles to the Arduino board and the display, that the display looses its baud rate setting. After changing the baud rate on my code, I usually see the display come back to life at 4800 bps (weird). Once I communicate with it, I reset the baud rate to 38400 and everything is back to normal.
Now the “SerLCD v2.5” document I have says to send (0x12) when the splash screen is active. Now I am not sure if it makes it to the splash screen cycle. With exception to setting the baud rate on the Arduino board, it is the very first thing I do. So I guess it is a who boots faster, the Arduio or the display that will determine if I actually get it reset.
So, how can I reliably reset the display to a 9600 baud rate? How can I mitigate the baud rate changing on the display in the first place?
I have attached the two code files in question. “Joint_Adjust_zero.ino” is the main file. Look in the setup section for the code I described.
The other file is “Display.ino”. There you will want to see “set_display_baud”.
Ok. I have solved my problem for now. I have added a N-channel FET to pin 4 of my Arduino Uno. I’ve connected the FET to the ground on the display such that it opens and closes the connection between ground and the ground wire on the display.
Pin 4 is at high resistance during the boot up of the Arduino. This places the display in a power off condition. Once the Arduino Uno boots up and is ready to run my program, the display is still powered down. My program then power’s up the display, waits 250msec’s and then sends (0x12) command to the display to reset the baud rate to 9600kbs. My program then wait two seconds to let the display reset the baud rate to 9600.
Then I power down the display and wait 10 seconds to let the display completely power down. I then power up the display and wait 5 seconds so that the display boots up. I then configure the display for a baud rate of 38400kbs. I wait again about 1 second to let the display reset the baud rate to 38400. I am now ready to go. This is all done in “setup” and before the loop structure.
I have tried this over a hundred times and it always boots up correctly. Thus far it seems to be very reliable. This sequence and hardware change is good if you have a display whose baud rate setting is unknown or lost.
Joint_Adjust_Zero.ino (17.6 KB)
Display.ino (11.8 KB)