|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
EDU Demo Code: Serial Data Transmitter Using a State-Machine
I've written an example software-based serial data transmitter that shows how to implement a state-machine. This transmitter can be used to send asynchronous serial data to external devices using a digital I/O pin. Though it has many uses, I specifically wrote this to send data to a serial LCD. From the header:
This software demonstrates the use of a timer and associated interrupt to precisely clock a software-based serial transmitter which can be used to communicate with other common serial devices like serial LCDs. In this example we'll setup a timer to generate an interrupt at a rate of 2400 interrupts per second. In response to this interrupt, the microcontroller will execute a specific piece of code called an interrupt handler (see user_routines_fast.c). Within this interrupt handler is a software state-machine that emulates the transmitter section of Universal Asynchronous Receiver/Transmitter (i.e., common PC serial port) running at a baud rate of 2400 bps. The output can be configured to use positive logic for communication with TTL-level serial receivers or negative logic for communication with RS-232 devices that are also compatible with inverted TTL signaling. The TTL serial port on the EDU robot controller can only signal using positive logic. This code has been sucessfully tested with Scott Edwards Electronics' (http://www.seetron.com) BPP-420VY and SGX-120L serial LCDs (other than being a satisfied customer, the author has no relationship with this company). In the zip file I've also included a PDF document that shows how the generated serial waveform should look and how each serial bit maps to a specific state of the state-machine. The code can be found here: http://kevin.org/frc -Kevin |
|
#2
|
||||
|
||||
|
Re: EDU Demo Code: Serial Data Transmitter Using a State-Machine
I've updated the ZIP file to include a RS-232 serial communications primer.
-Kevin |
|
#3
|
||||
|
||||
|
Re: EDU Demo Code: Serial Data Transmitter Using a State-Machine
Thanks for posting this!
Our electrical team actually had the idea of using an LCD for feedback -- and this will make things easier on us! |
|
#4
|
||||
|
||||
|
Re: EDU Demo Code: Serial Data Transmitter Using a State-Machine
Quote:
Of course, you're best bet is to find a LCD that can use the hardware serial ports built into the EDU controller (and presumably the full-size controller). If you want to use the dedicated TTL-level serial port, make sure that your LCD supports non-inverted TTL-level signaling. Here is an great web page that discusses the different ways to communicate with a serial LCD: http://www.seetron.com/ser_an1.htm -Kevin |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Full list of teams & competitions | archiver | 2001 | 14 | 24-06-2002 00:52 |
| Limiting PWM in pbasic | archiver | 2001 | 4 | 24-06-2002 00:38 |