Everything has a beginning and the phrase, "The quick brown fox jumps over the lazy dog's back." is one I first heard during my days at Keesler AFB - 44 years ago. The phrase first came up in our typing classes where it was flashed on a screen and we had to type it on those old mechanical typewriters and we had to type it perfectly. The trainer would often change the phrase slightly to try and get us confused. Later, that pangram phrase was used along with, "RYRYRY....." and "Now is the time..." to help us align the accuracy of the mechanical teletypes. An electronic device called a test-set generator should be used for aligning the timing adjustments on the old Teletype machines and punched paper tape with the same information for aligning tape readers. Mostly though, we just typed on the machines while our buddy turned a screwdriver back and forth centering the setting in the middle of the points where garble would appear on the platen. We did the manual adjustment because some prankster would always hide the testset generator.
Having the right test equipment is light years ahead of having no test equipment at all. Anyone that has ever gotten caught up in trying to resolve a serial communication problem with a microcomputer knows that these problems can be real migraine headache creators. Best practice is to do a loop-back test, but for many people this involves the use of emulator software on a PC, serial-USB adapters, and cables that may be the source of the communication problem! Owning a small, inexpensive device that can send a known good test signal and validate a loopback is invaluable in narrowing down serial communication problems and reducing hair loss.
For years, I have been using a QBF generator that I built from a PICAXE 08M2 chip with very minimal options: sending 4800 or 9600 BAUD. The original BASIC version is here if anyone is interested:
The QBF testset I am presenting in this article is made from an Arduino Pro Micro, a 32U4 based microcontroller, and not only will it send at 4800 or 9600 BAUD, it will receive at the same BAUD rate: it can send and can receive simultaneously! Doing a loopback test can now be done with one handy little piece of test equipment built for around $15. The device can even perform a loopback test on itself for sanity purposes.
The Arduino (clone) referenced from China is a common type built to compete with the Sparkfun Pro Micro. Atmel, the designer of the 32U4 microcontroller does not spec the chip for 16MHz operation at 3.3V; however, repeated testing and numerous projects confirms that the device will most likely work at the voltage. Running at 3.3V eliminates the voltage level converters that would otherwise be necessary between the microcontroller and the 3.3V GLCD. Following this simplified approach makes the wiring between the uC and GLCD a direct-connection. However, while I have never encountered an issues, I can not guarantee what the manufacturer will not. This being said, there are many, many posts in the forums on http://forum.arduino.cc/ where users attest to successful operation when temperatures are room ambident. If you feel that you must be totally compliant with Atmel specifications, both Adafruit and Sparkful have excellent articles on selecting the proper circuits for voltage level conversion.
For example: https://learn.sparkfun.com/tutorials/using-the-logic-level-converter
Looking above at the code, you will notice that the "Fox" generation is normally off; that is, nothing is being sent out from the Tx line, Pin #1 in the Pro Micro Pinouts and Connections graphic. If you wish to operate the Fox generator, you must switch Pin #4 to Gnd (ground) before powering up the unit.
The default BAUD mode is 9600 BAUD, receive or transmit. Switching Pin #6 to Gnd (ground) before powering up the unit will lower the BAUD to 4800.
Switches can be jumpers, slide switches, or pushbutton type.
Special note to UNO users: Serial1 on the Pro Micro must be changed to Serial on the UNO.
The same code that drives the Color GLCD is used for the serial receive side of this project.
Normally, one may think that
if( lFoxActive ) Serial1 << "The Quick Brown Fox Jumps Over The Lazy Dog's Back \n" ;
would be an appropriate way to write the Fox output routine. However, if this approach is taken, the Pro Micro Tx (output) will overrun the Rx (input) buffer and bad things will happen!
So, rather than sending out a long string of characters, the approach taken here is to send no more than 1 character per Loop() and always checking the receive character routine before sending another character out the port.
++ cPostn ;This variable starts at 0 and is incremented upon each time in the code, until the entire phrase is sent out the port, character by character at the selected BAUD. The maximum character transfer rate is reduced based upon the need to process the internal receive buffer and display the characters on the GLCD. When all of the characters are sent, a carriage return is then sent out the port
Serial1 << "\r" ;
and the whole process starts over when cPostn is set to 0.
QBF local loopback.
Note: The RED character is a searchable tag: see code!
Blank lines are "empty CR"
Current position seen in "flying line"
Looking at the image above of the GLCD during local loopback (sanity testing) you will notice a RED "T" at the beginning of every line. If you want to change this to any printable character, simply edit the value in the source code. For example, when using for GPS, hi lighting "$" may be useful. If you wish to disable this feature, simply use any non-printable character, such as \008.
Horizonal solid lines are lines where the cursor advanced to the first position on the line and the next character was a carriage return. Therefore, the software shows this line.
As characters are displayed, the horizontal line is "eaten away from left to right" and the line will be removed if a carriage return is received otherwise the line wraps to the next display line.
As this circuit is 3.3V, you will want to use a 10K resistor on the Rx pin (in series with sending device) if you are connecting to 5V TTL serial signals- it is not a perfect solution, but usually will work correctly unless there are long cables involved (see PDF for better solution.)
No resistor is required if you are connecting to a 3.3V device such as a GPS. The technically correct way to do the interfacing is documented here: http://www.ti.com/lit/an/swra071/swra071.pdf
The 3.3V Tx line can drive a TTL serial 5V Rx line, just connect.
If you are working with RS232 to TTL requirements, then extra hardware is required. Use Google to get other options for this level shifter (example): https://www.sparkfun.com/products/449
When powering up the unit in default mode, only the Rx feature is operating and Tx is disable. The default BAUD is 9600. When the Send Mode button is held down during powering up, the Tx and the Rx feature are both operating. If you are only using the Tx, stray signals will likely cause the display to record random characters. To avoid this, ground the Rx line. Garbage on the Rx line will affect Tx as only one can function at a time (Rx has priority to maintain the buffer level lower than overflow.)
For a round-robin test, the Tx output should go to the device under test and the return should go to the Rx. Again, ground Rx if it is not being used (that is, you wish to not receive characters on the GLCD.)
If you wish to use 4800 BAUD for Rx. Press and hold that mode button during power-up. You can also press both mode buttons simultaneously for 4800 Tx and Rx.
To test your unit, simply connect Tx to Rx and then power the unit on while holding down the Tx Mode button (pin #4 on the Pro Micro.) The modes are set by the time the Credits Screen comes on the display.