找回密码
 马上注册

QQ登录

只需一步,快速开始

查看: 8183|回复: 10

动手焊接加速度传感器

  [复制链接]
发表于 2011-12-16 13:21:08 | 显示全部楼层 |阅读模式
参照http://bbs.cmnxt.com/thread-5847-1-1.html{自制数字三轴罗盘传感器(猪头猪脑)}动手焊了BMA180加速度传感器,不知道如何编写程序,将指南针的程序地址改了一下直接运行,发现x轴数据不对,Y和Z轴有用,请高手指导一下怎么做?
IMG_1417.JPG

IMG_1418.JPG


如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
发表于 2011-12-16 13:40:48 | 显示全部楼层
呵呵,能焊接LGA封装挺厉害啊,和你其他的电容电阻很不相称。
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

 楼主| 发表于 2011-12-16 13:51:30 | 显示全部楼层
糖伯虎 发表于 2011-12-16 13:40
呵呵,能焊接LGA封装挺厉害啊,和你其他的电容电阻很不相称。

呵呵,尝试了好多次才有用的
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

 楼主| 发表于 2011-12-16 13:55:49 | 显示全部楼层
就将0X3C改成0X80,下面就不会弄了!

  1. /************************************************************************/
  2. /*                                                                      */
  3. /* Program Name: Compass-Nx-demo.nxc */
  4. /* ===========================                                          */
  5. /* Adopted by [url=mailto:ypiggy@tom.com]ypiggy@tom.com[/url]                                            */
  6. /* 2011/09/21                                                           */
  7. /************************************************************************/
  8. #define SensorPort IN_1
  9. #define ADDR     0x80
  10. struct TriAxisData
  11. {
  12. int gX,gY,gZ;
  13. };
  14. void COMPASS_Init(byte port, byte i2cAddr)
  15. {
  16. byte cmdBuf[];
  17.   SetSensorLowspeed(port);
  18.   ArrayBuild(cmdBuf,i2cAddr,0x00,0x70);
  19. I2CWrite(port,0,cmdBuf);
  20.   int status = I2CCheckStatus(port);
  21.   while (status > NO_ERR)
  22.     status = I2CCheckStatus(port);
  23. ArrayBuild(cmdBuf,i2cAddr,0x01,0x20);
  24. I2CWrite(port,0,cmdBuf);
  25.   status = I2CCheckStatus(port);
  26.   while (status > NO_ERR)
  27.     status = I2CCheckStatus(port);
  28. ArrayBuild(cmdBuf,i2cAddr,0x02,0x00);
  29.   I2CWrite(port,0,cmdBuf);
  30.   status = I2CCheckStatus(port);
  31.   while (status > NO_ERR)
  32.     status = I2CCheckStatus(port);
  33. }
  34. byte COMPASS_ReadData(byte port, byte i2cAddr,TriAxisData &triData)
  35. {
  36.   byte message[];
  37.   byte buf[12];
  38.   int count;
  39.   byte nByteReady = 0;
  40. byte b;
  41.   SetSensorLowspeed(port);
  42.   ArrayBuild(message, i2cAddr, 0x03);
  43.   while (I2CStatus(port, nByteReady) ==  STAT_COMM_PENDING);
  44.   count = 6;
  45.   if(I2CBytes(port, message, count, buf)) {
  46.     triData.gX=buf[0]<<8;
  47.     triData.gX |= buf[1];
  48.     triData.gY=buf[2]<<8;
  49.     triData.gY |= buf[3];
  50.     triData.gZ=buf[4]<<8;
  51.     triData.gZ |= buf[5];
  52. }
  53. return b;
  54. }
  55. task main()
  56. {
  57.   string msg;
  58.   TriAxisData gData;
  59.   string ax, ay, az;
  60. COMPASS_Init(SensorPort,ADDR);
  61.   
  62.   while (true ) {
  63.   // read the values from the sensor.
  64.     COMPASS_ReadData(SensorPort, ADDR, gData);
  65.     msg = "X:            ";
  66.     ax = NumToStr(gData.gX);
  67.     msg = StrReplace(msg, 2, ax);
  68.     TextOut(0, LCD_LINE2, msg, false);
  69.     msg = "Y:            ";
  70.     ay = NumToStr(gData.gY);
  71.     msg = StrReplace(msg, 2, ay);
  72.     TextOut(0, LCD_LINE3, msg, false);
  73.     msg = "Z:            ";
  74.     az = NumToStr(gData.gZ);
  75.     msg = StrReplace(msg, 2, az);
  76.     TextOut(0, LCD_LINE4, msg, false);
  77.     Wait(50);
  78.   }
  79. }

复制代码

如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2011-12-16 14:26:36 | 显示全部楼层
请问插头在哪里买到的,我也想自己做些传感器
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

 楼主| 发表于 2011-12-16 15:06:51 | 显示全部楼层
baby_snake 发表于 2011-12-16 14:26
请问插头在哪里买到的,我也想自己做些传感器

以前淘宝买的,好像是南通的
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2011-12-16 17:19:36 | 显示全部楼层
看出来了,是烙铁加松香,厉害。有机会用风枪加焊油试试,BGA都没问题。
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2011-12-16 20:20:08 | 显示全部楼层
楼主的焊接水平还有提高空间。 {:soso_e100:}
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2011-12-17 08:48:09 | 显示全部楼层
厉害,佩服楼主的能力。
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2011-12-17 21:30:58 | 显示全部楼层
行啊
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

发表于 2011-12-17 21:31:22 | 显示全部楼层
膜拜Lz 强悍啊
如果您觉得我的帖子对您有用,请不吝给我一个“赞”!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|中文乐高 ( 桂ICP备13001575号-7 )

GMT+8, 2024-6-20 15:57 , Processed in 0.709458 second(s), 22 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表