Açıklama Yok

adis16448.js 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //////////////////////////////////////////////////////////////////////////////////////
  2. // The MIT License (MIT)
  3. //
  4. // Submit Date: 03/09/2015
  5. // Author: Juan Jose Chong <juanjchong@gmail.com>
  6. // Copyright (c) 2015 Juan Jose Chong
  7. //
  8. //////////////////////////////////////////////////////////////////////////////////////
  9. // adis16448.js
  10. //////////////////////////////////////////////////////////////////////////////////////
  11. //
  12. // This example code runs on an Intel Edison and uses mraa to acquire data
  13. // from an ADIS16448. This data is then scaled and printed onto the terminal.
  14. //
  15. // This software has been tested to connect to an ADIS16448 through a level shifter
  16. // such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired through
  17. // the level shifter and the ADIS16448 is also being powered by the Intel Edison.
  18. //
  19. // Permission is hereby granted, free of charge, to any person obtaining
  20. // a copy of this software and associated documentation files (the
  21. // "Software"), to deal in the Software without restriction, including
  22. // without limitation the rights to use, copy, modify, merge, publish,
  23. // distribute, sublicense, and/or sell copies of the Software, and to
  24. // permit persons to whom the Software is furnished to do so, subject to
  25. // the following conditions:
  26. //
  27. // The above copyright notice and this permission notice shall be
  28. // included in all copies or substantial portions of the Software.
  29. //
  30. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  31. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  32. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  33. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  34. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  35. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  36. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  37. //
  38. //////////////////////////////////////////////////////////////////////////////////////
  39. //Call the ADIS16448 library
  40. var adis16448 = require('jsupm_adis16448');
  41. //Instantiate SPI and Reset
  42. var imu = new adis16448.ADIS16448(0,3);
  43. periodicActivity(); //Call the periodicActivity function
  44. function periodicActivity()
  45. {
  46. //Read & Scale Gyro/Accel Data
  47. var xgyro = imu.gyroScale(imu.regRead(0x04));
  48. var ygyro = imu.gyroScale(imu.regRead(0x06));
  49. var zgyro = imu.gyroScale(imu.regRead(0x08));
  50. var xaccl = imu.accelScale(imu.regRead(0x0A));
  51. var yaccl = imu.accelScale(imu.regRead(0x0C));
  52. var zaccl = imu.accelScale(imu.regRead(0x0E));
  53. //Display Scaled Data on the Console Log
  54. console.log('XGYRO: ' + xgyro);
  55. console.log('YGYRO: ' + ygyro);
  56. console.log('ZGYRO: ' + zgyro);
  57. console.log('XACCL: ' + xaccl);
  58. console.log('YACCL: ' + yaccl);
  59. console.log('ZACCL: ' + zaccl);
  60. console.log(' ');
  61. setTimeout(periodicActivity,200); //call the indicated function after 0.2 seconds (200 milliseconds)
  62. }