Making Music with the CMDO™

First we need a device that is capable of making a sound. We choose the piezoelectric transducer. Transducer means a device that translates one form of energy to another.

There is this crystal material (quartz) that will produce a small amount of electricity if you squeeze it, step on it, or hit it with a hammer. The same crystal, if you grind it flat, will bend or flex when you apply electricity to it. By flexing this piece of material at an audio rate an audible sound is produced. This is what a “piezoelectric transducer” does.

Piezoelectric means electricity from squeezing. The Greek word “piezo” means to push. Electric comes from the Greek word, “elektron”, and means amber. Static electricity was discovered in 600 BC by the Greeks when they found that rubbing fur on amber, a piece of fossilized tree resin, could make static electricity capable of attracting small light objects and holding them.

The piezoelectric crystal was discovered in 1880 by Pierre Curie, husband of Marie Curie. Later they used the piezoelectric effect to study radiation. The crystal properties he discovered have become the bases for the “crystal” oscillator that produces the clock pulses that computers use. It’s also the material that produces the shrill beeping sound you hear when a smoke detector goes off. We will use one of these to enable our micro-controller to produce a sound.

The CMDR™ Android App
The CMDR™ app has 6 screens:

  • Program Screen – Name a sub-routine and assign it a numbered address.
  • Sub-program Screen – Edit command lines to perform a function.
  • Data Screen – Access Data Memory and assign values to the program.
  • A Control Screen – Remote control the CMDO™ micro-controller board.
  • A Button Screen -Define the buttons used on the Control Screen.
  • A Download Screen – Access resources from the website.

The CMDO™ Micro-Controller Board

The micro-controller has 14 I/O ports that can be used to interface to many devices, such as: LEDs, Piezo Beepers, Servo Motors, Remote Switches and Motor Drivers. It can also receive input from sensors such as: Temperature, Pressure, Moisture, and Light. In addition to these I/O ports the controller also has built-in functions such as: Timers, Oscillators, Serial Communications, Analog-to-Digital Converters, and Digital-to_Analog Converters which can be routed to the I/O ports for use. The micro-controller is remarkably versatile.

CMDO™ Loops
The CMDO™ board is bluetooth enabled and is paired with an Android Phone or Tablet. The hardware is pre-programmed and has 3 modes of operation: Listen Mode, Demo Mode, and Command Mode. When the board is in “Listen Mode” it continuously listens to the bluetooth interface for commands. In “Listen Mode” the CMDO™ can be placed in Demo Mode, Command Mode or be given new Demo and Command programs to run. The CMDO™ automatically returns to Listen Mode after performing a Demo or a Command.

Another way to describe it is to think of it as continuously looping through its Listen Program. When in Demo Mode, it includes branching to the Demo Code as part of that loop. When in Command Mode, it includes branching to the Command Code as part of the loop. For this reason, I frequently use the term “Loop” in place of the term “Mode” in describing the board’s function.

The “Demo Loop” begins at line 0x380 of the main program. A demo allows you to quickly program a function and see how it works or, in the case of a beginner, if it works. The board can only be placed in the “Demo Loop” from the “Launch” menu on the “Sub-Routine” screen. To exit “Demo Loop” choose “CMDO™ Reset” from the Launch Menu. The “Demo Loop” is for beginners and allows a person to write simple programs in assembly language.

The “Command Loop” is for interactive commands and remote control. It begins at line 0x0400 of the main program. Anytime you press a button on the control screen the board automatically enters the command loop and executes all the subroutines stored there. Using the command interface is easy and requires no programming skill. However, programming the “Command Loop” is for intermediate and advanced users.

Micro-Controller Peripherals
Micro-controllers do more than store and run programs. They also come pre-configured with small electronic gadgets called peripherals. It has timers, pulse-width modulators, audio oscillators, voltage references, analog-to-digital converters, temperature sensors, serial communications, and more. Generally when an engineer selects a micro-controller, the need for certain peripherals is driving the choice. The inclusion of a wide variety of peripherals is the primary distinction between a micro-processor and a micro-controller.

The Numeric Controlled Oscillator Peripheral
The NCO is a built-in peripheral that can output an audio frequency. The micro-controller gives the NCO a clock pulse, a 16-bit number, and an enable command. The NCO then outputs an audio tone. The NCO is separate from the program and will output a tone until told to stop.

Let’s learn how to use the NCO.

Using the Demo Loop to make Sound

0380;   DEMO_LOOP; 301A; MOVLW 0x11; 4-C (MiddleC)
0381;            ; 0029; MOVLB 09;
0382;            ; 171E; BSF NC0CON, 0x06;
0383;            ; 0029; MOVLB 09;
0384;            ; 009B; MOVWF 0x1B; NCOINCL;
0385;            ; 0008; RETURN;