Home » Posts tagged 'Arduino'

Tag Archives: Arduino

Setting up Git for Arduino and Raspberry Pi Development

For my future projects, I plan to do a combination of Arduino and RPi development.  The development of the Arduino code will be on my MS Windows PC and the RPi solution will be developed naively within the RPi Linux environment   Given this distributed environment (and my ability to bungle things), I can foresee  potential problems maintain good source code control.  To deal with this, the combination of git and gethub seems the right way to proceed …. after all it has worked for the distributed Linux development community.

Git on MS Windows

The first thing I did was to set up git within my MS Windows PC.  Given that I installed Cygwin when setting up the RPi, that is where I returned to install git.  Therefore, I plan to use git within the Cygwin environment on my PC and not within MS Windows per say.  This could be done, but my approach allows me to learn git commands once since, Cygwin is a Linux-like environment, everything should look and operate the same.

To accomplish this I follow the instructions outline in Installing Git on Cygwin.  These instructions are very straight forward.  The challenge was in initializing git for my first project, at least it was a challenge for me since git is new tool for me and Cygwin didn’t always cooperate.  I had to address this the old fashion way …. read the documentation and trouble logs (vs. doing a web search for someones web post with instructions).  All the important secrets of git can be found widely dispersed and buried deep withing these web sites: Git Documentation and Git Reference.  Source information from trouble logs will be listed below.

So how did I do it?  It’s easy once you successively done it once.  First let me state the context; for the exercise I’m doing, I’m attempting to place my .bashrc, .profile, .vimrc, and a few other configuration files under gits control.  The basic sequence of operation is to initialize the git environment, configure some parameters, and then add the files.  It goes like this (I’ll let you research the git documentation, just like I did, to understand the command.  Trust me, this is good for you!):

git init
git config --global user.name "jeffskinnerbox"
git config --global user.email jeff.irland@verizon.net
git config --global core.editor vim
git config --global merge.tool vimdiff
git add .bashrc .profile .vimrc .bash_profile .minttyrc .inputrc .gitconfig .gitignore

To see what you got, use the git status command.  This will tell you the files got staged but not committed. The commit will come later.  First we need to set up our communal repository within github.

Setting Up Github

You may be asking, What Exactly Is GitHub Anyway?  Well, in a few words, github is a web-based hosting service for software development projects that use git. The next step is to go to github, set up your free login, and then set up a repository.  In my case, I set up a github repository called Cygwin-Configuration-Files to store my configuration files established earlier under git control.  It will be empty at this point, and that’s all for now, loading it with files comes later.

I didn’t say much about how to set up github, but trust me, it is as simple as outlined above.  It’s via git that all the real work takes place.  Github is all about giving you an off-site, web-access-able, complete version controlled historical record of your code that can be shared with others.

Back to Git within Cygwin

Now that we have established github and initialized, configured, and added files to the Cygwin environment  we can associated the PC and github environments.  It wasn’t clear to me, from the git documentation, how to best do this association.  Using  git clone isn’t intuitive to me, but it seems to work.  This is how I did it:

git clone https://github.com/jeffskinnerbox/Cygwin-Configuration-Files.git

Warning You may, as I did, get the following error:

Cloning into 'Cygwin-Configuration-Files'...
error: error setting certificate verify locations:
CAfile: /usr/ssl/certs/ca-bundle.crt
CApath: none while accessing https://github.com/jeffskinnerbox/Cygwin-Configuration-Files.git/info/refs
fatal: HTTP request failed

If you get the above error, the problem is that Cygwin hasn’t installed the ca-certificates package.  Run the Cygwin installer again, and add that package; after that git clone should start working.

The next step is to commit your files to the git local repository within the PC under Cygwin.  To do this, execute the following command:

git commit

You will be put into vim to provide a comment that will be posted with the git version.  Why vim?  Because you executed the command git config --global core.editor vim  earlier.  If you don’t want to use vim for adding comments under git, supply another editor when you do the configuration step.

The next step, which strictly isn’t required but a nice to have, is to associate a descriptive identifier with the github repository.  The descriptor I used is “Cygwin-Configuration-Files”.  The command I used is:

git remote add Cygwin-Configuration-Files https://github.com/jeffskinnerbox/Cygwin-Configuration-Files.git

The final step is to push your local files to the github repository,

git push Cygwin-Configuration-Files

Warning … It was during the git push that I ran into another problem, but it could happen nearly any time.  I discovered that sometimes, after multiple Cygwin updating or installing packages, you’ll start to get strange errors related to “fork()” or .dll loading. After some research, I discoved these errors are usually solved by rebasing your packages.  While rebasing, which is executed using the Cygwin rebaseall command, is is a bit of a mystery, it does appear to work

Rebasing Cygwin

Before you can run the rebaseall command, you’ll need to make sure no Cygwin-based services are running.   To do this, you need to run two cygwin command, cygrunsrc and rebaseall,  under the ash command in MS Windows command prompt, not in a Cygwin Terminal window.   The sequence of activity is as follows:

    1. Exit the Cygwin Terminal
    2. Run as administrator the MS Windows Command Prompt window
    3. Execute ash via \cygwin\bin\ash.exe
    4. Now under ash, see if any Cygwin processes are running via /usr/bin/cygrunsrc -L
    5. Stop any of the  running processes via /usr/bin/cygrunsrc --stop <process's>
    6. Now do the rebase via /usr/bin/rebaseall

For an example the steps above performed within the Command Prompt under ash, see below:

Git on the Raspberry Pi

Admittedly, getting git setup under MS Windows / Cygwin isn’t a walk in the park.  It appears to work fine once set up, but the setup process can be painful.

Git under the Raspberry Pi’s Linux installs flawlessly, as you would expect, given git origins.  First you  install git via sudo apt-get install git.  Then, just as was done above, do the initialization of the git environment, configure some parameters,  add the files, setup the github, clone, and push.

In my case, I setup a separate  a github repository called RPI-Configuration-Files to store my RPi configuration files.  I could have used the same repository as was setup for the PC environment but that didn’t make sense for my present needs.

Conclusion

So that’s it!  Its a long post for what is really a simple to use tool, but setting it up the first time could be a challenge.

Advertisements

Arduino Memory

As I have been exploring the Arduino hardware platforms for my TBD project, I find myself forgetting the memory options available.  I’m recording here my findings so I can reference it later.

Arduino

Chip

Flash

SRAM

EEPROM

Nano 2.3

ATmega168

16K bytes

1024 bytes

512 bytes

Nano 3.0

ATmega328

32K bytes

2048 bytes

1024 bytes

Uno

ATmega328

32K bytes

2048 bytes

1024 bytes

Mega 2560

ATmega2560

256K bytes

8192 bytes

4096 bytes

    • SRAM (Static Random Access Memory) is where the sketch creates and manipulates variables when it runs.
    • EEPROM (Electrically Erasable Programmable Read-Only Memory) is memory space that programmers can use to store long-term information.
    • Flash memory is where the Arduino sketch is stored (program space).  The bootloader takes about 2 KB of flash memory and remaining space is for the sketch.

The Arduino IDE will tell you exactly how much Flash is being used after each compile/upload.  EEPROM is an older, more reliable technology. It is somewhat slower than Flash.  In Flash, a large block is erased all at once, much faster than the EEPROM method of going cell-by-cell.

If you don’t need to modify the strings or data while your sketch is running, you can store them in Flash (program) memory instead of SRAM; to do this, use the PROGMEM keyword.

Part of my interest in the Arduino’s memory is my concern about how much memory a sketch uses.  Here are some sites that provide insight and algorithms for calculating the memory:

Arduino Electronic Design Automation

Electronic design automation (EDA or ECAD) is a category of software tools for designing electronic systems such as printed circuit boards.  In my professional life, I have been work apart from this domain, and only now because of renewed interest in electronics, I have come back to do some research.  I was pleasantly amazed by what I found.

Schematic and PCB Layout Editors

EAGLE (Easily Applicable Graphical Layout Editor) is a very popular (and free) solution for PCB design, including Schematic Capture, Board Layout and Autorouter.

Other tools are specifically focused on the Arduino that allows users to document their prototypes, share them with others, teach electronics in a classroom, and to create a PCB layout for professional manufacturing.

Arduino Platform Simulation

PCB Board Creation

You can crate printed circuit board (PCB) with the aid of some web sites.  You submit your PCB design; they add your design to the batch of orders. When the batch is big enough, the batch is set off to be manufactured.

SPICE

SPICE (Simulation Program with Integrated Circuit Emphasis) is a general-purpose, open source analog electronic circuit simulator

Arduino Software Tools

Arduino Specific Program Languages


Wiring is an open source electronics prototyping platform composed of a programming language, an integrated development environment (IDE), and a single-board microcontroller.

Using Microsoft Visual Studio 2010 Professional


The Arduino Playground web site provides some advice and instructions on Using Microsoft Visual Studio 10  and a plugin called Visual Micro to provide a full Arduino development platform.  For more information, check out:

To install the Microsoft Visual Studio 10, Visual Micro, and set it up for Arduino development, follow these steps:

    1. Download and install Microsoft Visual Studio 2010 Professional (For a free copy of Visual Studio, check out http://www.visualmicro.com/page/Offer-Visual-Studio-Professional-Free-For-3-Years.aspx).
    2. Download and install Visual Micro from http://www.visualmicro.com/.
    3. The above reference has a series of links that will take you through setting-up and testing the installation, configuring it, etc.  All well worth reviewing.
    4. There are a few things you need to do that were not included in the above reference:
      • Make sure “Upload Using Programmer” is uncheck within Tool > Arduino
      • To make sure you can “include” “.h” files within your source directory, add “$(ProjectDir)” in Properties > Configuration Properties > VC++ Directories > Include Directories.

All of this is much easier than setting up and using Microsoft Visual C++ 2010 Express!

Atmel AVR Studio 5

This is an Integrated Development Environment (IDE) for developing and debugging embedded Atmel AVR applications write, build, and debug using C/C++ and assembler code.

Processing and Arduino

Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Arduino comes with some basic examples for communicating with Processing (in Examples > Communication). These are useful for when you want to write both Arduino and Processing programs and have them talk to each other.

Arduino and openFrameworks

On the surface, openFrameworks seems very similar to Processing. openFrameworks is much better at creating projects that use a lot of 3D Graphics, computer vision libraries like OpenCV or projects that involve the real-time manipulation of video. Also, while Processing requires a Java backend, openFrameworks is simply a set of C++ libraries, meaning that developers comfortable with C++ will be right at home.

C and Arduino

The Arduino language is simply just a small refinement of C, in an effort to make the Arduino easier to code. Moving to C or C++ is very natural step up.

Scratch for Arduino

Scratch is a programming language learning environment enabling beginners to get results without having to learn syntactically correct writing first.

Scratch is evolving into a more powerful platform.

Getting Started with Arduino

What is an Arduino?

First things first – Just what is an Arduino? Check out the following links for a brief introduction:

For a lighter look at the Arduino, check out the comic book by Jody Culkin.

To go a bit deeper to understand the Arduino hardware variants and the Arduino’s Interactive Development Environment (IDE):

Arduino also comes in multiple hardware variations to support different types of applications.

What you Need to Purchase

For less than $100, Adafruit Industries offers an excellent starter package, Adafruit ARDX. This package not only includes an Arduino Uno but also all the electronic pieces needed to complete 11 different circuits, along with a experimenter’s guide booklet & breadboard layout sheets.

Installing the IDE

This is the program used to write code for the Arduino. Install the software for you operating system and type of Arduino. I’m assuming Vista and Arduino Uno R3.

Start Your Education

Using the experiments guide that comes with the Arduino kit, Arduino Experimenter’s Guide (ARDX), and your off and running! Other sites to check out include:

Purchasing Arduino Hardware and Supporting Electronics

There are several online retail stores that sell the bits and pieces to make electronics projects possible. Some of the best are:

Robotics is a popular topic for Arduino and these sites specialize in components and kits especially suited for robots:

There are many shields available for the Arduino to accommodate many needs and Arduino Shield List keeps a running list of them.

Arduino Knowledgebases

%d bloggers like this: