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

CGMMSTICK Hardware Interface Example

CGMMSTICK Hardware Interface Example

Using the CGMMSTICK or CGCOLORMAX 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.

Miscellaneous interfacing using the prototype for the CGMMSTICK. The CGMMSTICK development prototype pictured here was used for a lot of the initial CGMMSTICK testing. 

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

It is easy to plug the CGMMSTICK 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 CGMMSTICK.

This introductory example uses a program that runs on PC/Linux/Mac as an aid to CGMMSTICK project development. The MMIDE program uses the serial port that is created when you connect the CGMMSTICK to your computer. The MMIDE program 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 CGMMSTICK. The CGMMSTICK 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 CGMMSTICK 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 CGMMSTICK 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 (from software perspective which is pin 30 on the header), the connection farthest to the right on the CGMMSTICK. The breadboard is set up so that ground runs along the blue bus bar.

Pin 9 on JP1 (the CGMMSTICK header) is ground and attaches to the ground bus on the white solderless breadboard.

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 CGMMSTICK. 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 CGMMSTICK 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 CGMMSTICK and drivers installed, or you might just be reading along to learn 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 CGMMSTICK 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. To make it the brains, all you have to add is some BASIC code that you write and then run on the CGMMSTICK.

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:


1
2
3
4
5
6
10 SETPIN 20, 8
20 PIN(20) = 1
30 PAUSE 200
40 PIN(20) = 0
50 PAUSE 200
60 GOTO 20


This can also be done without line numbers in a text editor and downloaded to the CGMMSTICK. Here is what code without line numbers may look like:


1
2
3
4
5
6
7
8
9
10
11
12
' Set pin direction
SETPIN 20, 8
 
' Repeat forever
DO
  ' Set pin high and pause
  PIN(20) = 1
  PAUSE 200
  ' Set pin low and pause
  PIN(20) = 0
  PAUSE 200
LOOP


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 CGMMSTICK to be run again later. It can even be made to run automatically when the CGMMSTICK 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 CGMMSTICK Maximite can do.

 

CGMMSTICK LED Control

CGMMSTICK LED Control

Using MMIDE it is pretty easy to set up a large group of pins to drive LEDs. The “Scroll LEDs Applet” on the Direct I/O page of MMIDE groups all 20 lines into two groups of 10. The groups can be scrolled separately.

Behind the scenes the applet code sets all of the lines to be outputs. It then lights the LEDs one by one from left to right. Then the applet turns the LEDs off one by one from right to left.

Using the MMIDE Scroll LEDS Applet to test a group of LEDs.

The MMIDE Scroll LEDS Applet lets you choose between two sets of ten pins that will light up when activated.

Solderless breadboard setup for demonstration.

The ten LEDs are contained in a single package. Plugged into the solderless breadboard you can see that they connect on one side to pins 21-30 of J1 which means that they are controlled by MMBasic commands as pins 11-20. Current-limiting resistors (330 ohm) tie the LEDs to ground.

Setting those 10 lines to output and then turning each line on and off will turn each LED on and off.

60% power remaining on warp drive.

The Scroll LEDs Applet will light the LEDs from left to right when the “11-20” button is pressed.

Using MMIDE to enter some code to control the LEDs

Setting the applet aside, you can write a MMBasic program to control these LEDs, too. This example code will light and extinguish the LEDs randomly.

Code can be entered to the CGMMSTICK using the MMBasic page of MMIDE. The following code will flash the LEDs randomly.


1
2
3
4
5
6
7
8
9
10 For a = 11 To 20
20 SetPin a, 8
30 Next a
40 a = 11 + Fix(Rnd(0) * 10)
50 b = 11 + Fix(Rnd(0) * 10)
60 Pin(a) = 1
70 Pin(b) = 0
80 Pause 50
90 Goto 40


MMBasic lines 10, 20, and 30 loop to set the I/O pins 11-20 to output. MMBasic line 40 establishes a random pin to turn on. Rnd(0) generates a random value between 0 and 1 that is multiplied by 10 to get a random number between 1 and 10. “Fix” cleans up the number by removing the fraction. The number is offset by 11 to finally be a random number between 11 and 20 for pins 11-20. MMBasic line 50 does the same thing for a random line to turn off. 60 and 70 turn off and on these lines respectively. MMBasic line 80 pauses for a twentieth of a second before line 90 forces the whole thing to repeat. When run, the program turns the 10 LEDs on and off randomly. The code can also be done without line numbers:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
' Set pins to output
For a = 11 To 20
  SetPin a, 8
Next a
Do
  ' Select two random pins
  a = 11 + Fix(Rnd(0) * 10)
  b = 11 + Fix(Rnd(0) * 10)
 
  ' Turn one on, one off
  Pin(a) = 1
  Pin(b) = 0
 
  ' Pause
  Pause 50
Loop

September 19, 2010 by robert Leave a Comment

LED Instructable using Engineering Graph Paper

This instructable “How to use an LED Array Module” uses a variation of the CircuitGizmo Engineering Graph Paper that has the pin-out for the ATmega644.

This version can be downloaded here:

https://www.circuitgizmos.com/files/enggraphmega644.pdf

This paper can be downloaded here:

https://www.circuitgizmos.com/files/projectpaper.pdf

Filed Under: Uncategorized Tagged With: AVR, Engineering, LED

  • 1
  • 2
  • 3
  • Next Page »

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 © 2021 · Generate Pro Theme on Genesis Framework · WordPress · Log in