2014年3月3日 星期一

Stepper Motors code, circuits, & construction

摘錄自 http://www.tigoe.net/pcomp/code/circuits/motors/stepper-motors/

Stepper Motors
A stepper motor is a motor controlled by a series of electromagnetic coils. The center shaft has a series of magnets mounted on it, and the coils surrounding the shaft are alternately given current or not, creating magnetic fields which repulse or attract the magnets on the shaft, causing the motor to rotate.
This design allows for very precise control of the motor: by proper pulsing, it can be turned in very accurate steps of set degree increments (for example, two-degree increments, half-degree increments, etc.). They are used in printers, disk drives, and other devices where precise positioning of the motor is necessary.
There are two basic types of stepper motors, unipolar steppers and bipolar steppers.
Unipolar Stepper Motors(一般有56條接線)
The unipolar stepper motor has five or six wires and four coils (actually two coils divided by center connections on each coil). The center connections of the coils are tied together and used as the power connection. They are called unipolar steppers because power always comes in on this one pole.



Bipolar stepper motors(一般僅有4條接線)
The bipolar stepper motor usually has four wires coming out of it. Unlike unipolar steppers, bipolar steppers have no common center connection. They have two independent sets of coils instead. You can distinguish them from unipolar steppers by measuring the resistance between the wires. You should find two pairs of wires with equal resistance. If you’ve got the leads of your meter connected to two wires that are not connected (i.e. not attached to the same coil), you should see infinite resistance (or no continuity).
Like other motors, stepper motors require more power than a microcontroller can give them, so you’ll need a separate power supply for it. Ideally you’ll know the voltage from the manufacturer, but if not, get a variable DC power supply, apply the minimum voltage (hopefully 3V or so), apply voltage across two wires of a coil (e.g. 1 to 2 or 3 to 4) and slowly raise the voltage until the motor is difficult to turn. It is possible to damage a motor this way, so don’t go too far. Typical voltages for a stepper might be 5V, 9V, 12V, 24V. Higher than 24V is less common for small steppers, and frankly, above that level it’s best not to guess.
To control the stepper, apply voltage to each of the coils in a specific sequence. The sequence would go like this:
Step
wire 1
wire 2
wire 3
wire 4
1
High
low
high
low
2
low
high
high
low
3
low
high
low
high
4
high
low
low
high
To control a unipolar stepper, you use a Darlington Transistor Array. The stepping sequence is as shown above. Wires 5 and 6 are wired to the supply voltage.

To control a bipolar stepper motor, you give the coils current using to the same steps as for a unipolar stepper motor. However, instead of using four coils, you use the both poles of the two coils, and reverse the polarity of the current.
The easiest way to reverse the polarity in the coils is to use a pair of H-bridges. The L293D dual H-bridge has two H-bridges in the chip, so it will work nicely for this purpose.

Once you have the motor stepping in one direction, stepping in the other direction is simply a matter of doing the steps in reverse order.
Knowing the position is a matter of knowing how many degrees per step, and counting the steps and multiplying by that many degrees. So for examples, if you have a 1.8-degree stepper, and it’s turned 200 steps, then it’s turned 1.8 x 200 degrees, or 360 degrees, or one full revolution.
Two-Wire Control
Thanks to Sebastian Gassner for ideas on how to do this.
In every step of the sequence, two wires are always set to opposite polarities. Because of this, it’s possible to control steppers with only two wires instead of four, with a slightly more complex circuit. The stepping sequence is the same as it is for the two middle wires of the sequence above:
Step
wire 1
wire 2
1
low
high
2
high
high
3
high
low
4
low
low
The circuits for two-wire stepping are as follows:
Unipolar stepper two-wire circuit:

Biolar stepper two-wire circuit:

Programming the Microcontroller to Control a Stepper
Because both unipolar and bipolar stepper motors are controlled by the same stepping sequence, we can use the same microcontroller code to control either one. In the code examples below, connect either the Darlington transistor array (for unipolar steppers) or the dual H-bridge (for bipolar steppers) to the pins of your microcontroller as described in each example. There is a switch attached to the microcontroller as well. When the switch is high, the motor turns one direction. When it’s low, it turns the other direction.
The examples below use the 4-wire stepping sequence. A two-wire control program is shown for the Wiring/Arduino Stepper library only.
Wire pins 9-12 of the BX-24 to inputs 1-4 of the Darlington transistor array, respectively. If you’re using the PicBasic Pro code, it’s designed for a PIC 40-pin PIC such as the 16F877 or 18F452. Use pins PORTD.0 through PORTD.3, respectively. If you’re using a smaller PIC, you can swap ports, as long as you use the first four pins of the port.
Note that the wires read from left to right. Their numbers don’t correspond with the bit positions. For example, PORTD.3 would be wire 1, PORTD.2 would be wire 2, PORTD.1 would be wire 3, and PORTD.0 would be wire 4. On the BX-24, pin 9 is wire 1, pin 10 is wire 2, and so forth.
Wiring Code (for Arduino board):

This example uses the Stepper library for Wiring/Arduino. It was tested using the 2-wire circuit. To change to the 4-wire circuit, just add two more motor pins, and change the line that initalizes the Stepper library like so:

Stepper myStepper(motorSteps, motorPin1,motorPin2,motorPin3,motorPin4);
/*
 Stepper Motor Controller
 language: Wiring/Arduino

 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 and 9 of the Arduino.

 The motor moves 100 steps in one direction, then 100 in the other.

 Created 11 Mar. 2007
 Modified 7 Apr. 2007
 by Tom Igoe

 */

// define the pins that the motor is attached to. You can use
// any digital I/O pins.

#include <Stepper.h>

#define motorSteps 200     // change this depending on the number of steps
                           // per revolution of your motor
#define motorPin1 8
#define motorPin2 9
#define ledPin 13

// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);

void setup() {
  // set the motor speed at 60 RPMS:
  myStepper.setSpeed(60);

  // Initialize the Serial port:
  Serial.begin(9600);

  // set up the LED pin:
  pinMode(ledPin, OUTPUT);
  // blink the LED:
  blink(3);
}

void loop() {
  // Step forward 100 steps:
  Serial.println("Forward");
  myStepper.step(100);
  delay(500);

  // Step backward 100 steps:
  Serial.println("Backward");
  myStepper.step(-100);
  delay(500);

}

// Blink the reset LED:
void blink(int howManyTimes) {
  int i;
  for (i=0; i< howManyTimes; i++) {
    digitalWrite(ledPin, HIGH);
    delay(200);
    digitalWrite(ledPin, LOW);
    delay(200);
  }
}



3D資料(檔案)格式

3D資料(檔案)格式

3D2
Stereo CAD-3D object format

3DML
Flatland 3DML language

AC3D
AC3D

3DS
ASE
ASC

3D-Studio File Format
3D Studio Max Ascii Export Format
3D Studio Ascii Format


ALC
Alchemy III molecule file format

AL2
Alchemy 2000 molecule file format

BMF
BMF by David Farrell, exported from 3dStudio by "view3ds'.

CDF
Cyberspace Description Format

CGM
Computer Graphics Metafile (ISO/IEC standardfor vector graphics)

cinema4d
Cinema4d file format from "Maxon Computer"

COB
Calgari trueSpace2 File Format

DAE
Sony / Khronos Collada

cmod
3D model format for Celestia

cube
Gaussian cube file format for volumetric data

DF3
Povray DF3 density (volumetric) format

Direct-X
Microsofts answer to QuickDraw3D and OpenGL

DMO
Duke Nukem 3D or Redneck Rampage

DWF
Format used by AutoDesks attempt at an internet format for it's models, used by the WHIP viewer.

DXF2000
Release 14
Release 12
Release 10

DXF, AutoDesk/AutoCAD interchange format in the various format versions that have appeared over the years.

Minimal 3D DXF
The minimal requirements to represent 3D geometry in DXF, useful for creating geometry for commercial packages from your own software.

EGDR
MOLA Experiment Gridded Data Record

FACT
From ElectricImage

FBX
Autodesk FBX

FFIVW
File Format for the Interchange of Virtual Worlds

fld
AVS Field format.

FLT
OpenFlight format by MulitGen Inc

GEO
Videoscape geo an early Amiga 3D animation program written by Allen Hastings.

Geom
Geom format as used by "Stereo", an OpenGL interactive stereo pair package.

GLF
3D font format for the GLF library

GOCAD
GOCAD ascii data format

HIV
HyperChem molecular format

HPGL
Hewlett Packard Graphics Language for platters

hf
Hyperfun: Language for F-rep Geometric Modelling

IGES
Initial Graphics Exchange Specification by the National Bureau of Standards

ILDA
International Laser Display Association

Infini3D
Infini3D internal format

Inventor
Inventor ASCII format from SGI

IRIT
IRIT interchange format by Gershon Elber

LWOB
Lightwave 5.x

LightWave Object File format
Importing geometry into Lightwave 5.x


MDL
From Cornell University and Indiana University

MGF
Materials and Geometry format originally appearing as part of the Radiance package. By Greg Ward, Lawrence Berkeley Laboratory.

MI
Mental Images, as used by Mental Ray, SoftImage, and others

MOL2
Tripos mol2 molecule format

MovieBYU
Format from Birmingham Young University to represent polygons, originally designed for FORTRAN file IO.

MS3D
MilkShape 3D format

MSLD
Manchester Scene Description Language

MTL
Lightwave / OBJ material file

NDO
NENDO by Izware

nff
For Eric Haines' SPD package

nff
Neutral ASCII File Format

enff
Extensions to Neutral File Format

NUAGES
Format for the NUAGES software, a tool for 3D reconstruction from parallel cross-sections

OBJ
Wavefront .obj file format specification for the Advanced Visualizer software.

OFF
OFF format as used by the Geometry Center

OFF
OFF format specification originally developed by WSE.

OOGL
As used by GeomView

PEDR
MOLA Precision Experiment Data Records from NASA

PDB (V2.1)
Protein Data Base (Atomic Coordinate File)

PHD
PolyHedra Database (NetLib)

PI
Format for the polyray raytracer by Alexander Enzmann

PLG, FIG, WLD
Virtual World formats as used in Gossamer, Rend386, and others.

PLY
Polygon File Format also known as the Stanford Triangle Format.

Poly
Another Polygon Format from the University of Iowa, Image Analysis Facility

PS
Introduction to Postscript

POVRAY (v3.6)
Scene format for the Persistence Of Vision RAYtracer (and derivatves).

PVL
Processed VoLume (and other RAW formats) as used by the Drishti volume rendering software.

PVM
Volume files from Stefan Roettger.
Macperspective
Translator for this undocumented format.

PowerFlip
Data format (SGI)

PRT
PRT raytracer format by Kory Hamzeh

PRT
Unigraphics "parts" file format.

q3o
Quick3D Object File and Scene file format (.q3s)

QuickDraw3D
Primitive summary

Apple's Quickdraw 3D meta format

radio
Radio format by Anthony D'Agostino

RAD V3.1
RAD V2.5

Radiance scene description by Greg Ward.

ArchiCAD to Radiance converter
StrataStudio to Radiance converter


RAW
PovRay raw triangle format

RAY
RAY summary

RayShade scene description format, a solid modelling by Craig Kolb.

RIB
Pixar RenderMan scene description (RenderMan Interface Bytestream)

Rotater
Macintosh interactive line and point viewer by Craig Kloeden.

rsd
Playstation

SAT
ACIS 3D format for viewing and transferring solid information

SCENE
A proposed format for 3D geometry

SCN
SCeNe format designed to replace SFF for the Rtrace ray-tracer.

SDML
Old SDML

Spatial Data Modelling Language

SHP
ERSI Shapefile

SLC
SLiCe format

STL
Industry standard format for stereoLithography.

STP
SteinLib format

STEP
Standard for exchange of product model

Super3D
Text export format used by the Macintosh modeller Super3D.

SURF
Export format from 3D-XplorMath

Tachyon
Preliminary scene format for tachyon by John E. Stone

FORM TDDD
By Impulse's Turbo Silver for Sense8's WorldToolKit Neutral File Format specification

tet
Format for tetrahedra, originating at the Computer Science department of Williams College.

TIN
Triangular Irregular Network

TM
LONI triangle surface model format to represent surface models.

TP
TecPlot file format

TRI
Triangle format

U3D
Universal 3D

UNREAL
UNREAL File Format

V
VIVID file format by Stephen Coy

VEF
Vertex - Edge - Face format

Vision3D
Text format for the Macintosh Vision3D modeller

VLA
Digistar II VLA format

vol
.vol by Mark Dow

vmd
VMD - WinOSi (XOSi, MacOSi) raytacer by Michael Granz.

vol
Paul Bourke volumetric data format

VRI
Virtual Reality Interchange Language

WLD
Morfit's WorldBuilder format

WRM
World Reference Model by Multigen Inc.

VRML V1.0
VRML 97

The Virtual Reality Modelling Language

WMF
Windows Metafile Format

x3d
WEB3D consortium

XYZ
XYZ molecular format

YASRT
YASRT - Yet Another Simple Ray Tracer

YAODL
SGI PowerFlip format



2014年3月2日 星期日

Arduino Uno安裝設定

一、       Arduino Uno
板子正面照。

          主要元件說明


二、       安裝設定

1.首先到Arduino官方網站的下載頁面(http://arduino.cc/en/Main/Software),下載Arduino開發環境。
Windows Installer:下載直接執行
 Windows (ZIP file)不用安裝,zip解壓縮後即可。
要記得解壓縮安裝的目錄。

            2.連接Arduino Uno與電腦後,Windows會跳出新增硬體精靈,因為要自行指定驅動程式,點選「不,現在不要」。


然後選「從清單或特定位置安裝(進階)」。
   


只勾選「搜尋時包含這個位置」,按下「瀏覽」,指向Arduino安裝目錄下的drivers目錄。

然後就會開始安裝了。


按下「繼續安裝」。


驅動程式安裝完成。






2014年3月1日 星期六

步進馬達種類及激磁的方式




一、步進馬達種類

        步進馬達依定子線圈可為二相、三相、四相和五相式等,一般常用的步進馬達以四相式較多每送接受脈衝信號時,就以一定的角度作正確的步進轉動,
轉動速度與脈衝頻率成正比。常見接線圖如下:


 二、四相步進馬達激磁的方式

1.     激磁:
同一時間只有一個線圈通過電流,消耗電力小,轉矩小,振動大

2.     二相激磁:
同一時間有兩個線圈同時通過電流,轉矩大,振動小

3.     ~二相激磁:
相和二相輪流激磁