Tuesday, April 13, 2010

Remotely Control Arduino








In the previous article,we have discussed how to use the RF module to control Arduino wirelessly. Its principle is similar to a remote control, which has 4 buttons for RF wireless remote control. However,on occasions of data transmission, such a solution becomes less suitable,for example when you want to send PC the data that Arduino collected from light sensors.It is technically known as the wireless data transmission. At present, there are many solutions for wireless data transmission.A very simple way is connecting with the Arduino using APC220 to send data via serical port. Although the data transmission speed may slow (limited by the serial port baud rate) ,it is a simple and pratical way.No wonder that many netizens recommended the inclusion of such Arduino module support.
Manufacturers do not give any datasheet or material to us. Fortunately, some can be found on the network.Meanwhile learn by researching. First,USB adapter from manufacturer seems not to match APC220 because the number of pins is different. Maybe because it has to be compatible with other different products, or at least it is not specially designed for the APC220. USB adapter used CP2102 chip.Download the appropriate drivers in Silicon Laboratories, I downloaded the file cp210x_vcp_win2k_xp_s2k3.zip, unzipped to get an exe file, then instal the driver step by step following the prompts.

After driver installation is complete,insert USB adapter into the PC's USB interface, Windows will be prompted to find new hardware,?then finsh installation and configuration accordingly:

When Windows prompts that you can use the hardware.Below the Device Manager's "Ports (COM & LPT)" is CP2102 virtual serial port:



APC220 module can now be connected to a USB adapter.As pin number of USB adapter and APC220 is different, pay attention to the insert location:


Open setup program "RF-ANET" gotten from APC220 manufacture. CP2102 has found the default serial port "COM87".However, RF-ANET can not open the port.


In the Device Manager, set serial port to COM4 , re-insert the USB adapter and open RF-ANET, click the "Read R" button.Everything is all right.The status bar displays "read succeed!", which means we are able to communicate with APC220.



Then we finished setup work on PC side. Now come to Arduino side. APC220 module has 4 connection wires to Arduino: 5V, GND, TX and RX.Note that APC220 and Arduino are a separate serial device, so connect TX on the Arduino to RX on APC220 and conncet RX on Arduino to TX on APC220:


APC220 module's default baud rate is 9600. Let's test it with the following code.Note that when downloading process to Aduino, break the connection of TX and RX on APC220, otherwise downloading will be wrong.



int val = 0;
int ledPin = 13;
void setup()
{
Serial.begin(9600);
}

void loop()
{
val = Serial.read();
if (-1 != val) {
if ('A' == val 'a' == val) {
Serial.println("Hello from Arduino!");
}else if ('B' == val 'b' == val) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
}
}
}


In summary, now that we have respectively connected Arduino and PC to APC220 module, and also has written test code to Arduino. While everything is ready, we can start the tests. First,we have to use an external power supply to power Arduino, because if the USB cable is connected, FT232 module will be activated,and then FT232 serial port and ACP220 serial port will conflict, leading to communication failure:


Put powed-on Arduino into a corner of the room. Then configure the PC. Through its USB adapter, APC220 module works like a serial port.So we can use Arduino's development environment to test.In this case your PC is no longer connected to Arduino, but to APC220 USB adapter. After USB adapter's connection, open Arduino, in the "Tools" ; "Serial Ports" menu, select "COM4" (in line with the previous settings). Then open "Serial Monitor" in Arduino, send the A character. PC will receive "Hello from Arduino!" from Arduino. Send the B characters, then No. 13 LED on the Arduino is lighted(continuous 0.5 seconds):

Monday, April 12, 2010

Motor Drive Shield DIY

Image
This is a finished motor drive board.
You need a 25W electric soldering iron and a roll of solder wire
OK. Let's began. As the following map. This is a PCB board where you weld all the components.
Image
The following pic shows all the components you need.
Image
First, solder the two resistaces. It's simple:
Image
Cut the long foots:
Image
Then weld there capacitors and cut the foots as above:
Image
Now weld the exclusion. Which is exclusion? That black thing below. Exclusion has polarities. The foot facing the white point is GND. Weld it in the right position as following do:
Image
finished:
Image
Now we begin welding 74HC595. The IC chip also has direction with the gap up. Install it as the following pic and weld it on.
Image
Now we weld IC transposon beside 74HC595. Pay attention to the direction.
Image
Now we begin to weld electrolytic capacitors. Electrolytic capacitor has positive and negative polarities. The long legs is positive. Note that the hole with the + sign on the billboard is positive. Match the capacitor's polarities with the board's.
Image
There are five capacitors on the boards:
Image
cut the foots:
Image
The next is LED diode. Pay attention to positive and negative polarities.
Image
cut the foots:
Image
Weld the two foot terminals for steering gear on the top-left board:
Image
Weld the foot terminals for power (PWR):
Image
As following, weld the two blue output terminals, the yellow power terminal, and reset switch. Then install the two L239 as on the pic.
Image
At last, weld the pins on the back of the board:
Image
OK, all is down:
Image
Image
Image

Now this baord can work without any debugging . It can simultaneously drive two steering gears and four DC motor (PWM can adjust speed). It can drive two stepper motors and connect to four sensors. Of course it has to work with Arduino control board.

Thursday, April 8, 2010

Arduino motor drive

Arduino motor drive shield- L293D Shield

This motor drive shield of Arduino based on L293D chip, it can drive two DC electric machine.



you can drive DC electric machine easily by this shield, you only need to insert the shield to Arduino, link the DC electric machine to motors's pin of the shield.



As mention above, you should get external power of Arduino,and use transformer and power work for Arduino.Here we choose 9V transformer and 9V DC electric machine.



motors pin above on motor shield to motor 1,motors pin below on motor shield to motor 2



When finish linking ,the next step is how to control by program.We can control direction of rotation and speed of rotation of DC electric machine.To control direction of rotation are digital I/O pin 12 and 13 of Arduino;to control speed of rotation are digital I/O pin 9 and 10 of Arduino
if you want to control DC electric machine 1, you need to do this:export PWM signal to pin 9 to control speed of electric machine , and set pin 12 and 13 voltage as high or low to control derection of electric machine;
if you want to control DC electric machine 2, you need to do this:export PWM signal to pin 10 to control speed of electric machine , and set pin 12 and 13 voltage as high or low to control derection of electric machine;
electric motor shield contain two button :S1 to pin7 of Arduino digital I/O and S2 to pin6 of Arduino digital I/O,low when press.So we can control S1 by program as below.

int switchPin = 7; // switch pin
int dir1Pin = 12; // direction 1
int dir2Pin = 13; // direction 2
int speedPin = 9; // spped pin

void setup() {
pinMode(switchPin, INPUT);
pinMode(dir1Pin, OUTPUT);
pinMode(dir2Pin, OUTPUT);
pinMode(speedPin, OUTPUT);
}

void loop() {
// switch is pressed
if (digitalRead(switchPin) == LOW) {
// set spped
analogWrite(speedPin, 250);
// set direction
digitalWrite(dir1Pin, LOW);
digitalWrite(dir2Pin, HIGH);
} else {
analogWrite(speedPin, 100);
digitalWrite(dir1Pin, HIGH);
digitalWrite(dir2Pin, LOW);
}
}


download to Arduino and run, we can use S1 to change direction and speed of electric motor.



Arduino controls Digital Temperature & Humidity sensors

Arduino Digital Temperature & Humidity sensors


As to environmental temperature and humidity measurement and control,Swiss Sensirion launched the SHT family integrated of digital temperature and humidity sensor,which is undoubtedly a very good choice. Although the prices is a littile more than common analog temperature or humidity sensor, it is good when you need to read an accurate temperature and humidity values. Besides it has high reliability and excellent long-term stability.

We designed this digital temperature and humidity sensor based on most widely used SHT10 from SHT family.

SHT10 used a two-wire serial interface similar to I2C (bidirectional 2-wire), so we need to use two connection cables to connect with the electronic building module.


To use the electronic building module with Arduino, you can download the appropriate library code in the official website, or download directly from here, We use "Arduino 0018"to test.Extract the files to the "libraries" directory under Arduino installation directory:




Connect DATA and SCK pins on electronic building module respectively to Arduino digital I / O, 10 pins and 11 pins, As follows:

#include?<SHT1x.h>

#define dataPin 10 // DATA
#define clockPin 11// SCK
SHT1x sht1x(dataPin, clockPin);

void setup()
{
?Serial.begin(9600);
?Serial.println("Starting up");
}

void loop()
{
float temp_c;
float temp_f;
float humidity;

// Read values from the sensor
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity=sht1x.readHumidity();

// Print the values to the serial port
?Serial.print("Temperature: ");
?Serial.print(temp_c, DEC);
?Serial.print("C / ");
?Serial.print(temp_f, DEC);
?Serial.print("F. Humidity: ");
?Serial.print(humidity);
?Serial.println("%");

delay(2000);
}

here is output as follows:

Information about SHT10 - Digital Humidity Sensor

Economic relative humidity sensor for low cost applications.

SHT10 digital humidity and temperature sensor is the low cost version of the reflow solderable humidity sensor series. The accuracies have been opened to a level that guarantees a very competitive price. The capacitive humidity sensor is available up to high volumes and as every other sensor type of the SHTxx family, it is fully calibrated and provides a digital output.

Features :

  • Energy consumption:
80uW (at 12bit, 3V, 1 measurement/s)
  • RH operating range:
0~100% RH
  • T operating range:
-40 ~+125Centigrade (-40~+257F)
  • RH response time:
8 sec (tau63%)
  • Output:
digital (2-wire interface)

  • Maximal accuracy limits for relative humdity and temperature:

Accuracy relative humidity SHT10Accuracy  temperature SHT10

Delivery Conditions

Packaging: Tape & Reel, sealed in ESD bag

Please go to our Forum for further discussion