GP3 Board on Sale (great for robotics and more)

GP3

The GP-3 is a powerful board that you can use with or without a PC to do many physical computing tasks. I’ve talked about this board several times in this blog including and this .

The boards are currently . This is a great chance to pick up one or more for your next project.

The original purpose for this board was to act as an I/O device for a host computer (typically a PC). An efficient serial protocol (you can use a USB adapter) allows you to read analog voltages (5 channels of 10 bit A/D), output PWM, create and read pulses accurately, and control 8 bits of digital I/O. Library support is available for nearly any language. There are ActiveX and DLL libraries that you can use from C#, C++, Visual Basic, and many other Windows languages (for example, there’s a demo that uses the board with Microsoft Excel). There’s also a generic C library that works with Linux and most other platforms too.

With the free software, you can do many tasks (like the robot example above) using no programming at all. Better still once you have a script built using GP3EZ’s easy-to-use interface, you can “compile” the script down to the board and it will run without the PC until you reprogram it. In fact, things like timing become more accurate after you compile since the PC is notoriously bad at keeping time on small scales.

These boards aren’t on sale often, so pick one up while they are. Once you have simple I/O on your PC, you’d be surprised how handy it is. And since the GP3EZ scripts can run without a PC, using just one somewhere to replace a PC in a control application will save a bundle.

Is it Basic or is it C? Its SEABASS

Personally, I like to program in C. Luckily, there is pretty good C language support for most modern microprocessors. However, if you don’t know C, its a pretty steep learning curve. Sometimes you just want to bang something out quick.

If your processor wants you to use C but you want to use Basic, you might try . Seabass is a BASIC compiler that outputs C code. So anywhere you can compile a C program (even on Linux or Windows) you can write BASIC programs. Even better, Seabass integrates with existing C libraries and you can even embed C code in your program.

The link shows an entire article about using Seabass to produce some Morse code on an Atmel AVR and a PIC. Here’s the first part of the AVR program:

include "avrio.bh"       ` get I/O routines
cinclude "app4delay.h"   ` get delay routines (from C)
#link "app4delay.c"      ` include C library

` Define a string typedef
type string char *

` Speed of a dot in milliseconds

 Const speed=200

The first line includes a basic header file (by convention, these files have a .bh extension). This is a SeaBass file (included on the CDROM) that provides some common I/O routines for the APP-IV (the target board). This line allows us to use things like HIGH and LOW to affect the I/O pins.

The second line includes a C file, not a SeaBass file. This file is one that the APP-IV kit supplies and provides an easy way to write delays. Notice the line just under this tells the compiler where to find the associated C file. If you are manually compiling SeaBass’ output, this isn’t necessary, but if SeaBass controls the build process, this will allow it to automatically bring in the correct C code that your program needs.

Type names in SeaBass have to be a single word. However, many C types use multiple words (or even symbols). For example, if you want to deal with a string, in C you use a character pointer represented by “char *”. The SeaBass DefType statement allows you to make a SeaBass type that represents a complex C type:

` Define a string typedef
type string char *

The final part of the initial part of the program sets a constant using Const. In this case, the speed value is set to 200 (this will be the number of milliseconds to delay for a dot).

Now it is very simple to understand the main code:

` Main program
function main() as int
dim text as string
dim i
text="-.-. --.-"   ` message to send
` Set LED to output
OUTPUT(B,0)

The first two lines in the function define variables (notice one of them is a string).

Here’s the main loop:

` Main code
top: for i=0 to strlen(text)-1

 ` walk through text
     if text[i]='.' then
	dot()
     end if
     if text[i]='-' then
	dash()
     end if
    if text[i]=' ' then
      space()
    end if
 next

Notice that the program uses the C library call strlen to find the length of the string. Of course, you could write a version of strlen in SeaBass, but since the C compiler already has this function, why not use it?

You can read the or look at an example . You can also play with a demo of .