Wednesday, July 23, 2014

Put the Physical into Physical Computing!

The whole point of microcontrollers and physical computing is doing something with the data sensed. If you sense a temperature, if you sense motion, you act on it. However, There's a bunch of science involved when you want to make things move, making sure you have enough power to move said object. The best explanation of the science of making things move is "Making Things Move DIY Mechanisms for Inventors, Hobbyists, and Artists" by Dustyn Roberts.
I've written about this book before, and I own it in paperback and kindle version, because it's that important to Arduino and Raspberry Pi owners. If you want action, you need this book. It simplifies the "magic" of making your microcontroller make things move, in some cases, very large objects.

Sunday, July 6, 2014

Creating the Super Simple Library

Functions allow you to remove repetitive routines from your main code, and call them when needed. There are times when you would like to move commonly used functions out of your Arduino sketch entirely, and into a library you can call from your sketch. This helps clean up your sketch visually, and allows you to reuse code without having to recreate it each time. Below is a simple sketch that takes a value in Celsius, and converts it to Fahrenheit. I'll show you how to convert that into a called function, then I'll repost it by calling an external library that does the same thing. This is kept simple, in order to show the process. There is much more you can do with libraries, but this is the bare minimum to get it to work.

Original sketch without a function:

float celsius = 20;
float tempF = 0;

void setup()
{
  Serial.begin(9600);
  tempF = (1.8 * celsius) + 32;
  Serial.print(tempF);
}

void loop()
{
  
}



Original sketch with a function:

float celsius = 20;
float tempF = 0;

void setup()
{
  Serial.begin(9600);
  tempF = tempConvert(celsius);
  Serial.print(tempF);
}

void loop()
{
  
}


float tempConvert(float celsius)
{
  float fahrenheit = 0;
  fahrenheit = (1.8 * celsius) + 32;
  return fahrenheit; 

}

Now let's remove the function tempConvert, and put it in a seperately called library, ( a pair of .h & .cpp files).

Sketch calling libary:

float celsius = 20;
float tempF = 0;

#include <tempConvert.h>

void setup()
{
  Serial.begin(9600);
  tempF = tempConvert(celsius);
  Serial.print(tempF);
}

void loop()
{
  
}

put the following two files in a folder called tempConvert, inside the libraries folder.

tempConvert.cpp

// tempConvert.cpp

#include "Arduino.h"   
// use: Wprogram.h for Arduino versions prior to 1.0

#include "tempConvert.h"

float tempConvert(float celsius)
{
  float fahrenheit = 0;
  fahrenheit = (1.8 * celsius) + 32;
  return fahrenheit; 
}

tempConvert.h

/*
 * tempConvert.h
 * Library header file for tempConvert library
 */
#include "Arduino.h"

float tempConvert(float celsius);  // function prototype

For more on creating libraries, see http://arduino.cc/en/Hacking/LibraryTutorial


Sunday, June 29, 2014

Arduino, or a Raspberry Pi, What's better?

Well that question is like asking what's better, a hammer, or a saw? It all depends on what you are trying to accomplish. If you are trying to read analog and digital inputs, make a decision, and control a device, the Arduino is the clear winner. If you need to run a linux operating system, with web and database services, full screen displays, and keyboard and mouse input, then the Raspberry Pi is more appropriate. There are many projects that are best served with a combination of the two. For instance, we use a network of Arduino's as sensors, feeding a database running on a Pi, and other Arduino's are picking up jobs from the database to be executed. This could not be done by an Arduino or a Raspberry Pi alone. So don't limit yourself to making choices, take both home, thay are small!

SainSmart Arduino Uno - $17
Raspberry Pi - $37 (needs a SD Card)




Wednesday, June 25, 2014

Setting up Arduino to work via Windows Embedded and RDP

by Mike Maynard

So here is my situation.  I had the brilliant idea to set up virtual machines for my boys to use, and let them access them via an HP Thin Client, and Windows Remote Desktop.  Great idea right?  I thought so..... right up to the point where I wanted to introduce them to the Arduino.....

The Thin clients are running Windows Embedded Standard (WES) an embedded version of XP.  They then connect to their Win 8.1 pro virtual machines using remote desktop.  Its actually set up so when they log into the the thin client (TC) the remote desktop session (RDP) auto launches and connects them to their virtual machine.

The directions that follow make the following assumptions:

  • You already know how to setup and use an Arduino on a standard computer
  • You are somewhat familiar with driver installations
  • You understand the basics of making a Remote Desktop Connection and how to set its options prior to the connection.


The first problem is, WES does not have driver support for the Arduino.  After much digging I stumbled upon this article - http://www.maxvalente.com/2013/03/installing-arduino-on-windows-embedded/ - which was instrumental in making this work.

I only needed 2 files from his list

  • usbser.sys
  • mdmcpq.inf
I originally tried copies out of a Windows 7 install, but I am not sure they will work.  Not having a handy XP install, I turned to google.  I found the needed files, and downloaded them along with the standard Arduino fileset from www.arduino.cc  (download the zip and not the exe, since we only need the drivers at this point).  Extract the Arduino zip someplace handy, and add the 2 above files to the drivers directory.

Plug in your arduino and let the driver install process start.  Choose the driver folder location inside the arduino directory, and voila - you should have a functional Arduino COM port!  (note: on both of my installs, I had placed a copy of usbser.sys into c:\windows\system32\drivers\ first.  I am not sure if this is necessary or not.  Also on one TC, it asked me to locate that file on my windows xp install disk, I just pointed it to the one in the above mentioned drivers directory and it worked fine)


Now on to the second problem!

Now that we have a working COM port for the Arduino on the TC - we need to pass it through to the RDP session.  I have several hours of banging my head against the wall here, and its really a simple solution, courtesy of this post here:  http://www.thinstuff.com/faq/index.php?action=artikel&id=27

Long and short, upon making your RDP connection, click the options dropdown.  then choose the Local Resources tab, followed by the 'more' button.  Then check the Ports checkbox, and click OK.  Then you can make your connection like normal (or save the connection for simple use later)

Once you connect to your remote session, your Arduino Com port should be passed through to the remote session, using the same Com port  #.

Voila!! - you now have an arduino plugged into a Windows Thin Client, and passed through to the Remote Desktop Session of another machine.


Friday, June 20, 2014

Arduino Bar Code Reader

Use Bar Coded ID Badges in your time card or security application? Want to teach your Arduino to read Bar Codes? Get a PS/2 style card reader, and connect it to The Arduino PS/2 Keyboard Smart Interface, and you have Bar Code Badge ID's flowing into your Arduino security application!


Thursday, June 19, 2014

A Better Arduino IDE?

Everyone pretty much agrees that although the Arduino IDE is simple to use, for professional programming it's just not up to par with mainstream code editors.

I've used Notepad++ for several years as my editing environment of choice, for html, css, php, etc.

Would it be possible to use Notepad++ for Arduino Sketch editing? Well as it is, yes, but there's no syntax highlighting, extension recognition, or easy way to upload sketches to the Arduino (a macro that executes "C:\Program Files\Arduino\arduino.exe" $(FULL_CURRENT_PATH)).

All that and more can be done, with a few tweaks of the environment, and a plugin.

Follow the instructions at

http://sriramiyer.net/blog/2014/02/12/using-notepad-plus-plus-instead-of-the-arduino-ide/

then  download the plugin at http://sourceforge.net/projects/narduinoplugin/ and follow the instructions in the README file.








Tuesday, June 3, 2014

Logic Gates (with pulleys)

Computers are built with Logic Gates. A logic gate looks at a input that is either on or off, and makes a decision, producing a output that is either on or off. Different types of logic gates have different outputs. The following video describes the various types, and the associated "truth tables".

 
Pulley Logic Gates from Alex Gorischek on Vimeo.

Thursday, May 29, 2014

Free Circuit Design and Simulation?

What happens when a bunch of makers and hackers decide that they need multiplatform schematic capture, spice simulation and PCB layout and don't like the idea of having to pay lots of money to buy a huge software suite and then spend weeks learning how to use it? EasyEDA Happens!


Cool Schematic Capture

Draw schematics quickly using the available libraries. Share your work, or import from LTSpice , Altium Designer and Eagle files.

Schematic capture image


Clever Spice Simulation

Verify analog, digital and mixed signal circuits with spice subcircuits and models. Get the results quickly from our cloud based servers!

Spice simulation image


Powerful PCB Layout

Export your PCB files to Gerber files, or order your PCBs from EasyEDA directly. Hardware design never come out so easy!

PCB layout image

Friday, May 23, 2014

Getting Kids Interested in Electronics

When I was a kid, my parents got me the 300-In-1 Electronic Project Lab from Radio Shack. Elenco now makes similar units. Although this really kickstarted my interest in electronics (and a 30+ year career), the springs would get bent out of shape, and if you blew a component, it was not so easy to replace. Now with Snap Circuits, younger children can enjoy the excitement of connecting electronics and seeing and hearing the results, with a much more durable product.

Friday, May 9, 2014

What is 123D Circuits?

With 123D Circuits you can design in a familiar breadboard view and the app will guide you to make professional printed circuit boards with built in layout tools. When you’re done just click to have your boards professionally manufactured and shipped for free worldwide.

What’s also cool is how you can easily, simultaneously work on the same circuit with your friends. And at any point you can compile and emulate your Arduino code inside a live, editable circuit!

http://www.123dapp.com/circuits

Tuesday, May 6, 2014

Win a free Baofeng GT-3 Dual Band Ham Radio!

Win a free Baofeng GT-3!

Just join the forum at http://www.radioddity.com/forum/ and you'll be entered into a drawing for a free Baofeng GT-3 dual band HT! A new radio given away each month to a member of the pool that joined that month. Get in for May!

Web Based Volt / Amp / Watt Hour Meter

Our Watt Hour meter project, designed for Solar / Wind power systems, and Ham radio applications is getting a new interface. Upgraded with a Ethernet or WiFi card, you can now monitor your power system with a laptop or smartphone.

You can track how many Amps (and Watts) your system is producing (or using), how many Amp hours (and Watt hours) were consumed, and how many remain in your battery bank. Bring load monitoring to a whole new level.

The new web interface makes it easy to monitor, on site, or while on the go! The new database back end makes it easy to track historical usage and production data.

Details will be posted soon!

Friday, May 2, 2014

Creating a ATX Bench Power Supply

Need a good 12v / 5v / 3.3v power supply for projects? A 400 watt supply can provide about 23 amps at 12.5 vdc or so. If you have an old computer supply laying around, you may be all set. New ones are about $18 (http://goo.gl/ilrXyi). Mike McRoberts has a great instructional on the conversion process.

His blog has lots of great projects, and we really recommend his Arduino book: Beginning Arduino

Tuesday, April 15, 2014

Arduino based SQL Queries

We are successfully performing SQL queries on two Arduino's, one in the US, one in Italy, inserting data into a HostGator hosted MySQL server (example). We are polishing a spiffy PHP / Ajax interface so you can see the results.

INSERT - Done!
SELECT - Done!
UPDATE - Done!
DELETE - Done!

Got all 4 queries working. DELETE, UPDATE, SELECT, and INSERT. Ran out of memory on the UNO, had to step up to a 2560.

Here's a taste of what's going on:

void read_data() {

      sensorValue = analogRead(sensorPin);
      char buf[128];
      sprintf(buf, "INSERT INTO spspence_test_arduino.temp VALUES (%i)",
                   sensorValue);
      my_conn.cmd_query(buf);
      Serial.println("Data read and recorded.");
      Serial.println(sensorValue);
   
  }

void setup() {
  Ethernet.begin(mac);
  Serial.begin(9600);
  delay(1000);
  Serial.println("Connecting...");
  if (my_conn.mysql_connect(server_addr, 3306, user, password))
    delay(500);
  else
    Serial.println("Connection failed.");
}

void loop() {
  delay(read_delay);
  read_data();
}

Learn more by reading Beginning Sensor Networks with Arduino & Raspberry Pi by Charles Bell


Sunday, April 13, 2014

Arduino Internet Time Client

UPDATE!
Added 12h/24h switch and Standard / Daylight Savings Time Switch! See steps 7 & 8.


Typically computers get their internal clocks adjusted by connecting to a Network Time Server (Internet or Local), using the Network Time Protocol (NTP). That functionality is also available to microcontrollers like the Arduino. We have put together an inexpensive and easy to follow instructable that will allow you to add official time keeping to a project. Have fun!

http://www.instructables.com/id/Arduino-Internet-Time-Client/