rickysinho 1 Posted March 31, 2013 Share Posted March 31, 2013 I have had some problems in using srf10 and energia, because with msp430 and the stellaris, can only measure values ??below 110 cm, and values ??between 60 cm and 110 cm, are unstable.here is my code for the stellaris. for msp430 is the same by removing only the functions setmodule of stellaris. #include <Wire.h> TwoWire Wire1; void setup() { Wire1.setModule(1); Wire1.begin(); Serial.begin(9600); } byte highByte = 0x00; // Stores high byte from ranging byte lowByte = 0x00; int reading = 0; int range = 0; void loop() { Wire.beginTransmission(120); // Start communticating with SRF08 Wire.write(0x00); // Send Command Byte Wire.write(0x51); // Send 0x51 to start a ranging Wire.endTransmission(); delay(100); // Wait for ranging to be complete Wire.beginTransmission(120); // start communicating with SRFmodule Wire.write(0x02); // Call the register for start of ranging data Wire.endTransmission(); Wire.requestFrom(120, 2); // Request 2 bytes from SRF module while(Wire.available() < 2); // Wait for data to arrive highByte = Wire.read(); // Get high byte lowByte = Wire.read(); // Get low byte range = (highByte << 8) + lowByte; // Put them together Serial.print(range); Serial.println(); delay(25); } also made ??some changes in the wire library of stellaris, to this work. was only a change of frequency, they are this: line 242 before:wire.cpp ROM_I2CMasterInitExpClk(MASTER_BASE, ROM_SysCtlClockGet(), false);//max bus speed=400kHz for gyroscope after: wire.cpp ROM_I2CMasterInitExpClk(MASTER_BASE, ROM_SysCtlClockGet()/1.4, false);//max bus speed=400kHz for gyroscope where is the error? Quote Link to post Share on other sites
L.R.A 78 Posted April 1, 2013 Share Posted April 1, 2013 i say again. i remember that sensor being tested the last year with basicx or picaxe. it's broken. it only gave short ranges and a little off. all values over 60cm are just errors btw Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.