Monday, March 19, 2012

Arduino to VGA

I've previously posted about our micrometer to VGA project, and wanted to post an updated picture of that finished project in production. It's a gear mic'ing station that takes 3 samples of a gear, rejects the gear if the samples are not close enough, and generates a bin number for the operator to put that gear into, for pump assembly (fuel oil pumps).


The Arduino Thermostat

I've talked about this before, but since I just built another one last week, I thought I'd reshare this project, as it has a slight twist.

The idea is to select the temperature you want with a potentiometer, and display it on the screen. Then the Arduino reads a Dallas 18B20 digital temperature chip (or a thermocouple for higher temperature needs, like a temperature controlled soldering station) and controls a SSR (with a heater or A/C attached) to match the temperature requested. When the temperature chip reads the same as the requested temperature, then the power to the heating or cooling device is turned off.


This project has many applications, from room temperature control, to water heaters, or even environmental chambers. The concept is the same. With the addition of a RTC, you can easily program day night setbacks or even weekend setbacks. With a second temp sensor outdoors, you can add a offset based on outdoor temperature, i.e. increase indoor temperature by 5 F if outdoor is <30, and decrease indoor by 5 F if outdoor is >90.

I've covered some of these concepts before at Two DS18B20 Temp Sensors on LCD Display!

Most of the parts needed to make this unit are available at Hacktronics:
Arduino Uno
LCD Display
Dallas 18B20

10 amp 24-330vac load, 4-32vdc control (opto isolated) SSR

I'll post the sketch shortly.

Saturday, March 10, 2012

Circuit Lab - Sketch, simulate, and share schematics

For Students & Educators

Draw and print beautiful schematics for lab reports. In-browser simulations make it easy to quickly learn electronics concepts via just-for-fun playing and guided exploration. Our tools complement undergraduate and graduate electrical engineering classes, as well as high school and college physics curriculum.

For Hobbyists & Tinkerers

CircuitLab lets you rapidly test circuit ideas before breadboarding. And when we host your circuit, we provide you with a convenient image and link that you can use to share your circuit on online forums or your own website, so you can contribute to or get help from the hobbyist community.

For Practicing Engineers

Our user-friendly schematic capture tool lets you explore the design space in a fraction of the time of traditional tools. SPICE-like models with a mixed-mode simulation engine help you apply one tool to a wide range of design tasks, from digital to analog, DC to VHF and beyond.

Sunday, March 4, 2012

Fun with Servos

Hacktronics recently sent me two HXT900 servos to play with. I used the sample servo code included in the Arduino IDE, that allows me to control the servo position with a potentiometer.

The pot is connected to the arduino, with the center wiper connected to Analog 0, and the outside connections to +5 and Gnd., respectively.

The servo initially gave us trouble, till Wild Bill on the Arduino.cc forum pointed out the servo needs it's own power supply. The Arduino can't provide enough power to operate it reliably, and could possibly damage the Arduino (thankfully it didn't).

So, we connected the orange wire on the servo to Arduino pin 9, the servo red wire to the + of two AA batteries in series, and the servo brown wire, plus the AA battery pack negative, to Arduino ground. We then loaded the following sketch, and had instant success!

// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott

#include "servo.h"

Servo myservo;  // create servo object to control a servo

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup()
{
  Serial.begin(9600);          //  setup serial
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
//  Serial.println(val);
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);    // sets the servo position according to the scaled value
//  Serial.println(val);
  delay(15);                           // waits for the servo to get there
}  




Light Sensing with a Cds (LDR)

A Cadmium Sulfide (CdS) sensor is a Light Dependent Resistor (LDR). It is a resistor that reduces resistance when hit with light. The more light, the lower the resistance. The Arduino is ideal for monitoring one of these sensors, and can be the heart of a streetlight or burglar alarm system, turning devices on or off in the presence of light. It could also be used in photography or solar applications, detecting the amount or direction of light.

See the following sketch for ideas. The parts are available at Hacktronics.


/*
Cds Connections:
CdS Pin 1 to +5v
CdS Pin 2 to Analog Pin 3
10k ohm resistor pin 1 to Analog Pin 3
10k ohm resistor pin 2 to Gnd
*/

int analogPin = 3;   // CdS (ldr) connected to analog pin 3
int val = 0;         // variable to store the read value



void setup() {
 Serial.begin(9600);
}



void loop() {
  val = analogRead(analogPin);   // read the input pin
  Serial.println(val);
  delay(100);
   }





Arduino 1.0 upgrades

We have been going through our old sketches, making sure they are Arduino 1.0 friendly. Most of the sketches are, and we have been upgrading any libraries that were not. Please check frequently as we post new upgrades. This weekend has seen a flurry of Arduino activity and we are posting as fast as possible.

To learn more about the changes seen in Arduino 1.0 coding, please see the 2nd Edition (Dec. 2011) of the Arduino Cookbook, by Michael Margolis.


Dallas DS18B20 Temperature Chip

We previously addressed this great temperature sensor (http://arduinotronics.blogspot.com/2010/11/ds18b20-digital-thermometer.html), and have built many projects around it including thermostats and process controls. Unfortunately, the new Arduino 1.0 software upgrade did not work with the older One Wire and Dallas Temperature Libraries. Never fear, the folks at Hacktronics dug up the upgraded libraries, and we just finished testing them with the old sketches. Everything once again is wonderful!

Libraries:

http://download.milesburton.com/Arduino/MaximTemperature/DallasTemperature_372Beta.zip

http://www.pjrc.com/teensy/td_libs_OneWire.html