CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / Input and Output / Audio and PWM Output

Audio and PWM Output

MMBasic there are a number of ways that you can use the sound output. You can play synthesized music, generate tones or generate program controlled voltages (PWM).

PLAYMOD

This command will play synthesized music in the background while the program is running. The music must be in the MOD format and the file containing the music must be located on the internal flash drive (drive A:).

The audio is high quality and MMBasic will generate full stereo on the CGCOLORMAX Maximite.

The MOD format is a music file format originating from the MOD file format on Amiga systems in the late 1980s. It is not a recording of the music (like a MP3 file) – instead it contains instructions for synthesizing the music. On the original Amiga this task was performed by dedicated hardware.

MMBasic will read this file and continuously play the music in the background while the program that launched the music will continue running in the foreground. Be aware that synthesizing music is a CPU intensive activity and uses a lot of memory and this could affect the performance of the program.

A description of the MOD format can be found at: http://en.wikipedia.org/wiki/MOD_(file_format)

A large selection of files that can be played on the Maximite can be found at: http://modarchive.org (look for files with the .MOD extension). Because the file must be located on drive A: to play it would be wise to select reasonably small files.

You can also create your own music using a tracker. For an example see: http://www.modplug.com

TONE

This command will create two tones for the CGCOLORMAX Maximite that will be outputted separately on the left and right sound channels. On the monochrome Maximite only one tone is generated. The tone is a synthesized sine wave and can be in the range of 1Hz to 20KHz with a resolution of 1Hz and is very accurate as it is locked to the PIC32’s crystal oscillator. When the frequency is changed there is no interruption in the output so the output can be made to glide smoothly across a range of frequencies.

The playing time can be specified in milliseconds and the tone will play in the background (ie, the program continues running).

SOUND

The sound command is included only for compatibility with older programs. It generates a single frequency square wave and should be replaced with the tone or PWM command in new programs.

PWM

The PWM (Pulse Width Modulation) command allows the Maximite to generate two square waves with programmed controlled duty cycle. By varying the duty cycle you can generate a program controlled voltage outputs for use in controlling external devices that require an analog input (power supplies, motor controllers, etc). he CGCOLORMAX Maximite has two channels while the monochrome CGMMSTICK Maximite has a single channel.

The frequency for both channels is the same and can be from 20Hz to 1MHz. The duty cycle for each channel can be independently set from between 0% and 100% with a 0.1% resolution.

This command uses the sound output for generating the PWM signal so the components on this output may need to be changed to allow this output to work as a PWM output.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2023 · Generate Pro Theme on Genesis Framework · WordPress · Log in