|
Building a MPC555-Based Oscilloscope
by Daniel Mihalik
Start ı Software
Description ı Oscilloscope Operation ı
Enhancement Opportunities ı Sources
and PDF
SOFTWARE DESCRIPTION
The program is simple by design. This
project is intended as a dedicated oscilloscope, so the entire programıs
main loop is devoted to waiting for the signal to begin transmission.
Features such as interrupts are not used.
The QADC can run independently of the
core to ensure that samples are taken and converted at precise intervals.
It contains an instruction queue called the conversion command word
(CCW) table, made up of 64 words, each of which contains an instruction.
Each instruction can tell the QADC to sample a pin, pause, or stop.
When activated, the QADC begins executing the CCWs sequentially. When
in Continuous Scan mode, the QADC continues until either a pause is
encountered in the queue or the main program disables the QADC.
The QADC also has a data queue called
the result word table, which stores the results from the matching
commands in the CCW table. For example, if the thirty-third entry
in the command queue is an instruction to sample AN0, then AN0 is
sampled and the result is stored in the thirty-third element of the
data queue. When the QADC reaches the end of the command queue, it
starts again from the beginning.
The program initializes the QADC by filling
the CCW table with the same instructionısample the AN0 pin (see Listing
1). Every time 32 samples are taken, the software copies the results
of those samples from the queue into the RAM to prevent them from
being overwritten when the QADC loops around.
| Listing
1ıThe C program for the MPC555 reads data from the AN0 pin and sends
it to the computer through the serial port. |
The SCI is a part of the queued serial
multi-channel module (QSMCM). Data is written into the data register,
automatically serialized, and sent out the serial channel. The software
checks the status of the data register to make sure that itıs clear
before writing the next byte to it. while(QSMCM.SC1SR.B.TDRE ==
0); tells the program to wait in a loop until the register is
clear. This prevents data from being written from the buffer to the
data register faster than it can be sent out the serial port.
The other half of the oscilloscope is
implemented on a personal computer, with the front end developed with
Visual Basic (see Listing 2). This front end uses the MSComm object
for communication, which handles communication through the COM1 port.
It has a function that runs automatically when activity is detected
on the serial port and is used to handle receiving information from
the MPC555. The graph is made using the picture box object. Lines
are drawn from one point to the next until the graph is completed.
| Listing
2ıIn order to use Visual
Basic code, you will have to create your own dialog box, similar
to the one shown in Photos 1 and 2. |
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ıCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |