PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : SRF10



honighamster
24.04.2009, 18:40
Hallo,
ich habe einen SRF10 bekommen :D
Ich habe alles super angeschlossen und erstmal ein Testprogramm gestartet.
Ich glaube es war Base_I2CMaster3.
Es funktionierte alles der SRF10 hat auf Entfernungen reagiert.
Leider misst er nur bis 50 cm.
Das sollte aber nicht so sein!
In der Beschreibung standt 6cm-6m.
Kann man das Ändern?
Gruß honighamster

sechsrad
25.04.2009, 15:04
Die Glaskugel ist kaputt.

honighamster
25.04.2009, 15:17
hmm was meinst du mit glaskugel?

Fabian E.
25.04.2009, 15:41
Er meint damit, dass du zu wenig Informationen gibts damit man was dazu sagen kann...

uwegw
25.04.2009, 15:53
Wie hast du die Reichweite und Verstärkung eingestellt?

honighamster
25.04.2009, 16:01
ok dann nochmal
ich habe mir das produkt : http://www.shop.robotikhardware.de/shop/catalog/product_info.php?products_id=121
gekauft.
Dann habe ich das SRF10 Modul an meinen RP6 über die Experimentier Platine angeschlossen.
Die hintere LED am SRF10 hat beim anmachen vom Rp6 kurz geleuchtet.(das soll auch so sein)
Nun habe ich dieses Beispielprogramm auf den Rp6 geladen:


/*
* ************************************************** **************************
* RP6 ROBOT SYSTEM - ROBOT BASE EXAMPLES
* ************************************************** **************************
* Example: I2C Master - Single SRF08/SRF10
* Author(s): Dominik S. Herwald
* ************************************************** **************************
* Description:
*
* This Example shows how to use a Devantech SRF08 or SRF10 with RP6Library
* (both sensors work nearly the same way, but SRF08 offers some additional
* features and seems to be more accurate sometimes - of course it is
* larger, but there's enough space on RP6).
*
* You may notice that the measurements fluctuate and that there are some error
* readings - this seems to be "normal" and you maybe need to filter these errors
* if you want to do obstacle avoiding with it.
* Simplest way is to calculate the average distance...
* ************************************************** **************************
*/

/************************************************** ***************************/
// Includes:

#include "RP6RobotBaseLib.h"


// IMPORTANT:

#include "RP6I2CmasterTWI.h" // Include the I²C-Bus Slave Library



/************************************************** ***************************/
// SRF08/SRF10:

// The I2C slave address of the SRF ranger - default is 0xE0, but you can
// change this when you use the function changeSRFAddr() below.
// Here we changed it to 0xE6 already:
#define SRF_ADR 0xE0



/************************************************** ***************************/
// I2C Event handlers:


// I2C Data request IDs:
#define MEASURE_US_LOW 0
#define MEASURE_US_HIGH 1

// The measured distance:
uint16_t distance;

/**
* This Function gets called automatically if all requested data has been received.
* You can identify your requests by giving them a unique dataRequestID for each
* device or even register you are reading from.
* Of course you don't need to use it like this - just look at the PCF8591 examples!
* But this allows you to do other things while the TWI Module fetches the
* data for you in the Background.
*/
void I2C_requestedDataReady(uint8_t dataRequestID)
{
uint8_t messageBuf[8];
static uint8_t dist_tmp;
switch(dataRequestID)
{
case MEASURE_US_HIGH: // High data register
// get received data ...
I2CTWI_getReceivedData(messageBuf, 2);
dist_tmp = (messageBuf[0]);
// ... and request low data byte:
I2CTWI_transmitByte(SRF_ADR, 3);
I2CTWI_requestDataFromDevice(SRF_ADR, MEASURE_US_LOW, 1);
break;
case MEASURE_US_LOW: // low data byte:
I2CTWI_getReceivedData(messageBuf, 2);
distance = messageBuf[0] + (dist_tmp << 8);

// ----------------------------------
// Output measured distance:
writeString_P("Distance: ");
writeInteger(distance, DEC);
writeString_P(" cm | ");
// show a simple text bargraph:
uint16_t dist_count;
for(dist_count = distance; dist_count > 4; dist_count-=2)
writeChar('#');
writeChar('\n');
// ... of course you can also use "distance" as a normal
// variable everywhere else in your program!
// ----------------------------------
break;
}
}

/**
* This function gets called automatically if there was an I2C Error like
* the slave sent a "not acknowledge" (NACK, error codes e.g. 0x20 or 0x30).
* The most common mistakes are:
* - using the wrong address for the slave
* - slave not active or not connected to the I2C-Bus
* - too fast requests for a slower slave
* Be sure to check this if you get I2C errors!
*/
void I2C_transmissionError(uint8_t errorState)
{
writeString_P("\nI2C ERROR --> TWI STATE IS: 0x");
writeInteger(errorState, HEX);
writeChar('\n');
}

/************************************************** ***************************/

/**
* The SRF needs some time to perform the measurements - here we use Stopwatch1
* to time the measurement actions.
*/
void task_SRF(void)
{
static uint8_t measureInProgress = false;
if(!measureInProgress) // Start measurement ONCE only
{
if(TWI_operation == I2CTWI_NO_OPERATION) // If there is no request in progress...
{
I2CTWI_transmit2Bytes(SRF_ADR, 0, 81); // 81 means return distance in cm
measureInProgress = true;
setStopwatch1(0);
}
}
else if(getStopwatch1() > 70) // 70ms (measurement delay)
{
I2CTWI_transmitByte(SRF_ADR, 2);
I2CTWI_requestDataFromDevice(SRF_ADR, MEASURE_US_HIGH, 1); // receive it
measureInProgress = false; // allow to start new measurement
setStopwatch1(0);
}
}


/************************************************** ***************************/
// Main - The program starts here:

int main(void)
{
initRobotBase();

I2CTWI_initMaster(100);
I2CTWI_setRequestedDataReadyHandler(I2C_requestedD ataReady);
I2CTWI_setTransmissionErrorHandler(I2C_transmissio nError);

setLEDs(0b111111);
mSleep(500);
setLEDs(0b000000);

// Use this to change the address of a SINGLE SRF with this
// address on the bus:
// changeSRF_addr(0xE0,0xE6);
// do not forget to delete/outcomment this again after you performed this once!

powerON();

startStopwatch1();

while(true)
{
task_SRF();
task_I2CTWI();
task_RP6System();
}
return 0;
}

Schließlich habe ich den SRF10 parallel zu einem 1 meter lineal gelegt ,das programm gestartet und mit einer cd hülle über das lieneal gefahren und die entfernung die ich auf dem lineal sah mit der entfernung im rp6 loder verglichen. es war fast perfekt.
Leider funktionierte dies nur bis 40 cm.
Ab 40 cm meter erkennt er keine entfernungen mehr,das heißt das er ab da nur noch 40 cm sagt.
Im datenblatt steht auch noch etwas von einer reichweiten veränderung und einer verstärkung der signale.
Dies beides habe ich auch ausprobiert in dem ich im main teil
dies eingebaut habe:



I2CTWI_transmit2Bytes(224, 1, 16);
I2CTWI_transmit2Bytes(224, 2, 255);

Das datenblatt ist hier:
http://www.robotikhardware.de/download/srf10doku.pdf

uwegw
25.04.2009, 18:15
Was zeigt er an, wenn du den Sensor in eine Richtung zeigen lässt, wo keine Hindernisse sind? Also zb aus dem Fenster zeigen lassen.
Der SRF10 ist sehr empfindlich. Es kann sein, dass in 40cm Entfernung irgendeine Stelle ist, wo was reflektiert wird. Auf dieser kurzen Distanz reicht schon eine minimale Unebenheit. Daher sollte man in so einem Fall die Empfindlichkeit des Sensors kleiner einstellen. Ich habe meinen SRF10 auf der niedrigsten Stufe stehen, das reicht immer noch für mehrere Meter.