Description: The circuit consists of a PIC microcontroller, an in-circuit serial programming (ICSP) interface, an RS232 level translator, and an HD44780 LCD display. Initially, a scrolling message is shown using the show_intro function. When a serial input is detected, the main program commences. All keys are designated for either text entry or commands. An infinite loop continuously checks for key input. If the key is a hash symbol, the command is retrieved using the function get_prefix_and_execute_command(&x, &y). Otherwise, the key value is displayed on the LCD at the current cursor position.
Note: The use of x and y addresses (&x, &y) allows for passing the variable addresses to the called functions, enabling updates to the values of x and y in the main program through pointers. The get_prefix_and_execute_command function invokes execute_command, which retrieves another key from the UART (or waits for one). If the key matches a valid command, the corresponding code is executed to control the LCD. If it does not match, the UART1_unget_char function is employed to push the key back. Notably, the commands #X and #Y in execute_command utilize get_and_Set_X and get_and_Set_Y, using pointers without the need for address dereferencing, as px is a pointer returning its address when called. These functions invoke get_2dig_num, which expects more characters in the form of digits; if digits are not received, the key is pushed back using UART1_unget_char. The UART1_get_char and UART1_unget_char functions are complementary and are utilized in parsers (this program functions as a simplistic parser) to examine the next character of the input. If the character is not the expected one, UART1_unget_char is employed to store the current character in memory. The UART1_get_char function checks this memory first before retrieving a character from its standard input, ensuring effective operation. However, only one character can be ungotten at a time; for handling more, an array for unget storage would be necessary. These routines simplify the process by avoiding complex look-ahead algorithms or indexing, allowing a focus on the current character without needing to track an index. For a more extensive parser, the focus would shift to handling complete words.
The described circuit integrates various components to facilitate user interaction through a serial interface and an LCD display. The PIC microcontroller serves as the core processing unit, executing commands based on user input. The ICSP interface allows for programming the microcontroller, enabling updates and modifications to the firmware as needed. The RS232 level translator is crucial for ensuring compatibility between the microcontroller's logic levels and the serial communication standards.
The initial scrolling message displayed on the HD44780 LCD serves as a user interface element that provides feedback and informs the user about the system's status. Once user input is detected, the system transitions into a command processing mode where it can accept both textual input and specific commands, enhancing its functionality.
The infinite loop structure ensures the system remains responsive to user input, continuously checking for key presses. The use of a hash symbol as a command initiator allows for a clear distinction between standard text input and command execution, streamlining the user experience. The command retrieval process employs pointers to manipulate the values of x and y, facilitating dynamic updates to the system's state based on user interactions.
The UART communication functions enhance the program's ability to manage input effectively, allowing for a robust parsing mechanism that can handle unexpected characters gracefully. The design emphasizes simplicity and efficiency, with a focus on maintaining a responsive and user-friendly interface. These characteristics make the circuit well-suited for applications requiring real-time user interaction and feedback through a visual display.The circuit simply consists of a PIC micro, ICSP interface, an RS232 level translator and an HD44780 LCD. Initially a scrolling message is displayed using show_intro. When a serial input is detected the main program starts. All keys are now either text entry or commands. An infinite loop keeps checking for key input. If the key is a hash symbol then the command is fetched using: get_prefix_and_execute_command(&x,&y); Otherwise the key value is displayed on the LCD at the current cursor position.
Note: the use of x and y addresses (&x,&y) to pass the variable address through to the called functions so that values of x and y in main() are updated (using pointers in the called functions). get_prefix_and_execute_command calls execute_command which gets another key from the UART (or waits for one).
If it matches a valid command then the appropriate code is executed to control the LCD. If not then UART1_unget_char is used to push the key back. The most interesting commands in execute_command are #X and #Y which use get_and_Set_X and get_and_Set_Y, again using pointers (this time the address & de-reference is not used as px is a pointer that returns its address when invoked). These functions both use get_2dig_num which gets more characters expecting digits - if it does not get them it pushes the key back again using UART1_unget_char.
UART1_get_char, UART1_unget_char These complementary functions are used in parsers (this program is a very small parser) where you need to look at the next character of the input to see if you want to continue. If you don't i.e. its not the character you were expecting then you use UART1_unget_char to put the current character into memory.
The function UART1_get_char always checks this memory first before getting a character from its normal input so the system works well - but you can only do one unget-char at a time. For more you would need an array of unget storage etc. The routines let you avoid complicated look ahead algorithms or indexing - you can concentrate on the current character without knowing where an index is.
Connect the serial cable to the serial port. If using a USB to TTL, RS232, or serial converter, plug it into the USB port. Next, short the Tx pin to the Rx pin or the TxD pin to the RxD...
A relay can be controlled using a PIC microcontroller. The circuit illustrates how to control a single relay with the PIC 16F628. When the RB5 port of the PIC is set to high, the relay will activate. This circuit is...
The objective of this project was to develop a front-end for Commodore 64 emulation utilizing VICE. A significant challenge with emulators, particularly for devices from the 1980s, is the absence of a standardized keyboard layout. In this project, a malfunctioning...
The project we have chosen as our example is an RS232 to RS485 converter. This is a often needed device which can demonstrate a lot of principles of circuit design, and hopefully the finished project will be useful to some...
This project enables a PIC microcontroller to play audio PCM sounds using PWM modulation. Pulse-code modulation (PCM) is a digital representation of audio signals.
The project utilizes a PIC microcontroller, which is programmed to generate audio signals through pulse-width modulation (PWM)....
The ADM3251E is a transceiver that features high-speed operation, 2.5 kV full isolation, and a single channel for RS-232/V.28 communication. This device operates from a single 5 V power supply.
The ADM3251E transceiver is designed for robust communication in environments where...
To connect a microcontroller project to the COM port of a PC, an RS-232 converter is required. Various chips are available to address this need, such as the MAX232 and DS275.
The RS-232 standard is widely used for serial communication between...
The PIC Microchip Processor must be programmed before it will function as a Volt & Amp meter. There are many internet sites and PIC programmers that you can use. I used a Microchip MPLAB ICD 2 during the project. You...
A PIC-based inverter circuit is being developed that utilizes two P-channel MOSFETs (F9540N) along with a center-tapped 12-0-12/230V transformer.
The proposed circuit design incorporates a microcontroller from the PIC family, which serves as the main control unit for the inverter operation....
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more