Show Posts
Pages: [1] 2 3 ... 15
1  Products / Arduino Yún / Want to changer the IP from the Yún WiFi on: March 14, 2014, 06:06:08 am
I am trying to change the IP as described here http://arduino.cc/en/Guide/ArduinoYun#toc13 but with no luck.
My laptop runs on Windows8.
The Yún is connected true the USB cable.

If i try to connet to the Yún using my laptop, the device is shown in the available connections list, i get a warning that there are only limited services available for that connection. It has the IP address 192.168.240.222.

But if i do a Ping to the Yún on 192.168.240.1 i get no reaction.

Is this normal or am i doing something wrong or is there a problem with my configuration?

Harry
2  Using Arduino / Programming Questions / Re: Reverse calculation gives wrong result on: March 07, 2014, 01:30:55 pm
The results not wrong you are. The C language has been around since the 1970's and gcc the (compiler used by the IDE) has been around for many years - so any bugs which a newbie would find are long gone!

Converting (casting) to int allways rounds down.

Mark
But where do i convert to a int?
3  Using Arduino / Programming Questions / Re: Reverse calculation gives wrong result on: March 07, 2014, 01:29:28 pm
Shouldn't xResult be a float ?
No not according to the AccelStepper library documentation, it should be a long.
http://www.airspayce.com/mikem/arduino/AccelStepper/classAccelStepper.html#ace236ede35f87c63d18da25810ec9736
4  Using Arduino / Programming Questions / Reverse calculation gives wrong result on: March 07, 2014, 11:38:31 am
In the code below i first calculate the number of steps a stepper should step according to the degrees value.
Code:
char     xDishBuffer[8]     = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

int      xGearRatio        =  42;          // stepper ratio per X degree of rotation (1:42)
int      xMicroSteps       =   2;          // Value of the microsteps
                                                         // Posible value's are 1, 2, 4, 8 and 16

typedef enum {
  X_ROTOR, Y_ROTOR
}
stepperfn;

long deg2step( float degrees, stepperfn stepper );
long deg2step( float degrees, stepperfn stepper ) {
  if (stepper == X_ROTOR) return (( degrees / 1.8) * xMicroSteps * xGearRatio);
  if (stepper == Y_ROTOR) return ((-degrees / 1.8) * yMicroSteps * yGearRatio);
}

long xResult = 0;
float xxResult ;

void setup() {
  Serial.begin(19200);                     // Start the Serial communication
  while (!Serial);

  xResult = deg2step(99.99, X_ROTOR);
  Serial.println(xResult);

  xxResult = xResult / xGearRatio / xMicroSteps * 1.8;
  dtostrf(xxResult, 7, 2, xDishBuffer);  // Make it alse printable
  Serial.println(xDishBuffer);
}

void loop() {
  // put your main code here, to run repeatedly:

}
With 99.99 degrees the result = 4666(.2) steps.
If i reverse the calculation the result should be almost equals 99.99 but printed is 99.00.

Maybe i use the wrong types but how to solve this?
5  Using Arduino / Motors, Mechanics, and Power / How to reset when external power is switched on on: March 07, 2014, 08:08:59 am
The problem is as follows, The Arduino is powered true its USB connection where the DTR connection is taken out the equation.
This is due that every time under windows8, when a USB device is connected/disconnected, the Arduino would reset.

The Arduino controls two steppers and there is no feedback on their position other than several limit switches.
Both steppers are powered by a power supply and has no connection to the Arduino, the steering interface is true OPTO.

But the problem is that is the main power is interrupted when the steppers should move, the possition in the Arduino would be different from the actual position.
So what i need is a means to tell the Arduino to reset after a power fail.
Any suggestions are welcome.

Harry
6  Using Arduino / Programming Questions / Emergency stop with AccelStepper on: March 07, 2014, 07:57:55 am
As i am trying to include a emergency stop imy sketch i do ran into a problem with the AccelStepper libray.

It has the function stepper.stop() with stops the stepper as fast as possible.
In m.h.o. that would be a direct stop as i want to use it as a emergency stop if the movement runs into a limit switch.
But is doesn't, its slows down and then stops.

Any suggestions how to solve this problem?

Harry
7  Using Arduino / Programming Questions / Re: Wire requestFrom compiler problem on: March 05, 2014, 04:24:27 pm
Hi M<ark,

What i don't understand is the fact that i used this for the I2C RTC1307 and the I@C serial as wel and that works fine.

Harry
8  Using Arduino / Programming Questions / Wire requestFrom compiler problem on: March 05, 2014, 02:07:26 pm
I have a simple code example that produces error
Code:
#include <Wire.h>
byte     KeypadAddress     = 0x20;         // Only used if available       

void setup() {
  // put your setup code here, to run once:
Wire.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
Wire.requestFrom(KeypadAddress, 1);
}
Gives this error message:
Quote
sketch_mar05b.ino: In function 'void loop()':
sketch_mar05b.ino:11: error: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:58: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:56: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

If i change in loop keypadAddress in 0x20 the sketch compiles with no error.
Anny suggestions?
9  Using Arduino / Programming Questions / Re: dtostrf not givving desired result on: February 27, 2014, 10:18:22 am
O stupid me, your correct.
The values should have been 123.45 and 89.99. It now works after some extra adapting e.g.:
Code:
char     xStrBuffer[8]     = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
char     yStrBuffer[8]     = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
So i know that the last character is always zero
10  Using Arduino / Programming Questions / dtostrf not givving desired result on: February 27, 2014, 09:17:49 am
This little skech gives me headache:
Code:
char     xStrBuffer[7]   = "";
char     yStrBuffer[7]   = "";

float    newXAxis          =  0L;   // Holds the new value where the dish should point to
float    newYAxis          =  0L;

void setup() {
  Serial.begin(115200);                    // Start the Serial communication
  while(!Serial);

      dtostrf(newXAxis,7, 2, xStrBuffer);    // Create the  x value to print
      dtostrf(newYAxis,7, 2, yStrBuffer);    // Create the y value to print

      Serial << xStrBuffer << endl;     // Print only the x value
      Serial << xStrBuffer <<  " -" << yStrBuffer << endl;     // Print both x and y values
}

void loop() {
}

The result of first print looks like :  123.45  89.99
And the  second print looks like  :  123.45  89.99 -  89.99

Did i mis something here? And if so what.

Harry
11  Using Arduino / Programming Questions / Re: Need help with AccelStepper sketch on: February 24, 2014, 05:53:49 am
Is there some reason to be using AccelStepper? That library is intended for situations where you need to be able to run two steppers simultaneously. Since you block until the stepper gets to the new position, anyway, using Stepper would seem to make more sense.
As the resulting sketch is for two steppers, but in the building fase i am only working on one stepper and then copying it for the second step[per.
12  Using Arduino / Motors, Mechanics, and Power / Re: Determinating max stepper speed. on: February 24, 2014, 05:49:56 am
OK i understand that, but then how can i create a correct sketch using AccelStepper. h commands:
Code:
// Steppers , see AccelStepper documotation for more information
AccelStepper stepperX(1,XAxisPWM,XAxisDIR);
AccelStepper stepperY(1,YAxisPWM,YAxisDIR);
int xMotorSpeed            = 500;  // Maximum steps per second
int yMotorSpeed            = 500;  // Maximum steps per second
int xMotorAccel            =  25;  // Steps per second for acceleration
int yMotorAccel            =  25;  // Steps per second for acceleration

void setup() {
  stepperX.setMaxSpeed(xMotorSpeed);        // Set the X rotor-motor maximum speed
  stepperX.setAcceleration(xMotorAccel);    // Set the X rotor-motor acceleration speed
  stepperY.setMaxSpeed(yMotorSpeed);        // Set the Y rotor-motor maximum speed
  stepperY.setAcceleration(yMotorAccel);    // Set the Y rotor-motor acceleration speed
}

So how should determinate the relationship between the two?
13  Using Arduino / Motors, Mechanics, and Power / Determinating max stepper speed. on: February 21, 2014, 07:00:51 am
I have a stepper, 23LC051-025-8W, controlled by a M415C controller.
As the data sheet has no information about the max speed that this stepper can reach, is there a method or sketch to determinate the maximum speed and acceleration using AccelStepper library.

Regards

Harry
14  Using Arduino / Programming Questions / Need help with AccelStepper sketch on: February 21, 2014, 06:49:04 am
Trying to mover a stepper-motor first to a predefined hardware position with a photo-interrupter i ran into a programming problem.
I wil post the complete sketch as far i have now in this post starting with the setup and loop.
Code:
// LIBRARIES
#include "Arduino.h"
#include <Wire.h>
#include <AccelStepper.h>          // http://www.airspayce.com/mikem/arduino/AccelStepper/index.html

// Arduino version compatibility Pre-Compiler Directives
#if defined(ARDUINO) && ARDUINO >= 100   // Arduino v1.0 and newer
#define I2C_WRITE Wire.write
#define I2C_READ Wire.read
#else                                   // Arduino Prior to v1.0
#define I2C_WRITE Wire.send
#define I2C_READ Wire.receive
#endif

// PINS
int YAxisDIR = 13;      // Stepper direction output
int XAxisDIR = 12;
int YAxisPWM = 11;      // Stepper steps output
int XAxisPWM = 10;

int yStopper1 = 5;      // Y Rotor end stops
int yStopper2 = 4;
int xStopper1 = 3;      // X Rotor end stops
int xStopper2 = 2;

// DEGREES / STEPS CONVERSION
float stepsPerRotation = 200;   // 200 steps per rotation (1.8 degrees per step)
int xGearRatio = 42;            // stepper degrees per pan degree of rotation
int yGearRatio = 42;            // stepper degrees per tilt degree of rotation + calibration factor
int xMicroSteps = 1;
int yMicroSteps = 1;

typedef enum {
  X_ROTOR, Y_ROTOR }
stepperfn;

long deg2step( float degrees, stepperfn stepper );
long deg2step( float degrees, stepperfn stepper ) {
  if(stepper == X_ROTOR) return (( degrees/1.8)*xMicroSteps*xGearRatio);
  if(stepper == Y_ROTOR) return ((-degrees/1.8)*yMicroSteps*yGearRatio);
}
// VARIABLES
typedef enum {
  CALIBRATE, NEUTRAL, TRACKING, RESET}
states;    // Posible states inside the program
states state = CALIBRATE;    // Default state is calibration at startup

int xStop1 = 0;    // Holds the switches digitalRead result
int xStop2 = 0;
int yStop1 = 0;
int yStop2 = 0;

boolean  hitXStop = false;
boolean  hitYStop = false;
boolean  xCentered = false;
boolean  yCentered = false;

// Steppers , see AccelStepper documotation for more information
AccelStepper stepperX(1,XAxisPWM,XAxisDIR);
AccelStepper stepperY(1,YAxisPWM,YAxisDIR);
int xMotorSpeed = 500;  // Maximum steps per second
int yMotorSpeed = 500;  // Maximum steps per second
int xMotorAccel = 8000;  // Steps per second for acceleration
int yMotorAccel = 8000;  // Steps per second for acceleration

// The setup function is only called once
void setup() {

  pinMode(yStopper1, INPUT_PULLUP );      // Initialize the switches inputs
  pinMode(yStopper2, INPUT_PULLUP );      // The internal resistors are made active
  pinMode(xStopper1, INPUT_PULLUP );
  pinMode(xStopper2, INPUT_PULLUP );

  stepperX.setMaxSpeed(xMotorSpeed);        // Set the X rotor-motor maximum speed
  stepperX.setAcceleration(xMotorAccel);    // Set the X rotor-motor acceleration speed
  stepperY.setMaxSpeed(yMotorSpeed);        // Set the Y rotor-motor maximum speed
  stepperY.setAcceleration(yMotorAccel);    // Set the Y rotor-motor acceleration speed

}    // End setup()

void loop() {
  readSwitches();
  switch(state) {
// Calibrate the system. Called at program startup. At theend the dish points upwards.
    case(CALIBRATE):
      calibrateSystem();
   
    break;

  } // End state

}    // End loop()
As the system must be calibrated after a power loss the first thing to do is to run to a end-stop. These  are a photo-interrupter at either end of the 180 degrees sweep. These are read with a simple routine:
Code:
void readSwitches() {
  xStop1 = digitalRead(xStopper1); 
  xStop2 = digitalRead(xStopper2); 
}
When a interrupter is activated it changes from LOW to HIGH.
This is checked in this part:
Code:
void calibrateSystem() {
// See if any switches are active, else run the steppers
  if(hitXStop == false)  stepperX.moveTo(deg2step(-200, X_ROTOR));
 
// If a switch is activate determinate the position and save it
  if(xStop1 == HIGH && hitXStop == false) {
    stepperX.stop();

    stepperX.setCurrentPosition(deg2step(180, X_ROTOR));
    stepperX.moveTo(deg2step(90, X_ROTOR));
  }
  else if(xStop2 == HIGH && hitXStop == false) {
    stepperX.stop();
    stepperX.setCurrentPosition(deg2step(0, X_ROTOR));
    stepperX.moveTo(deg2step(90, X_ROTOR));
  }
 
  stepperX.run();
}
But  after it hits the end stop the stepper wont move to the 90 degrees position but it goes for and backwards.
Any insight is welcome.

Harry
15  Using Arduino / Programming Questions / Using accelstepper and a I2C display on: February 11, 2014, 02:45:30 pm
I am trying to get my steppers running using the accelstepper library.
Also having a I2C display connected to the system.
But if i want to run the motor at some speed i notice that the motor is not running continuously but its looks that there is a pause in the movement.

Is this normal behaviour using this library and if so how should i solve this?.
All the examples, they have not much code, are running normal.

Harry
Pages: [1] 2 3 ... 15