Show Posts
Pages: [1] 2 3 4
1  Using Arduino / Motors, Mechanics, and Power / Re: Servo twitching on: August 12, 2013, 08:55:48 am
Sorry for the late response, we lost our home internet. But anyways, i'm powering the servo using the ground and the +5 on the arduino board.
2  Using Arduino / Motors, Mechanics, and Power / Servo twitching on: July 25, 2013, 10:28:46 am
I have this servo: http://www.ebay.com/itm/HOE-SEL-SG90-9-Gram-Micro-9g-Servo-For-RC-Airplane-Car-Boat-US-Sel-/151049686413?pt=US_Scissors_Shears&hash=item232b434d8d

I'm using it with this code:
Code:
#include <Servo.h>
 
Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created
 
int pos = 0;    // variable to store the servo position
 
void setup()
{
  myservo.attach(10);  // attaches the servo on pin 10 to the servo object
}
 
 
void loop()
{
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

When I run the code the servo just keeps twitching on and off. I've verified the connections and they're correct. If I move the servo by hand a small bit it begins to move then it starts twitching again. It seems that the issue is that it's not moving enough to get to the next tooth on the servo gear, so it is in an endless loop of moving a small bit and then springing back. I've checked the servo and the teeth are not stripped out. I've tried changing the degrees and the delay in the code and it didn't seem to help, but I appreciate any help offered and I'm open to suggestion.

Thanks, Michael
3  Using Arduino / Project Guidance / Re: Arduino Bios Programmer on: August 16, 2012, 03:43:27 pm
I can't really find any information on this, I've tried to research it but I'm confused.
4  Using Arduino / Project Guidance / Arduino Bios Programmer on: July 30, 2012, 01:24:31 pm
I need help trying to re-flash a bios chip, I looked it up on the internet and I've only found completed projects being showed, not any instructions. Can you please tell me which Arduino ports I connect this chip to: [link]http://pdf1.alldatasheet.com/datasheet-pdf/view/47677/WINBOND/W55F10.html[/link]

Also how do I program the chip with the Asus bios?
5  Using Arduino / Programming Questions / Re: Revolutions Per Minute Calculating Error on: July 14, 2012, 07:15:00 pm
Thanks for all your help, I fixed it.

Code:
//these are just some references for it to work properly
#include <StopWatch.h>
#include <LiquidCrystal.h>
//these are the microcontroller ports that an lcd screen is connected to, a status led, and the switch.
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
#define LED 13
#define Reed 3 //pin for the switch

//create a timer
StopWatch MySW (StopWatch::MICROS);
//state of sensor 1 or 0
byte reedState=0;
//time between pass of magnet
unsigned long timeSincePass=0.0;
//revolutions per second
float RPS=0.0;
//revolutions per minute
float RPM=0.0;
//last state
byte lastreedState=0;

//just some setup stuff
void setup()
{
  pinMode(LED,OUTPUT);
  pinMode(Reed,INPUT);
  Serial.begin(9600);
  lcd.begin(16, 4);
  lcd.print("RPM");
}


void loop()
{  
  reedState=digitalRead(3);
  //get the state of the sensor;
  //time since pass of magnet
  timeSincePass= MySW.elapsed();
  //set the lcd cursor to write on the second line
  

  //if the magnet engages the switch
  if (reedState != lastreedState && reedState==HIGH)
  {
    //turn on status led for visual purposes
    //convert milliseconds to seconds
    RPS=(float)1000000.0/timeSincePass;
    //reset the timer storage int    
    timeSincePass=0;
    //reset the timer and start it again
    MySW.reset();
    MySW.start();

  }

  if (reedState==HIGH)
  {
    digitalWrite(LED, HIGH); // gives a visual aid to tell when it is being magnetized
  }

  else
  {
    digitalWrite(LED, LOW); //Turns off when no magnet is detected
  }

  //convert seconds to minutes
  RPM=(float)RPS*60.0;
  

  //print the results to a screen
  lcd.print(RPM);
  lcd.setCursor(0, 1);
  lcd.print("Time  ");
  lcd.print(timeSincePass);  
  lcd.print(" MPH ");
  lcd.print();
  lastreedState = reedState;

  Serial.begin(9600);
  Serial.println(RPM);
}

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)
6  Using Arduino / Motors, Mechanics, and Power / Re: How would I control these stepper motors with this driver? on: July 01, 2012, 07:09:40 pm
Also those settings like wave and half step, are those in the programming?
7  Using Arduino / Motors, Mechanics, and Power / Re: How would I control these stepper motors with this driver? on: July 01, 2012, 06:53:34 pm
Sorry, to clarify this motor is the 24v version with 4 wires. Which wires do I connect where? Which wires do I connect where? There is a brown, yellow, orange, and black, and output 1, 2, 3, and 4. Also where do you put the input? to the +5v or the +12v will it step it up to 24v?
8  Topics / Device Hacking / Re: Off Road Traction Control on: July 01, 2012, 01:44:52 pm
One thing that you should definitely do is have a differential. This will spread out the traction between the two wheels (or four if you put on on the front also) and give the non slipping wheel more torque.
9  Using Arduino / Motors, Mechanics, and Power / Re: Torque calculation on: July 01, 2012, 01:24:14 pm
I suggest viewing this video from a guy in my robotics club, it's very useful and interesting.

10  Using Arduino / Motors, Mechanics, and Power / How would I control these stepper motors with this driver? on: July 01, 2012, 01:21:51 pm
I would like to control 2 stepper motors like this one: http://pdf1.alldatasheet.com/datasheet-pdf/view/105735/MITSUMI/M42SP-7.html

Using this motor controller, a 24volt transformer power supply and the arduino:
http://www.ebay.com/itm/180898363604?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_5489wt_1189

I appreciate any help.
11  Using Arduino / Programming Questions / Re: Revolutions Per Minute Calculating Error on: June 19, 2012, 08:11:25 pm
I wasn't using my bike right away for the test I was just testing the concept by doing a simulation of moving the magnet in front with my hand. As for the hall effect, I'll look into that. My reed switch does however seem to be working because the light goes on when I move it in front of it. Also here's my new code, strangely it keeps getting 257 then a decimal like 257.45 and 257.56 rps even when I wait a long time.
Code:

//these are just some references for it to work properly
#include <StopWatch.h>
#include <LiquidCrystal.h>
//these are the microcontroller ports that an lcd screen is connected to, a status led, and the switch.
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
#define LED 13 //pin for the LED indicator (green)
#define Reed 3 //pin for the switch

//create a timer
StopWatch MySW (StopWatch::MICROS);
//state of sensor 1 or 0
byte reedState=0;
//time between pass of magnet
float timeSincePass=0;
//revolutions per second
float RPS=0;
//revolutions per minute
float RPM=0;
//last state of reed switch on or off
byte lastReedState=LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;

//just some setup stuff
void setup()
{
  pinMode(LED,OUTPUT);
  pinMode(Reed,INPUT);
  Serial.begin(9600);
  lcd.begin(16, 4);
  lcd.print("Your Revs/Sec");
}


void loop()
{
  
  byte reading = digitalRead(Reed);  
  //get the state of the sensor;
  //time since pass of magnet
  timeSincePass= MySW.elapsed();
  //set the lcd cursor to write on the second line
  lcd.setCursor(0, 1);

  if (reading != lastReedState)
  {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
  
    if ((millis() - lastDebounceTime) > debounceDelay)
  {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:
    reedState = reading;
  }

//if the magnet engages the switch
  if (reedState==HIGH)
  {
    //turn on status led for visual purposes
    digitalWrite(LED, HIGH);
    //convert milliseconds to seconds
    RPS=(float)1000000.0/timeSincePass;
    //reset the timer storage int    
    timeSincePass=0;
    //reset the timer and start it again
    MySW.reset();
    MySW.start();
  }

  else
  {
    //turn off led otherwise
    digitalWrite(LED, LOW);
  }
  //convert seconds to minutes
  RPM=(float)RPS*60;
  
  //print the results to a screen
  lcd.print(RPS);
  lcd.print("  ");
  lcd.print(timeSincePass);
  lastReedState = reading;
}
12  Using Arduino / Programming Questions / Re: Revolutions Per Minute Calculating Error on: June 19, 2012, 07:54:43 pm
Oh ok thanks I'll try that.
13  Using Arduino / Programming Questions / Re: Revolutions Per Minute Calculating Error on: June 19, 2012, 09:44:32 am
Ok now I'm getting somewhat more realistic numbers like 200 and 250 revs per second, but still those are the only 2 readings I'm getting.

Code:

//these are just some references for it to work properly
#include <StopWatch.h>
#include <LiquidCrystal.h>
//these are the microcontroller ports that an lcd screen is connected to, a status led, and the switch.
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
#define LED 13 //pin for the LED indicator (green)
#define Reed 3 //pin for the switch

//create a timer
StopWatch MySW;
//state of sensor 1 or 0
byte reedState=0;
//time between pass of magnet
float timeSincePass=0;
//revolutions per second
float RPS=0;
//revolutions per minute
float RPM=0;
//last state of reed switch on or off
byte lastReedState=LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;

//just some setup stuff
void setup()
{
  pinMode(LED,OUTPUT);
  pinMode(Reed,INPUT);
  Serial.begin(9600);
  lcd.begin(16, 4);
  lcd.print("Your Revs/Sec");
}


void loop()
{
 
  byte reading = digitalRead(Reed); 
  //get the state of the sensor;
  //time since pass of magnet
  timeSincePass= MySW.elapsed();
  //set the lcd cursor to write on the second line
  lcd.setCursor(0, 1);

  if (reading != lastReedState)
  {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
 
    if ((millis() - lastDebounceTime) > debounceDelay)
  {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:
    reedState = reading;
  }

//if the magnet engages the switch
  if (reedState==HIGH)
  {
    //turn on status led for visual purposes
    digitalWrite(LED, HIGH);
    //convert milliseconds to seconds
    RPS=(float)1000/timeSincePass;
    //reset the timer storage int   
    timeSincePass=0;
    //reset the timer and start it again
    MySW.reset();
    MySW.start();
  }

  else
  {
    //turn off led otherwise
    digitalWrite(LED, LOW);
  }
  //convert seconds to minutes
  RPM=(float)RPS*60;
 
  //print the results to a screen
  lcd.print(RPS);
  lcd.print("  ");
  lcd.print(timeSincePass);
  lastReedState = reading;
}
14  Using Arduino / Programming Questions / Re: Revolutions Per Minute Calculating Error on: June 19, 2012, 09:42:21 am
Ooops sorry I thought I made that division change that he suggested Ill change it and get back to you.
15  Using Arduino / Programming Questions / Re: Revolutions Per Minute Calculating Error on: June 19, 2012, 08:48:03 am
Here's my updated code to include a debounce:

Code:

//these are just some references for it to work properly
#include <StopWatch.h>
#include <LiquidCrystal.h>
//these are the microcontroller ports that an lcd screen is connected to, a status led, and the switch.
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
#define LED 13 //pin for the LED indicator (green)
#define Reed 3 //pin for the switch

//create a timer
StopWatch MySW;
//state of sensor 1 or 0
byte reedState=0;
//time between pass of magnet
float timeSincePass=0;
//revolutions per second
float RPS=0;
//revolutions per minute
float RPM=0;
//last state of reed switch on or off
byte lastReedState=LOW;
long lastDebounceTime = 0;
long debounceDelay = 50;

//just some setup stuff
void setup()
{
  pinMode(LED,OUTPUT);
  pinMode(Reed,INPUT);
  Serial.begin(9600);
  lcd.begin(16, 4);
  lcd.print("Your Revs/Sec");
}


void loop()
{
 
  byte reading = digitalRead(Reed); 
  //get the state of the sensor;
  //time since pass of magnet
  timeSincePass= MySW.elapsed();
  //set the lcd cursor to write on the second line
  lcd.setCursor(0, 1);

  if (reading != lastReedState)
  {
    // reset the debouncing timer
    lastDebounceTime = millis();
  }
 
    if ((millis() - lastDebounceTime) > debounceDelay)
  {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:
    reedState = reading;
  }

//if the magnet engages the switch
  if (reedState==HIGH)
  {
    //turn on status led for visual purposes
    digitalWrite(LED, HIGH);
    //convert milliseconds to seconds
    RPS=(float)timeSincePass*1000;
    //reset the timer storage int   
    timeSincePass=0;
    //reset the timer and start it again
    MySW.reset();
    MySW.start();
  }

  else
  {
    //turn off led otherwise
    digitalWrite(LED, LOW);
  }
  //convert seconds to minutes
  RPM=(float)RPS*60;
 
  //print the results to a screen
  lcd.print(RPS);
  lcd.print("  ");
  lcd.print(timeSincePass);
  lastReedState = reading;
}
Pages: [1] 2 3 4