Show Posts
Pages: 1 2 3 [4]
46  Using Arduino / Motors, Mechanics, and Power / Re: 28BYJ-48 5-Volt Stepper on: January 10, 2012, 08:25:56 pm
If you use my code (above) counterclockwise() for one direction, clockwise() for the other. It works!
47  Using Arduino / Motors, Mechanics, and Power / Re: Cheap Chinese micro 9g SERVOs on: January 06, 2012, 05:02:58 pm
Not to be too political but "you eventually become dependant on them as your only source of supply" has already happened - in all things, not just Arduino items.
48  Using Arduino / Motors, Mechanics, and Power / Re: Cheap Chinese micro 9g SERVOs on: January 05, 2012, 05:00:55 pm
I recently ordered a pack of 100 resistors from Thailand for $1.49, including shipping. When the package arrived the postage stamp was for 37 Bahts which is equivalent to $1.18. This means that the seller netted 31 cents. Given their labor, eBay fees, etc., they could not have made money on this sale and may have even lost money. I can only assume that they hope for large quantity orders where shipping may work out better for them, yet they honor the small orders. Bewildering but, as you say, I'm not complaining.
49  Using Arduino / Motors, Mechanics, and Power / Re: Arduino chip as Stepper Controller on: January 05, 2012, 02:38:17 pm
kfqtd - Please follow up with future posts on your progress. The thought of using the ATtiny2313 as a component is appealing to me. I used to do similar stuff back in the Z80 days (I am a retired engineer) and the Arduino has sparked my interest anew. It has been fun to knock the dust off of my old soldering iron and tinker again. I used to use the Z80 in lots of interrupt driven situations and I am eager to see more sophisticated uses for the Arduino/ATtiny2313.
50  Using Arduino / Motors, Mechanics, and Power / Re: Cheap Chinese micro 9g SERVOs on: January 05, 2012, 02:15:30 pm
I purchased one of those HC-SR04 units a few weeks ago and liked it so much that I purchased two more ($3.89 e/w postage), which just arrive in today's mail. On December 22nd I posted a YouTube video of my Arduino using the HC-SR04 as input to drive a full-size RC servo while displaying the distance on a KTM-S1201 LCD display (eBay $2.98 delivered). The video is at: http://youtu.be/QyNbjAxVh6c

The Chinese are selling this stuff cheaply but what gets me is the super cheap postage - often included. Obviously they do not pay the postage prices that the USPS charges. A package from China arrived last week that contained less than $5 of goods yet its tracking required a signature. The postman stopped his vehicle, came to the door and I had to sign for it. Just the labor costs for that effort far exceeded any contribution shared by China Post with the USPS, if, indeed, they share any. Nonetheless, I have been buying numerous Arduino stuff from China. I don't mind the wait for delivery and I certainly enjoy the prices.
51  Using Arduino / Motors, Mechanics, and Power / Cheap Chinese micro 9g SERVOs on: January 04, 2012, 11:47:51 am
I purchased several Chinese clones of Hitec HS-55 micro servos on eBay for $2.50 each, including postage. They are called "Micro 9g servo". I tested them using a simple sketch (see below) that uses a potentiometer to set the servo position. I posted a video on YouTube of its operation. My conclusion - pretty good for the money!

Watch YouTube at:  http://youtu.be/FPe0SpAm15A

Code:
#include <Servo.h>

/*
 Demonstration of a Micro 9g RC servo
 Edward Comer
 This code serves no useful purpose other then to demo a servo.
*/

// Global variables
char buffer [50];
Servo myservo;  // create servo object to control a servo
int potValue; //variables to hold A2 input
int iOldPos, iNewPos = 0;    // servo position
 
int potPin = 2; //potentiometer connected to A2

void setup()
{
  // Establish Arduino pin usages

  pinMode(13,OUTPUT); // Use the built-in LED

  //Initialize serial port
  Serial.begin(9600);
  Serial.println("Servo Demo");

  // Initialize servo
  myservo.attach(9);   // attaches the servo on pin 9 to the servo object
}


void loop()
{
  potValue = analogRead(potPin);    // read the value of the potentiometer
  iNewPos = potValue/5;     // convert to quasi-degrees (alter per your potentiometer)

  if(iOldPos != iNewPos) {     // Issue command only if desired position changes
    digitalWrite(13, HIGH);         // set the LED on
    iOldPos = iNewPos;
    Serial.print("Pot = ");         // Human readable verification on serial port
    Serial.print(potValue);         // View full range from 0 - 1024 in Serial Monitor
    Serial.print(", ~degrees = ");
    Serial.println(iNewPos);

    // Set shaft angle in degrees from approximately 0 to 180 (limited by integer math)
    myservo.write(iNewPos);     // tell servo to go to position in variable 'pos'
    delay(15);             // waits 15ms for the servo to reach the position
    //delay(1000);           // slow to human speeds
    digitalWrite(13, LOW);    // set the LED off
  }
}
52  Using Arduino / Motors, Mechanics, and Power / 28BYJ-48 5-Volt Stepper on: December 31, 2011, 02:46:27 pm
FYI - below is some Arduino code that demonstrates bidirectional operation of a 28BYJ-48 5-Volt stepper motor. It does not use the Arduino library partly because I wanted to get a bit more hands-on with the stepper to learn its operation and partly because the library isn't designed for this type of stepper and the pin assignments need to flipped around to work. Plus, I don't think that the library correctly addresses the eight codes required for this stepper and, instead, uses only four codes. Anyway, this code works well for a functionality demo. The code is based on some general stepper code that I found on the web (I don't recall where) and modified for the  28BYJ-48 stepper. I have also attached a photo of the stepper and interface board that I am using - <$5 for both on eBay. I have also attached a schematic for the ULN2003 Driver Board.

Code:
// This Arduino example demonstrates bidirectional operation of a
// 28BYJ-48, which is readily available on eBay, using a ULN2003
// interface board to drive the stepper. The 28BYJ-48 motor is a 4-
// phase, 8-beat motor, geared down by a factor of 68. One bipolar
// winding is on motor pins 1 & 3 and the other on motor pins 2 & 4.
// Refer to the manufacturer's documentation of  Changzhou Fulling
// Motor Co., Ltd., among others.  The step angle is 5.625/64 and the
// operating Frequency is 100pps. Current draw is 92mA.  In this
// example, the speed and direction of the stepper motor is determined
// by adjusting a 1k-ohm potentiometer connected to Arduino pin A2.
// When the potentiometer is rotated fully counterclockwise, the motor
// will rotate at full counterclockwise speed. As the potentiometer is
// rotated clockwise, the motor will continue to slow down until is
// reaches its minimum speed at the the potentiometer's midpoint value .
// Once the potentiometer crosses its midpoint, the motor will reverse
// direction. As the potentiometer is rotated further clockwise, the speed  
// of the motor will increase until it reaches its full clockwise rotation
// speed when the potentiometer has been rotated fully clockwise.
////////////////////////////////////////////////

//declare variables for the motor pins
int motorPin1 = 8; // Blue   - 28BYJ48 pin 1
int motorPin2 = 9; // Pink   - 28BYJ48 pin 2
int motorPin3 = 10; // Yellow - 28BYJ48 pin 3
int motorPin4 = 11; // Orange - 28BYJ48 pin 4
                        // Red    - 28BYJ48 pin 5 (VCC)

int motorSpeed = 0;     //variable to set stepper speed
int potPin = 2; //potentiometer connected to A2
int potValue = 0; //variable to read A0 input


//////////////////////////////////////////////////////////////////////////////
void setup() {
  //declare the motor pins as outputs
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorPin3, OUTPUT);
  pinMode(motorPin4, OUTPUT);
  Serial.begin(9600);
}

//////////////////////////////////////////////////////////////////////////////
void loop(){

  potValue = analogRead(potPin);     // read the value of the potentiometer
  Serial.println(potValue);          // View full range from 0 - 1024 in Serial Monitor
  if (potValue < 535){               // if potentiometer reads 0 to 535 do this
    motorSpeed = (potValue/15 + 5);  //scale potValue to be useful for motor
    clockwise();                     //go to the ccw rotation function
  }
  else {                             //value of the potentiometer is 512 - 1024
    motorSpeed = ((1024-potValue)/15 + 5); //scale potValue for motor speed
    counterclockwise(); //go the the cw rotation function
  }
}

//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 1 to 4
//delay "motorSpeed" between each pin setting (to determine speed)

void counterclockwise (){
  // 1
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 2
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay (motorSpeed);
  // 3
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 4
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 5
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, LOW);
  delay(motorSpeed);
  // 6
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin4, HIGH);
  delay (motorSpeed);
  // 7
  digitalWrite(motorPin1, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(motorSpeed);
  // 8
  digitalWrite(motorPin1, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin4, HIGH);
  delay(motorSpeed);
}

//////////////////////////////////////////////////////////////////////////////
//set pins to ULN2003 high in sequence from 4 to 1
//delay "motorSpeed" between each pin setting (to determine speed)

void clockwise(){
  // 1
  digitalWrite(motorPin4, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 2
  digitalWrite(motorPin4, HIGH);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, LOW);
  delay (motorSpeed);
  // 3
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 4
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, HIGH);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 5
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin1, LOW);
  delay(motorSpeed);
  // 6
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, HIGH);
  digitalWrite(motorPin1, HIGH);
  delay (motorSpeed);
  // 7
  digitalWrite(motorPin4, LOW);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, HIGH);
  delay(motorSpeed);
  // 8
  digitalWrite(motorPin4, HIGH);
  digitalWrite(motorPin3, LOW);
  digitalWrite(motorPin2, LOW);
  digitalWrite(motorPin1, HIGH);
  delay(motorSpeed);
}

Pages: 1 2 3 [4]