Posts | Comments

Planet Arduino

Archive for the ‘training’ Category

As we work on projects we’re frequently upgrading our tools. That basic soldering iron gives way to one with temperature control. The introductory 3D printer yields to one faster and more capable. One reason for this is we don’t really understand the restrictions of the introductory level tools. Sometimes we realize this directly when the tool fails in a task. Other times we see another hacker using a better tool and realize we must have one!.

The same occurs with software tools. The Arduino IDE is a nice tool for starting out. It is easy to use which is great if you have never previously written software. The libraries and the way it ties nicely into the hardware ecosystem is a boon.

When you start on larger projects, say you upgrade to a Due or Teensy for more code or memory space, the Arduino IDE can hamper your productivity. Moving beyond these limitations requires a new, better tool.

Where do we find a better tool? To begin, recognize, as [Elliot] points out that There is no Arduino “Language”, we’re actually programming in C or C++. We chose which language through the extension on the file, ‘c’ for C and ‘cpp’ for C++. An Arduino support library may be written in C or C++ depending on the developer’s preference. It’s all mix ‘n match.

Potentially any environment that supports C/C++ can replace the Arduino IDE. Unfortunately, this is not easy to do, at least for inexperienced developers, because it means setting up the language tool chain and tools for uploading to the board. A developer with that much experience might eschew an integrated development environment altogether, going directly to using makefiles as [Joshua] describes in Arduino Development; There’s a Makefile for That.

The reality is the Arduino IDE is not much more than a text editor with the ability to invoke the tools needed to compile and download the code to the Arduino. A professional IDE not only handles those details but provides additional capabilities that make the software development process easier.

Eclipse CDT & Arduino Plug-In

Eclipse IDE

An alternative to the Arduino IDE is Eclipse, a development environment used by professional and hobby developers. It’s open-source software and extensible via plugins. Many developers have contributed to its development, including some with corporate support.

Eclipse based Arduino development uses two additions to the basic Eclipse IDE. One is the C/C++ Development Tooling (CDT). The CDT not only adds the C/C++ development capability but tools for automatic code completion and insertion, and also some code refactoring. Trust me, once you understand how to use these capabilities you’ll miss them dearly when not available.

The other addition is a plug-in developed by [Jantje Baeyens]. The plug-in is free and open-source.

This setup works in combination with the build environment for the Arduino IDE. You still need the IDE installed; you just don’t have to use it.

Earlier this year I installed Eclipse Luna with the plug-in and the Arduino 1.6.0 IDE while running Ubuntu 14.04. I just followed the installation directions on the Eclipse and plug-in sites and it went smoothly. Since then [Jantze] released a version of Eclipse Luna with the latest version of the plug-in pre-installed. I downloaded it and the 1.6.5r5 Arduino IDE recently. It works fine and installing updates for the plug-in is handled automatically by Eclipse.

When making a switch like this you need to know both where the current tool is inadequate, how the new tool addresses those limitations, and what additional benefits will accrue. We’ll address the limitations and how they are addressed first, and then the added benefits.

Arduino IDE Limitations

 

Editor Tabs

When projects get larger they obviously have more lines of code. Having hundreds or thousands of lines of code in a single file is a nightmare. Scrolling through that large a file to find a single line of code is time consuming. That is why compilers support splitting code into multiple files. Moving between editor windows is far easier than scrolling.

The Arduino IDE supports multiple files by adding more tabs. If you use INO files you’re only adding one at a time, but if you use C/C++ header and source files it’s two at time. With the Arduino IDE all the files have to be in open windows in order to be processed by the compiler. Sooner or later you run out of space across the top of the screen for more tabs.

eclipse project explorerMy 23″ monitor supports around 18 tabs and my 19″ side monitor about a dozen. Tabs for additional files scroll off to the right. They can be reached using Ctrl-ALT-Right, or through a drop down list on the right, which is cumbersome to use. To add insult, on my Ubuntu system the Ctrl-ALT-Right is used for changing workspaces so cannot be used for changing tabs.

Eclipse also uses tabs but they are only involved with editing. The files for a project are listed in a Project Explorer sub-window. Any file can be opened in the editor and closed when the editing or viewing is done. Having only the files open pertinent to your current activity reduces distractions. Eclipse also allows access to multiple projects to be available at the same time. This is useful if you want to get code snippets for your current project from an older one, or if you are working on two Arduinos that cooperate with one another.

Compilation Speed

The Arduino IDE copies every file to a temporary directory as an early step in the build process. This forces the build environment to see every file as changed, which in turn means the files are all compiled.

Under Eclipse the build does not move the files. The tool chain recognizes that once a file is compiled it does not need to be compiled again until a change is made in the source. In extremely large commercial projects this can literally save hours of time. Even in large hobby projects the time savings can be substantial.

Hunting for Errors

The console at the bottom of the Arduino IDE displays the compilation process and the errors that occur. The errors are listed with the file, line number, and the column of the error:

somefile.cpp:11:3: error: expected '}' before 'else'

To fix the error you need to find the file – ouch! if it’s on the drop down list – and then find the line in the file. This is time consuming.

Eclipse reports errors in two ways. The first is a console window similar to the one for the Arduino. The difference is you can click on an error and be taken to the line of code. Eclipse will even open the file if it’s not currently active in an editor. A real time saver.

The second is a list of errors in a “Problems” window stripped of all the compiler gobbledygook. Reading this list is much quicker than either IDE’s console window. By scanning the list you may see that the reported error is not the error that needs to be fixed. Sometimes errors, typos for example, are reported in multiple locations but the correction is elsewhere. The console window is still important because it provides the additional information that is sometimes needed to understand exactly what is causing the problem.

problem window

Terminal Annoyance

An annoyance with the Arduino IDE is the need to shut down the serial port terminal when you want to upload new code. The Eclipse solution manages this while keeping the terminal window open.

Note: This appears to have changed from the 1.60 to the 1.6.5 version of the Arduino IDE. If you are working with an older version and sticking with the Arduino IDE you should upgrade to the latest.

Eclipse Enhancements

Eclipse provides enhancements in addition to the improvements discussed above. Some of these are capabilities you don’t realize you need, but will love once you have them.

new class dialogCode completion is a simple enhancement that saves keystrokes and prevents errors by adding closing braces, quotes, brackets, parentheses, etc. This reduces errors due to omissions, and helps keep code better organized. (You do put braces around your if-clauses, don’t you? Apple didn’t, which created a security hole in their SSL processing, although there were a number of other problems with that code.)

As you’re working you often realize the name of a function, variable, or class is not exactly right. It needs to change. Hunting down a name in multiple files is daunting so you just let it go. Eclipse allows you to select a name, tell it to make the change, and all the occurrences will be changed.

Adding a new class requires creating new header and source files. A wizard does this for you. You enter the class name, a base class name if needed, and select if you want the constructor and destructor created. The files are created with skeleton source code and added to the project.

Wizards also can create new source or header files.

Creating the body of a function or class member is also automated once the function is declared. You first create the declaration in the header file:

 int something(const int a); 

and then you right click, select ‘Source’ and ‘Implement Method’. A skeleton definition is inserted into the source file:

int something(const int a) {
}

This is especially handy when the function has a long list of parameters.

Often you realize that some lines of code would be better as a new function. This may be so they can be reused in other locations, or just to simplify the flow in the current location. Lifting the code into a new function just requires selecting the code, right clicking, selecting ‘Refactor’, and ‘Extract Function’. A wizard opens for you to approve the new functions parameter list and when you accept this a call to the function replaces the lines and the new function is created.

To illustrate, one set of the duplicated code in loop() can be extracted into a function, outPins, and the duplicate code can be manually replaced with a call to the new function. Not an earth shaking example, admittedly, but it demonstrates the possibilities. The code starts as:

void loop() {
	static unsigned char cnt = 0;
	static bool state = false;

	analogWrite(pin09, cnt);
        
	// code to extract to make new function
	digitalWrite(pin11, state);
	digitalWrite(pin13, state);
	delay(blink_time);

	state = !state;

	// duplicate code
	digitalWrite(pin11, state);
	digitalWrite(pin13, state);
	delay(blink_time);
}

and after the refactoring becomes:

void loop() {
	static unsigned char cnt = 0;
	static bool state = false;

	analogWrite(pin09, cnt);

	outPins(state);
	state = !state;
	// replace next three lines with outPins(state);
	digitalWrite(pin11, state);
	digitalWrite(pin13, state);
	delay(blink_time);
}

and after a little cut and paste loop() becomes much simpler and maintenance of the lines now in outPins() is easier:

 
void loop() {
	static unsigned char cnt = 0;
	static bool state = false;

	analogWrite(pin09, cnt);
	outPins(state);
	state = !state;
	outPins(state);
}

Many of these capabilities are refactoring of code, a complex topic that is well worth studying if you will be working on larger projects. The techniques involved improve your code organization without changing the operation.

Caution: Eclipse will make the change you ask for so be sure you have it right. Fixing a massive automatic change can be a nightmare. Been there, done that.

This is just an overview of the advantages of using Eclipse in larger projects. If you are familiar with Eclipse chime in with other capabilities in the comments.

Plug-in Niceties

plugin dialogAll the above is what Eclipse brings. The Arduino plugin also provides a dialog that gives you control over the development parameters by replacing the Arduino IDE drop down menus. You no longer have to go to the menu to first select the board and then go back up to select the port. Also, the dialog allows you to specify compiler options that are buried down in a configuration file with the Arduino IDE. For instance, you can change from the standard optimizing for space to optimizing for speed.

An addition the plug-in brings is an ‘oscilloscope’ graphing window that displays properly formatted data as a curve. This is good for seeing how sensors are reacting to the environment.

Wrap Up

I’ve switched completely to using Eclipse for my Arduino projects. I was already comfortable with Eclipse for other projects so it felt good returning to it for the Arduino. The refactoring and auto-code completion were sorely missed and the other features are icing on the cake.


Filed under: Arduino Hacks, Hackaday Columns, Raspberry Pi, Software Development
Apr
22

Practice Your Service Return With This Arduino-Powered Automatic Ping-Pong Ball Machine

arduino, General, Maker Faire, Ping Pong, sports, table tennis, training Commenti disabilitati su Practice Your Service Return With This Arduino-Powered Automatic Ping-Pong Ball Machine 

ping-pong-ball-machineFriction wheel mechanism, frame made of VEX Robotics Design System components.

Read more on MAKE

Dic
11

Yellow Plane 2 with Inverted V Tail

arduino, Flying, FPV, gallery, gyro, plane, RC, remote control, Remote Control (Invention), stability, training, xBee Commenti disabilitati su Yellow Plane 2 with Inverted V Tail 

 

[nickatredbox] keeps up to date with the improvements of his project [yellow plane]. As you can find on this blog, the project is evolving week by week. Let’s see what’s today submission

1200 mm Wing space
280 mm cord
14% Clark Y
Target AUW 1300 Grams

Missing battery and camera box have a design which should weigh 140 grams empty.
The assembly shown below weighs 684 Grams no motor or electronics.
Electronics shown weigh 110 grams ESC Arduino board, Xbee, antenna and Gyro board
Motor & prop another 120 Gram

Here you have a [video]  and there you can follow the project on the [website]

Introduction

There are many types of microcontrollers on the market, and it would be fair to say one of the two most popular types is the Microchip PIC series. The PICs are great as there is a huge range of microcontrollers available across a broad range of prices. However learning how to get started with the PIC platform isn’t exactly simple. Not that we expect it to be, however a soft start is always better. There are some older books, however they can cost more than $100 – and are generally outdated. So where do you start?

It is with this problem in mind that led fellow Australian David Meiklejohn to develop and offer his PIC Training Course and Development Board to the marketplace via his company Gooligum Electronics.

In his words:

There is plenty of material available on PICs, which can make it daunting to get started.  And some of the available material is dated, originally developed before modern “flash” PICs were available, or based on older devices that are no longer the best choice for new designs.  Our approach is to introduce PIC programming and design in easy stages, based on a solid grounding in theory, creating a set of building blocks and techniques and giving you the confidence to draw on as we move up to more complex designs.

So in this article we’ll examine David’s course package. First of all, let’s look at the development board and inclusions. Almost everything you will need to complete all the lessons is included in the package, including the following PIC microcontrollers:

You can choose to purchase the board in kit form or pre-assembled. If you enjoy soldering, save the money and get the kit – it’s simple to assemble and a nice way to spend a few hours with a soldering iron.

Although the board includes all the electronic components and PICs – you will need are a computer capable of running Microchip MPLAB software, a Microchip PICkit3 (or -2) programming device and an IC extractor. If you’re building the kit, a typical soldering iron and so on will be required. Being the  ultra-paranoid type, I bought a couple extra of each PIC to have as spares, however none were damaged in my experimenting. Just use common-sense when handling the PICs and you will be fine.

Assembly

Putting the kit board together wasn’t difficult at all. There isn’t any surface-mount parts to worry about, and the PCB is silk-screened very well:

The rest of the parts are shipped in antistatic bags, appropriately labelled and protected:

Assembly was straight forward, just start with the low-profile parts and work your way up. The assembly guide is useful to help with component placement. After working at a normal pace, it was ready in just over an hour:

The Hardware

Once assembled (or you’ve opened the packaging) the various sections of the board are obvious and clearly labelled – as they should be for an educational board. You will notice a large amount of jumper headers – they are required to bridge in and out various LEDs, select various input methods and so on. A large amount of jumper shunts is included with the board.

It might appear a little disconcerting at first, but all is revealed and explained as you progress through the lessons. The board has decent rubber feet, and is powered either by the PICkit3 programmer, or a regulated DC power source between 5 and 6V DC, such as from a plug-pack if you want to operate your board away from a PC.

However there is a wide range of functions, input and output devices on the board – and an adjustable oscillator, as shown in the following diagram:

The Lessons

There is some assumed knowledge, which is a reasonable understanding of basic electronics, some computer and mathematical savvy and the C programming language.

You can view the first group of lessons for free on the kit website, and these are included along with the additional lessons in the included CDROM. They’re in .pdf format and easy to read. The CDROM also includes all the code so you don’t have to transcribe it from the lessons. Students start with an absolute introduction to the system, and first learn how to program in assembly language in the first group of tutorials, followed by C in the second set.

This is great as you learn about the microcontroller itself, and basically start from the bottom. Although it’s no secret I enjoy using the Arduino system – it really does hide a lot of the actual hardware knowledge away from the end user which won’t be learned. With David’s system – you will learn.

If you scroll down to the bottom of this page, you can review the tutorial summaries. Finally here’s a quick demonstration of the 7-segment displays in action:

Where to from here? 

Once you run through all the tutorials, and feel confident with your knowledge, the world of Microchip PIC will be open to you. Plus you now have a great development board for prototyping with 6 to 14-pin PIC microcontrollers. Don’t forget all the pins are brought out to the row of sockets next to the solderless breadboard, so general prototyping is a breeze.

Conclusion

For those who have mastered basic electronics, and have some C or C-like programming experience from using other development environments or PCs – this package is perfect for getting started with the Microchip PIC environment. Plus you’ll learn about assembly language – which is a good thing. I genuinely recommend this to anyone who wants to learn about PIC and/or move into more advanced microcontroller work. And as the entire package is cheaper than some books –  you can’t go wrong. The training course is available directly from the Gooligum website.

Disclaimer - The Baseline and Mid-Range PIC Training Course and Development Board was a promotional consideration from Gooligum Electronics.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.


Introduction

[Updated 18/06/2013]

There are many types of microcontrollers on the market, and it would be fair to say one of the two most popular types is the Microchip PIC series. The PICs are great as there is a huge range of microcontrollers available across a broad range of prices. However learning how to get started with the PIC platform isn’t exactly simple. Not that we expect it to be, however a soft start is always better. There are some older books, however they can cost more than $100 – and are generally outdated. So where do you start?

It is with this problem in mind that led fellow Australian David Meiklejohn to develop and offer his PIC Training Course and Development Board to the marketplace via his company Gooligum Electronics.

In his words:

There is plenty of material available on PICs, which can make it daunting to get started.  And some of the available material is dated, originally developed before modern “flash” PICs were available, or based on older devices that are no longer the best choice for new designs.  Our approach is to introduce PIC programming and design in easy stages, based on a solid grounding in theory, creating a set of building blocks and techniques and giving you the confidence to draw on as we move up to more complex designs.

So in this article we’ll examine David’s course package. First of all, let’s look at the development board and inclusions. Almost everything you will need to complete all the lessons is included in the package, including the following PIC microcontrollers:

You can choose to purchase the board in kit form or pre-assembled. If you enjoy soldering, save the money and get the kit – it’s simple to assemble and a nice way to spend a few hours with a soldering iron.

Although the board includes all the electronic components and PICs – you will need are a computer capable of running Microchip MPLAB software, a Microchip PICkit3 (or -2) programming device and an IC extractor. If you’re building the kit, a typical soldering iron and so on will be required. Being the  ultra-paranoid type, I bought a couple extra of each PIC to have as spares, however none were damaged in my experimenting. Just use common-sense when handling the PICs and you will be fine.

Assembly

Putting the kit board together wasn’t difficult at all. There isn’t any surface-mount parts to worry about, and the PCB is silk-screened very well:

barepcbss

The rest of the parts are shipped in antistatic bags, appropriately labelled and protected:

allthebitsss

Assembly was straight forward, just start with the low-profile parts and work your way up. The assembly guide is useful to help with component placement. After working at a normal pace, it was ready in just over an hour:

finishedboardss

The Hardware

Once assembled (or you’ve opened the packaging) the various sections of the board are obvious and clearly labelled – as they should be for an educational board. You will notice a large amount of jumper headers – they are required to bridge in and out various LEDs, select various input methods and so on. A large amount of jumper shunts is included with the board.

It might appear a little disconcerting at first, but all is revealed and explained as you progress through the lessons. The board has decent rubber feet, and is powered either by the PICkit3 programmer, or a regulated DC power source between 5 and 6V DC, such as from a plug-pack if you want to operate your board away from a PC.

However there is a wide range of functions, input and output devices on the board – and an adjustable oscillator, as shown in the following diagram:

boardlayoutonceassembledss

The Lessons

There is some assumed knowledge, which is a reasonable understanding of basic electronics, some computer and mathematical savvy and the C programming language.

You can view the first group of lessons for free on the kit website, and these are included along with the additional lessons in the included CDROM. They’re in .pdf format and easy to read. The CDROM also includes all the code so you don’t have to transcribe it from the lessons. Students start with an absolute introduction to the system, and first learn how to program in assembly language in the first group of tutorials, followed by C in the second set.

This is great as you learn about the microcontroller itself, and basically start from the bottom. Although it’s no secret I enjoy using the Arduino system – it really does hide a lot of the actual hardware knowledge away from the end user which won’t be learned. With David’s system – you will learn.

If you scroll down to the bottom of this page, you can review the tutorial summaries. Finally here’s a quick demonstration of the 7-segment displays in action:

Update – 18/06/2013

David has continued publishing more tutorials for his customers every few months – including such topics as the EEPROM and pulse-width modulation. As part of the expanded lessons you can also get a pack which allows experimenting with electric motors that includes a small DC motor, the TI SN75441 h-bridge IC, N-channel and P-channel MOSFETS and more:

motorkit

So after the initial purchase, you won’t be left on your own. Kudos to David for continuing to support and develop more material for his customers.

Where to from here? 

Once you run through all the tutorials, and feel confident with your knowledge, the world of Microchip PIC will be open to you. Plus you now have a great development board for prototyping with 6 to 14-pin PIC microcontrollers. Don’t forget all the pins are brought out to the row of sockets next to the solderless breadboard, so general prototyping is a breeze.

Conclusion

For those who have mastered basic electronics, and have some C or C-like programming experience from using other development environments or PCs – this package is perfect for getting started with the Microchip PIC environment. Plus you’ll learn about assembly language – which is a good thing. I genuinely recommend this to anyone who wants to learn about PIC and/or move into more advanced microcontroller work. And as the entire package is cheaper than some books –  you can’t go wrong. The training course is available directly from the Gooligum website.

Disclaimer - The Baseline and Mid-Range PIC Training Course and Development Board was a promotional consideration from Gooligum Electronics.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

The post Review: Gooligum Electronics PIC Training Course and Development Board appeared first on tronixstuff.



  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook