22.09.2015 Views

of Microprocessors

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

304 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

S<strong>of</strong>tware Functions<br />

Of course, with a microprocessor-based interface, hardware is only half<br />

the batde. The fundamental s<strong>of</strong>tware job is to scan the 61 keys as fast as<br />

possible and handle any that are not contacting the upper bus (i.e., depressed)<br />

in an appropriate manner. In the fundamental program structure,<br />

time is broken into fixed length segments, and an attempt is made to do<br />

everything necessary in each time period. The most important housekeeping<br />

functions are done first and then the keyboard is scanned starting at the low<br />

end. In the rare event that keyboard activity is such that processing takes<br />

longer than a time segment, an interrupt from the timer will abort scanning<br />

and start the next cycle. Thus, the highest few keys might experience an<br />

occasional one count error in event or velocity timing under very heavy<br />

keyboard activity conditions.<br />

One <strong>of</strong> the first s<strong>of</strong>tware design steps (and in fact the first feasibility<br />

study step) is to determine how fast the scanning can be done and therefore<br />

the length <strong>of</strong> a time segment. If a straightforward scanning loop is not fast<br />

enough for adequate velocity timing resolution, then something less<br />

straightforward will be necessary.<br />

As it turns out, a simple scanning loop can test a key and go to the next<br />

if it is up in 12 f-Lsec, which means that a scan <strong>of</strong> the entire keyboard would<br />

take 732 f-Lsec. Allowing 70 f-Lsec <strong>of</strong> additional overhead for handling the<br />

timer and setting up for a scan, it would seem to be possible to complete a<br />

scan every millisecond, which is the desired resolution <strong>of</strong> key timing. However,<br />

if a key is found to be down or was down in the previous scan, then<br />

additional processing is necessary. Further study <strong>of</strong> key-down processing<br />

reveals that the time used varies from a minimum <strong>of</strong> 37 f-LSec when the key<br />

is fully depressed and held to a maximum <strong>of</strong> 100 f-Lsec when an event is<br />

queued. Thus, a time allotment <strong>of</strong> a millisecond would only cover a<br />

maximum <strong>of</strong>five fully down keys and less than that when events are queued,<br />

which is not really satisfactory. Although several courses <strong>of</strong> action are possible<br />

(2-MHz version <strong>of</strong> 6502 or external hardware to make key scanning<br />

faster), for this example the scan period will be increased to 1.28 msec.<br />

Velocity timing will therefore have a resolution <strong>of</strong> 1.28 msec, which is<br />

adequate when compared with normal variation in the velocity time differential.<br />

S<strong>of</strong>tware Flowchart<br />

An overall program flowchart is given in Fig. 9-7. When power is first<br />

applied or after a reset, all <strong>of</strong> the important program variables are initialized<br />

and then the main loop is entered. In the loop, the "time <strong>of</strong> day" is updated<br />

first taking into account the 1. 28-msec update interval and 1.0-msec time <strong>of</strong><br />

day units. Next the queue <strong>of</strong> events is checked. If an event is in the queue,<br />

then a check is made to determine if the previous event is still awaiting

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!