Monday, January 30, 2012

Maximite Hardware Interface Example

Using the CGMMSTICK1 might be very familiar or easy to understand for you, or you might be very new to all of this. Don't worry about the first examples here if you are new to all of this. This document does assume that you have some hobbyist-level familiarity with electronics and also familiarity with the BASIC language. However, by the end of this document, you should be familiar enough with the workings of the CGMMSTICK1 to feel confident that you will be able to program and utilize the CGMMSTICK1.

Before getting into greater detail on the Maximite hardware, software, and the workings of the CGMMSTICK1, I'd like to whet your appetite for the Maximite with a simple example.

Misc interfacing using the prototype for the CGMMSTICK1. The prototype pictured here was used for a lot of the initial CGMMSTICK1 testing.

It is easy to plug the CGMMSTICK1 into a white solderless breadboard and connect a USB cable to a PC to control the Maximite. This example demonstrates connecting an LED to one of the interface lines of the CGMMSTICK1.

This introductory example uses a program that runs on PC/Linux/Mac as an aid to CGMMSTICK1 project development. The MMIDE program uses the serial port that is created when you connect the CGMMSTICK1 to your computer. MMIDE can be used as a terminal, as a way to transfer files, and to assist in hardware/software development.

CGMMSTICK1 mounted in positions 1-30 of the author's solderless breadboard.

The picture shows a solderless breadboard that is set up with the CGMMSTICK1. The CGMMSTICK1 is plugged in to the solderless breadboard so that the numbered pins correspond to the numbers on the long connector. The 20 input/output lines of the CGMMSTICK1 are the connections on the right side. Ground, 3.3 volt, and 5 volt connections are some of the remaining pins on the right.

The electrical hardware used for this very simple example is a single LED and 330 ohm resistor. One CGMMSTICK1 output line is connected to the LED, and the resistor connects the other end of the LED to ground.

LED connected between I/O line #20 and a resistor (330 ohm) that goes to ground.

The picture shows the solderless breadboard with the LED example circuit. The I/O pin chosen was pin 20, the connection farthest to the right on the CGMMSTICK1. The breadboard is set up so that ground runs along the blue bus bar.

MMIDE - Select serial port and then click the Direct I/O page.

Normally your developed BASIC code would be run to turn this LED on and off. But before doing that, the MMIDE development tool can be used to verify the LED circuit. Run MMIDE and select the appropriate serial port for the CGMMSTICK1. Select the page tab to select the Direct I/O page.

Use the Blink LED Applet to test the LED that you have connected.

On the Direct I/O page you can see a little application called the “Blink LED Applet”. There are only two things to do to run this applet. First you select the I/O port connected to the LED. The little applet defaults to I/O pin #1, but can be changed to any of the 20 I/O pins.

In this example the I/O port used for the LED is port #20. Port #1 is the default when you first run the program, just select “20” from the drop-down menu.

After you have selected the port, press the “Blink” button. Your LED should start blinking. If it doesn't, recheck your circuit. One common problem is a reversed LED – just flip it around.

If you press the “Blink” button a second time, the LED blinking will cease. MMIDE sends commands directly to the CGMMSTICK1 in order to make this little applet work. The applet sets the port line to be an output port, and then sends commands to turn that line on and off over and over. When done, make sure that you turn the blinking LED off.

I'll mention again here that you might have wired up the LED circuit and could be clicking along with these instructions if you already have the CGMMSTICK1 and drivers installed, or you might just be reading along to see what this version of a Maximite can do. The setup/installation process will be talked about in more detail later.

So you've just tethered the CGMMSTICK1 to your computer, added a simple LED circuit to it, and controlled that LED with MMIDE. But now what? Isn't the little Maximite supposed to be the brains, not a big old computer running MMIDE? It is. And to make it the brains, all you have to add is some BASIC code that you write and then run on the CGMMSTICK1.

LED blinking BASIC program

If you return to the MMIDE page tab that says “MMBasic” you will be connected to the Maximite in a mode where you can type in your BASIC programs. This BASIC program in this example will do essentially the same thing as the MMIDE Applet did. Here is the program for you to enter:

10 SETPIN 20, 8
20 PIN(20) = 1
30 PAUSE 200
40 PIN(20) = 0
50 PAUSE 200
60 GOTO 20

You can run the program by entering the command “RUN” or you can click the green Run button. If you have entered the program correctly, the LED should be blinking while the program is running.

You can stop the blinking by typing Control-C or by clicking the red Stop button in MMIDE.

You can look up the commands in the program to see in detail what the program does at each step. In short, the program does about the same thing that the MMIDE “Blink LED Applet” does. The BASIC program sets the line (20) to be an output line, turns the line on, waits a little, turns the line off, waits a little, and then repeats.

This program can be saved to memory on the CGMMSTICK1 to be run again later. It can even be made to run automatically when the CGMMSTICK1 is powered up, so you would then have a fancy and overly sophisticated LED blinker. This fancy and overly sophisticated LED blinker has given you a good taste of what the CGMMSTICK1 Maximite can do.




Purchase a CGMMSTICK1

Download of Maximite Integrated Development Environment: MMIDE

No comments:

Post a Comment