Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / Re: HURRYYY EZ0 STOP WORKING SUDDENLY on: July 26, 2011, 08:53:38 am
CrossRoads, robtillaart, AWOL, cyclegadget thanks to all for the replys, just now I´m be able to response and thanks all for the tips. I agree with the lack of info that I posted, I was in a hurry. Finally I solved the problem, it was a bad wire thats was affecting the hole connection.

Thanks again for the quick replys, always great support from the arduino forum.

2  Using Arduino / Sensors / HURRYYY EZ0 STOP WORKING SUDDENLY on: July 15, 2011, 09:02:54 pm
I was working with 3 MaxSonic range finders and arduino duemilanove, getting a good quality ranging, and suddenly stop working, I mean is reading unsense reading.

I`m in a bit a a hury... any idea why or most important how to solve this...

URGENT....

thanks in advence

3  Using Arduino / Sensors / Re: Wizard reading from the SFR02 Ultrasonic range finder on: June 09, 2011, 02:33:23 pm
I´m being doing some tests and now is given me right values from 16 cm away until 27 cm, but as soon as I try beyond 27 cm, it´s begin to reply with the fake 16 cm measurament .

I´m using a 100uf cap in parallel with the range finder to smooth it's power supply. As is recomend in the SFR02 Sonic Range Finder Reader Tutorial. But it didn´t make a diference about de ranging.

( http://arduino.cc/en/Tutorial/SFRRangerReader ).

Rob, the length of the 12C wire is less than 10 cm, but I planed to use longer wiring, so I´ll test with the 4.7k to check if I could get better results.

If doesn´t  work, i´ll try via serial as jraskell suggest.

4  Using Arduino / Sensors / Re: Wizard reading from the SFR02 Ultrasonic range finder on: June 07, 2011, 08:05:56 pm
Rob, Thanks for the reply. I re checked the datasheet, the  complete measurement cycle is 65ms, and recommends 70 ms delay between readings. Also said that the SFR02 doesn´t response to any command  on the I2C bus whilst it is ranging, so I have no clue by is getting this 16cm false measurement.


About the shout, was a mistake. didn´t see it.

Any tip or advice to give it a try?

5  Using Arduino / Sensors / Wizard reading from the SFR02 Ultrasonic range finder on: June 06, 2011, 01:19:39 pm
Hi, I´m working with the SFR02 Ultrasonic Range Finder (Devantech). And is given me one real measurement and then repeat 16 cm fake measurement four or five times, and then another real measurement. So this fake measurement doesn´t allow me to get a continous real mesurement.

HOW CAN I ABOID THIS 16 CM  FAKE MEASUREMENT ?, ANY CLUE, THANKS.

SFR02 Spec.

Range detection 16 cm to 600 cm

I use this code
Code:
*/

// include Wire library to read and write I2C commands:

#include <Wire.h>

// the commands needed for the SRF sensors:

#define sensorAddress 0x70

#define readInches 0x50

// use these as alternatives if you want centimeters or microseconds:

#define readCentimeters 0x51

#define readMicroseconds 0x52

// this is the memory register in the sensor that contains the result:

#define resultRegister 0x02

void setup()

{

  // start the I2C bus

  Wire.begin();

  // open the serial port:

  Serial.begin(9600);

}

void loop()

{

  // send the command to read the result in inches:

  sendCommand(sensorAddress, readCentimeters);

  // wait at least 70 milliseconds for a result:

  delay(70);

  // set the register that you want to reas the result from:

  setRegister(sensorAddress, resultRegister);

// read the result:

  int sensorReading = readData(sensorAddress, 2);

  // print it:

  Serial.print("distance: ");

  Serial.print(sensorReading);

  Serial.println(" Centimeters");

  // wait before next reading:

  delay(70);

}

/*

  SendCommand() sends commands in the format that the SRF sensors expect

 */

void sendCommand (int address, int command) {

  // start I2C transmission:

  Wire.beginTransmission(address);

  // send command:

  Wire.send(0x00);

  Wire.send(command);

  // end I2C transmission:

  Wire.endTransmission();

}

/*

  setRegister() tells the SRF sensor to change the address pointer position

 */

void setRegister(int address, int thisRegister) {

  // start I2C transmission:

  Wire.beginTransmission(address);

  // send address to read from:

  Wire.send(thisRegister);

  // end I2C transmission:

  Wire.endTransmission();

}

/*

readData() returns a result from the SRF sensor

 */

int readData(int address, int numBytes) {

  int result = 0;        // the result is two bytes long

// send I2C request for data:

  Wire.requestFrom(address, numBytes);

  // wait for two bytes to return:

  while (Wire.available() < 2 )   {

    // wait for result

  }

  // read the two bytes, and combine them into one int:

  result = Wire.receive() * 256;

  result = result + Wire.receive();

  // return the result:

  return result;

}
6  Using Arduino / Sensors / Re: Need help with SPI + accelerometer on: April 15, 2011, 11:31:08 am
Those are probably not doing what you think they are doing.  smiley

digitalWrite and digitalRead will set an Arduino pin HIGH or LOW.

0x15 is a decimal value of 21 and your basic Arduino doesn't have a Pin 21.

I suspect you are trying to set a register but you will need SPI transfers for that.

In your accelerometer, register 0x15 is the upper three bits of the "Offset drift Z value" and has nothing to do with an "SPI mode".

You right, about digitalWrite and 0x15, nothing to do with what I want.

Your results don't change because you have no code in loop() to change x, y, or z.  You just send them out, wait 10 milliseconds, and repeat.  You probably want to read the data registers from the accelerometer to get values for X, Y and Z.  You can just read the 8-bit values to start (registers 0x07, 0x08, and 0x09).  Once that works you can try reading the 10-bit versions: 0x00/0x01, 0x02/0x03, 0x04/0x05.

I added a code for the loop, still not working, but no quick sure why. Is the loop code the bug or are there more bugs in the rest?

Code:
//Add the SPI library so we can communicate with the MMA7455L sensor
#include <SPI.h>

//Assign the Chip Select signal to pin 10.
int CS=10;

//This buffer will hold values read from the MMA7455L registers.
char values[6];
//These variables will be used to hold the x,y and z axis accelerometer values.
int x,y,z;

//This is a list of some of the registers available on the MMA7455L.
char DATAX0 = 0x00; //X-Axis 10 bits output Data LSB
char DATAX1 = 0x01; //X-Axis 10 bits output Data MSB
char DATAY0 = 0x02; //Y-Axis 10 bits output Data LSB
char DATAY1 = 0x03; //Y-Axis 10 bits output Data MSB
char DATAZ0 = 0x04; //Z-Axis 10 bits output Data LSB
char DATAZ1 = 0x05; //Z-Axis 10 bits output Data MSB
char XOUT8  = 0x06;     //X-Axis 8 bits output Data
char YOUT8  = 0x07;     //Y-Axis 8 bits output Data
char ZOUT8  = 0x08;     //Z-Axis 8 bits output Data

void setup()
{
    //Initiate an SPI communication instance.
  SPI.begin();
   //Create a serial connection to display the data on the terminal.
  Serial.begin(9600);
   //Set up the Chip Select pin to be an output from the Arduino.
  pinMode(CS, OUTPUT);
   //Before communication starts, the Chip Select pin needs to be set high.
  digitalWrite(CS, HIGH);
 
  writeRegister(0x16, 0x01); //to set the accelerometer into 2g measurement mode.
}

void loop(){ 
 
  //The results of the read operation will get stored to the values[] buffer.
  readRegister(XOUT8, 3, values);

  //The X value is stored in values[6].
  x = ((int)values[6] << 1);
  //The Y value is stored in values[7].
  y = ((int)values[7] << 1);
  //The Z value is stored in values[8].
  z = ((int)values[8] << 1);
 
  //Print the results to the terminal.
  Serial.print(x, DEC);
  Serial.print(',');
  Serial.print(y, DEC);
  Serial.print(',');
  Serial.println(z, DEC);     
  delay(10);
 
 
}
// To write a register:
  void writeRegister(char registerAddress, char value){
     
digitalWrite(CS, LOW);
SPI.transfer(registerAddress << 1);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}

  //To read a register:
void readRegister(char registerAddress, int numBytes, char * values){
    //Since we're performing a read operation, the most significant bit of the register address should be set.
char address = (0x80 | registerAddress << 1);

digitalWrite(CS, LOW);
SPI.transfer(address);
    //Continue to read registers until we've read the number specified, storing the results to the input buffer.
  for(int i=0; i<numBytes; i++){
    values[i] = SPI.transfer(0);
  }
digitalWrite(CS, HIGH);
}
7  Using Arduino / Sensors / Re: Need help with SPI + accelerometer on: April 13, 2011, 11:31:30 am
john, thanks for the reply

I read the page 18 of the datasheet, but I´m still confuse. this is what I got, but I´m still not getting any result. I´m not sure where is the problem.

Code:
#include <SPI.h>

//Assign the Chip Select signal to pin 10.
int CS=10;

//These variables will be used to hold the x,y and z axis accelerometer values.
int x,y,z;

//This is a list of some of the registers available on the MMA7455L.
char DATAX0 = 0x00; //X-Axis Data 0
char DATAX1 = 0x01; //X-Axis Data 1
char DATAY0 = 0x02; //Y-Axis Data 0
char DATAY1 = 0x03; //Y-Axis Data 1
char DATAZ0 = 0x04; //Z-Axis Data 0
char DATAZ1 = 0x05; //Z-Axis Data 1


void setup(){
 
  //Initiate an SPI communication instance.
  SPI.begin();
  //Configure the SPI connection.
  digitalWrite(0x15, 0x05); //to set the accelerometer into SPI 4 wire mode 2g measurement mode.
  digitalRead(0x16);  //Read the Control Register $16 to ensure that the value is correct (0x05).
 
  //Create a serial connection to display the data on the terminal.
  Serial.begin(9600);
 
  //Set up the Chip Select pin to be an output from the Arduino.
  pinMode(CS, OUTPUT);
  //Before communication starts, the Chip Select pin needs to be set high.
  digitalWrite(CS, HIGH);
 
}

void loop(){ 
 
  //Print the results to the terminal.
  Serial.print(x, DEC);
  Serial.print(',');
  Serial.print(y, DEC);
  Serial.print(',');
  Serial.println(z, DEC);     
  delay(10);
}
// To write a register:
  void writeRegister(char registerAddress, char value){
     
digitalWrite(CS, LOW);
SPI.transfer(0x80 | (registerAddress << 1));
SPI.transfer(value);
digitalWrite(CS, HIGH);
}

  //To read a register:
void readRegister(char registerAddress, int numBytes, char * values){
    //Since we're performing a read operation, the most significant bit of the register address should be set.
char address = 0x80 | registerAddress;

digitalWrite(CS, LOW);
SPI.transfer(registerAddress << 1);
for(int i=0; i<numBytes; i++){
values[i] = SPI.transfer(0);
}
digitalWrite(CS, HIGH);
}

I´m trying to get this working for a while (I´m not a pro) and is getting annoying.

any help will be great.
 
 
8  Using Arduino / Sensors / Need help with SPI + accelerometer on: April 11, 2011, 02:52:25 pm
Hi, I´m working in a project. and I´m trying to use a freescale MMA7455l accelerometer that I´ve got. I´m using a code for the ADXL345 accelerometer from http://www.sparkfun.com/tutorials/240 to test my accelelrometer. I already chance some of the registers adresses with the ones on the MMA7455L datasheet.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MMA745xL&tab=Documentation_Tab&linkline=Data%20Sheets&fpsp=1.

CODE QUESTION? - this appear in the code...

//Since we're performing a read operation, the most significant bit of the register address should be set.
  char address = 0x80 | registerAddress;
  //If we're doing a multi-byte read, bit 6 needs to be set as well.
  if(numBytes > 1)address = address | 0x40;


I know that this lines correspond to the ADXL345 accelerometer datasheet, but don´t know the equivalent for the MMA7455L. I Don´t undestand what this lines are for and if I need to use it for my accelerometer.

First time trying with an accelerometer, not quite easy at first. Any help, tips or docs will be appreciate.


Thanks in advance
9  Using Arduino / Motors, Mechanics, and Power / Re: Fluid motion with servo, is it possible? on: April 11, 2011, 09:11:04 am
KE7GKP
I´ll cheked the crank

thanks for the tips
10  Using Arduino / Motors, Mechanics, and Power / Re: Fluid motion with servo, is it possible? on: April 07, 2011, 02:28:24 pm
Not clear what "that" refers to?  Please be more specific.
[/quote]

I mean, If I used in arduino a Smoothstep function for a servo or a stepper gives the same result of sinusoidal motion?, Why you prefer a crank instead of stepper or servo?, is it simpler and gives better results?

Thanks


11  Using Arduino / Motors, Mechanics, and Power / Re: Fluid motion with servo, is it possible? on: April 07, 2011, 01:31:41 pm
No, I meant the mechanical solution: the cam or crank or "bellcrank".

Ok, If I use a crank for example, this gives me a sinusoidal motion using a constant speed, but I´m planing to use the motor motion for an animatronic wire tail, so I´m looking to resolve it from the programing instead of using another mechanism, because I have the animatronic wiring already .


Do you think using Smoothstep function could solve that?
12  Using Arduino / Motors, Mechanics, and Power / Re: Fluid motion with servo, is it possible? on: April 07, 2011, 12:42:54 pm
Quote
You are all doing this the hard way IMO. I would rig up a mechanical bellcrank apparatus, and then a simple constant-speed motor will give perfect sinusoidal motion.

Exactly what I suggested back in Reply #1.  But Pitu never responded or even acknowledged the concept.   smiley-confuse

KE7GKP, as you said, I tried with a mathematical function, like the Smoothstep function. Did you mean something like that?

What you mean with " look-up table to create this more "organic" motion"?

Thanks
13  Using Arduino / Motors, Mechanics, and Power / Re: Fluid motion with servo, is it possible? on: April 07, 2011, 12:39:20 pm
Code:
  for (i = 180; i >= N; i++)

Because N = 180, this loop will not end for a LONG time

Code:
     {
       myservo.write(A);    // move servo1 to 'A'
     }
These are OUTSIDE the FOR loops so you are doing 180 calculations and moving the servo once?  Makes no sense to me.

Serial.print("  ");           //Puts a space between each line of steps and their corresponding  float value
    Serial.println(X);            // prints the soothstepped value
  }

[/quote]

john, your right. I was mixup with the code, I`ll start all over

14  Using Arduino / Motors, Mechanics, and Power / Re: Fluid motion with servo, is it possible? on: April 04, 2011, 01:33:56 pm
Only an opinion but might be worth consideration.
Ideally you need to use a stepper motor rather than a servo.  With the stepper you can define EXACTLY what the motor does with respect to position and speed - two essentials for fluid movement.  A servo, unfortunately, is a compromise between position and speed, try to move it too fast or just a little and you will get both overshoot and /or jerkiness.  In control system terms, a servo's performance is optimised under one set of conditions, whereas for fluid movement you require optimal performance under many different conditions.

jackrae, thanks for the tips., I ´ll checked about steppers to see if the best option for fluid motion. Any kind of stepper could work, any suggestion?

thanks

15  Using Arduino / Motors, Mechanics, and Power / Re: Fluid motion with servo, is it possible? on: April 04, 2011, 01:29:38 pm
Can't see all the source there - could you please post it?


#define SMOOTHSTEP(x) ((x) * (x) * (3 - 2 * (x))) //SMOOTHSTEP expression.
#include <Servo.h>

Servo myservo;          // create servo object to control a servo
int j = 0;             //Just an Iterator.
int i = 0;             //Just another Iterator.
float A = 0;         //Input Min Value
float B = 180;       //Input Max Value
float X;               //final smoothstepped value
float v;               //smoothstep expression variable
float N = 180;       //number of steps

void setup() {
Serial.begin(9600);  //establish serial connection for debugging
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop(){

  if (i < N)                      // Keep looping until we hit the pre-defined max number of steps

  for (i = 0; i < N; i++){

  v = i / N;
  v = SMOOTHSTEP(v);
  X = (A * v) + (B * (1 - v));
     }
     {
      myservo.write(B);              // tell servo to go to position in variable 'B'
     }     
  for (i = 180; i >= N; i++){

  v = i / N;
  v = SMOOTHSTEP(v);
  X = (A * v) + (B * (1 - v));
     }
     {
       myservo.write(A);    // move servo1 to 'A'
     }
Serial.print("  ");           //Puts a space between each line of steps and their corresponding  float value
    Serial.println(X);            // prints the soothstepped value
  }
Pages: [1] 2