Getting started with Ansteron Board

1. Introduction

Welcome to Ansteron! In this tutorial, we will go through the steps to set up necessary software and create a program for Ansteron Board. There are also examples with LED, push button and Serial Interface to show you some of available functions and tools.

If you want to try these examples, you should have the following items handy:

  • You will need Ansteron Board and a USB cable.
  • One LED and one 1K resistor
  • A push button
  • A breadboard and some wire
  • A small screw driver

2. Ansteron Board

Let's get to know our Ansteron Board before we start experimenting with it.

Those marked B0 through B5, C0-C5 and D0-D7 are IO pins. The small texts in parentheses are additional functions of the each pin. There are B, C and D because IO pins are grouped and it is not usually use but your program can read or write all pins in a group at the same time.

A note on the blue wire connector: if you turn the screws down just enough, you can plug and unplug solid core wires and jumper cables as with points on the breadboard.

3. Set up software and hardware

We use Ansteron IDE to program our board; you can download from a link on software page. There are two options, a zip file and a self-extract. Download self-extract file if you don't have the software to extract zip file. Ansteron IDE is portable so you won't need to permanently install the program onto your computer. You can extract the files onto your hard-drive (or a thumb-drive if you want to bring it with you on the go) then run it from there. Look for file "ansteron.exe" in the folder and double click on that to run Ansteron IDE. You can also create shortcut on your desktop for convenience.

Let's connect Ansteron Board to your computer. On the first time, your computer will need to do driver installation and that should only take a minute or two. This installation is done automatically and it will let you know when the board is ready to work.

Once the board is ready, Ansteron IDE will automatically detect the board and you will see a message as below:

If you don't see something like that, you should double check hardware selection of Ansteron IDE by going to "Run" menu, choose "Hardware setup". Then, in the dialog, select Ansteron Board and click "OK".

4. Control an LED

There are two ways you can set up a simple circuit to drive the LED. You can directly hook-up components together or you can use a breadboard. Both ways are shown below. Note that Ansteron Board has one on-board LED connected to pin B5 by default and you can use that instead. However, you may still want to take a look to see of what the circuit look like or you can actually build the circuit to have a feel of it.

Below is schematic for a simple LED circuit. There is a resistor to limit current going through the LED. You will see the LED has 2 legs, 1 longer than the other. The longer one is positive (+) pin to be connected to pin B0 through the resistor.

Small components can directly hook-up into Ansteron board's connectors:

And on breadboard as well:

With the circuits above, when your program set pin B0 (make it "1"), the LED will light up and clear the pin (make it "0") will turn the LED off.

5. Create a simple program

In Ansteron IDE, go to menu File and select New to create a new file. The new program will have a main function by default; that is where your program starts. To blink the LED, we use two commands set_pin(PIN_B0); and clear_pin(PIN_B0);.When you do that, pin B0 will drive the circuit and turn the LED on and off. Besides, commands delay_ms(500); are added to let you see the light changes and set_pin_mode(PIN_B0,OUTPUT); is needed at the beginning to make pin B0 an output because it is input when start-up. If you use on-board LED, enter PIN_B5 instead.

In Ansteron IDE, each object is added by select one on the left toolbar, place them into main function and then enter code for each one. To edit an object, double click on it. For a complete instruction, see this article.

When the program is done, save it on to your computer. To compile, select Build on menu bar or press F7 on the keyboard. If there is any error (typing/syntax), a message will show in lower area of the screen. If the program is successfully compiled, press F5 or "Download and Run" in menu Run to download program to board and start running.

That's it! You should see the LED blinking. If not, check your circuit. The LED may be connected backward (longer leg is positive pin).

6. Connect a push button

It is a great thing when the microcontroller is able to sense the outside world. We start with a simple push button, which gives our microcontroller a signal (on or off) when it is being pressed or released. Then you can think of other sensors in the similar way. They will output some kind of signal that our microcontroller can sense and interpret. In this example, we will program Ansteron Board to turn on the LED when the button is being pressed and turn off otherwise.

The circuit below is the simplest one for a button. Signal line will be connected to pin D2 of Ansteron Board. There is a 10K resistor called pull-down resistor. When the button is pressed, it is a switch connecting V+ to signal line and it will become high (or "1"). When the button is released, signal line is disconnected from V+ and 10K resistor will keep the signal line low (or "0"). If the resistor wasn�t there, the signal line would be "floating" and our microcontroller may incorrectly read the signal.

This is the circuit on breadboard

Now, we will modify our program from the previous example. We will add a condition using function pin_is_high(PIN_D2); which will be true if the button is pressed and false if it's not. Then the program just turn the LED on or off accordingly.

7. Using Serial Interface

Serial interface is quite helpful to view data or debug your program. Serial Terminal is a built-in tool of Ansteron IDE that allows you to use this feature. To launch the utility, go to menu Tools then select Serial Terminal.

When using Serial Terminal with Ansteron Board, set port at USB and default settings then press Connect button to start monitoring serial interface.

Your program will need to enable serial interface on Ansteron Board as well before it can work. Command setup_serial(DEFAULT); will initialize serial interface with default settings, which will match the setting of Serial Terminal.

When everything is ready, your program can send a message using function serial_message(text);. To print a value of a number, use serial_print_int(number);.The example program below will send a message every second, notice "\n" at the end of the message which means enter a new line after the message was printed on the display.

This is the messages shown in Serial Terminal:

8. Using software libraries

There are many libraries that provide easy to use functions for working with different components. Each library comes in a .lib file and they can be individually added into your program. All libraries described on Ansteron website are included in "lib" folder of the latest version of Ansteron IDE.

To add a library into your program, you first create the program then in menu Build of Ansteron IDE, select Compiler settings. The dialog will show and in Additional library section of the dialog, click add button then navigate to library file. All Ansteron's libraries are in libs folder, which is in the same folder with Ansteron IDE. After the library is added, its functions will be available for use.

You can download this summary sheet of commonly used functions besides the full description on our website. It will be easier for you to look up the functions that you need while you programming. Print a copy to have it handy if you would like.

What's next

From the examples above, we hope that you have got the basic idea of how to program and use Ansteron Board. Many more libraries that provide functions for different purpose are available on our website and continue to be added. They will always be here for you to look up anytime. For beginners, there are other articles that introduce you to more topics of microcontrollers and general electronics, let's take a look!

Thank you for viewing!