Coder Social home page Coder Social logo

urm37's People

Contributors

nkrkv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

urm37's Issues

Ошибка при подключении нескольких устройств

При подключении нескольких устройств URM37 на одном из устройств(последнее проинициализированное устройство будет работать) при чтении появляется ошибка timeout.

ide: arduino 1.0, на старых версиях 2 urm37 работали нормально.

Скетч
{code}

include <SoftwareSerial.h>

include <URMSerial.h>

// LEFT sensor

define URM_LEFT_TXD_PIN 11

define URM_LEFT_RXD_PIN 10

// Right sensor

define URM_RIGHT_TXD_PIN 8

define URM_RIGHT_RXD_PIN 9

URMSerial urmLeft;
URMSerial urmRight;

int value; // This value will be populated

void setup()
{
delay(100);
Serial.begin(9600); // Sets the baud rate to 9600
urmLeft.begin(URM_RIGHT_TXD_PIN, URM_RIGHT_RXD_PIN,9600); // TX Pin, RX Pin, Baud
delay(100);
urmRight.begin(URM_LEFT_TXD_PIN, URM_LEFT_RXD_PIN,9600); // RX Pin, TX Pin, Baud Rate
}

void loop()
{
delay(500);
Serial.print("Measurement left: ");
Serial.println(getMeasurement(urmLeft));
Serial.print("Measurement right: ");
Serial.println(getMeasurement(urmRight));
}

int getMeasurement(URMSerial urm)
{
switch(urm.requestMeasurementOrTimeout(DISTANCE, value)) // Find out the type of request
{
case DISTANCE: // Double check the reading we recieve is of DISTANCE type
return value;
break;
case TEMPERATURE:
return value;
break;
case ERROR:
Serial.println("Error");
break;
case NOTREADY:
Serial.println("Not Ready");
break;
case TIMEOUT:
Serial.println("Timeout");
break;
}

return -1;

}
{/code}

Константа 255 выглядит подозрительно

Если имелся ввиду сдвиг на 8, то умножать следует на 256:
(gdb) p/x 0xbe * 255 + 0xef
$17 = 0xbe31
(gdb) p/x 0xbe * 256 + 0xef
$18 = 0xbeef

byte URMSerial::processDistance(int& value)
{
....
// 1x16bit value wrapped over two bytes
// HighByte must be multiplied by 255 to represent the correct byte
// Both are added together to calculate the value in Centimeters (I believe)
value = serialData[HighByte]*255+serialData[LowByte];
return DISTANCE;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.