久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3646|回復: 6
打印 上一主題 下一主題
收起左側

絕對值多圈編碼器,其中齒輪以格雷碼的方式編碼,但是現在齒輪安裝精度跟不上

[復制鏈接]
回帖獎勵 400 黑幣 回復本帖可獲得 100 黑幣獎勵! 每人限 1 次
跳轉到指定樓層
樓主
ID:319354 發(fā)表于 2019-7-22 10:18 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
這種齒輪很常見,齒輪比4比1,齒輪通過光學漫反射檢測位置信號,是現在市面上最常見的方案
參考資料: 資料.7z (236 Bytes, 下載次數: 30)
希望能得到有效的建議,現在問題是齒輪安裝的時候沒有對照機械零點(市場上應該都是這樣,都是通過軟件來彌補),導致其變化不是線性的,計算出來的圈數會跳變,本人的實現代碼如下,或許描述的不是太準確,希望懂的大佬能夠幫助我一下,已經研究幾個月了各種方法都試過了,如果有算法更好,感激不盡

  1. /*******************************************************************************
  2.   * 文件名     : light_coding.c
  3.   * 作者       : ylh
  4.   * 庫版本     : V3.5.0
  5.   * 文件版本   : V1.0.0
  6.   * 日期       : 2019年04月16日
  7.   * 摘要       : 齒輪
  8. ********************************************************************************/
  9. #include "light_coding.h"
  10. uint8_t light_cod[6] = {0};
  11. uint8_t result_turn[6] = {0};
  12. void LightCoding_GPIO_Init()
  13. {
  14. GPIO_InitTypeDef GPIO_InitStructure;
  15. // EXTI_InitTypeDef EXTI_InitStructure;
  16.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO,ENABLE); //使能端口和復用IO時鐘
  17. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);//
  18. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO,ENABLE);//
  19. GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
  20. GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_4;
  21. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//推挽輸出
  22. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  23.   GPIO_Init(GPIOB, &GPIO_InitStructure);//
  24. GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_15;
  25. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//推挽輸出
  26. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  27.   GPIO_Init(GPIOA, &GPIO_InitStructure);//
  28. GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_15;
  29. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//推挽輸出
  30. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  31.   GPIO_Init(GPIOC, &GPIO_InitStructure);//
  32. GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_14;
  33. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空輸入
  34. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  35.   GPIO_Init(GPIOC, &GPIO_InitStructure);//
  36. GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_13;
  37. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空輸入
  38. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  39.   GPIO_Init(GPIOC, &GPIO_InitStructure);//
  40. GPIO_InitStructure.GPIO_Pin  = GPIO_Pin_12;
  41. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空輸入
  42. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  43.   GPIO_Init(GPIOA, &GPIO_InitStructure);//
  44. }
  45. void NVIC_Configuration_LightCoding(void)
  46. {
  47. NVIC_InitTypeDef NVIC_InitStructure;

  48. NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
  49.   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 8;  //從優(yōu)先級為0
  50.   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  51.   NVIC_Init(&NVIC_InitStructure);
  52. Light_Coding(0x01);
  53. }
  54. //讀光編0x01~0x06;
  55. uint8_t Light_Coding(uint8_t type)
  56. {
  57. uint8_t result = 0;
  58. LED0(type&0x01);
  59. delay_ms(30);
  60. LED1((type&0x02)>>1);
  61. delay_ms(30);
  62. LED2((type&0x04)>>2);
  63. delay_ms(30);
  64. result = (result)|KEY3;
  65. delay_ms(30);
  66. result = (result<<1)|KEY4;
  67. delay_ms(30);
  68. result = (result<<1)|KEY5;
  69. delay_ms(30);
  70. return result;
  71. }
  72. //圈數轉換
  73. void computation(void)
  74. {
  75. int i = 0;
  76. for(i=0;i<6;i++){
  77.   switch(light_cod[i])
  78.   {
  79. //   case 0x00:
  80. //    result_turn[i] = 0.5;
  81. //    break;
  82.    case 0x04:
  83.     result_turn[i] = 3;
  84.     break;
  85. //   case 0x06:
  86. //    result_turn[i] = 1.5;
  87. //    break;
  88.    case 0x07:
  89.     result_turn[i] = 0;
  90.     break;
  91. //   case 0x05:
  92. //    result_turn[i] = 2.5;
  93. //    break;
  94.    case 0x01:
  95.     result_turn[i] = 1;
  96.     break;
  97. //   case 0x03:
  98. //    result_turn[i] = 3.5;
  99. //    break;
  100.    case 0x02:
  101.     result_turn[i] = 2;
  102.     break;
  103.   }
  104.   delay_ms(10);
  105. }
  106. }
  107. //計算齒輪總圈數
  108. int32_t computation_NUMOFTURN(void)
  109. {
  110.   int count = 0;
  111.   int32_t NUM_TURN_WG = 0;
  112.   while(count<6){
  113.    light_cod[count] = Light_Coding(count+0x01);
  114.    count++;
  115.   }
  116.   computation();
  117.   NUM_TURN_WG =
  118.           result_turn[5]*1024+
  119.           result_turn[4]*256+
  120.           result_turn[3]*64+
  121.           result_turn[2]*16+
  122.           result_turn[1]*4+
  123.           result_turn[0];
  124.   Light_Coding(0x01);
  125.   return NUM_TURN_WG;
  126. }
  127. ```
復制代碼


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:588702 發(fā)表于 2019-7-23 15:01 | 只看該作者
頂起來
回復

使用道具 舉報

板凳
ID:589001 發(fā)表于 2019-7-23 17:29 來自手機 | 只看該作者
很好,謝謝樓主
回復

使用道具 舉報

地板
ID:282095 發(fā)表于 2019-7-24 09:16 | 只看該作者
rolan是簡單的光學測量軟件
回復

使用道具 舉報

5#
ID:589469 發(fā)表于 2019-7-24 13:07 | 只看該作者
沒有人來解答嗎,想跟著學習一下
回復

使用道具 舉報

6#
ID:542954 發(fā)表于 2019-8-8 10:34 | 只看該作者
碼住學習
回復

使用道具 舉報

7#
ID:598763 發(fā)表于 2019-8-10 13:51 | 只看該作者
誰來解答一下,我也想知道
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 亚洲 欧美 综合 | 国产欧美二区 | 国产视频久久 | 国产98色在线 | www.青青草| 亚洲在线一区二区 | 久久69精品久久久久久久电影好 | 亚洲欧美在线观看 | 国产精品久久国产精品 | 精品久久影院 | 91视频在线看 | 日日噜噜夜夜爽爽狠狠 | 色综久久 | 污视频在线免费观看 | 福利网站导航 | 欧美在线二区 | 亚洲狠狠爱 | 在线视频亚洲 | 一区二区三区视频在线观看 | 成人黄页在线观看 | 一级片网址 | 黄色大片视频 | 国产欧美精品一区二区三区 | 国产精品一区二区三区在线 | 亚洲天堂一区二区 | 超碰操 | 国产视频二区 | 91精品久久久久久久久久 | 91精品国产乱码久久久久久久 | 国产精品久久亚洲 | 操操操操操 | 超碰97在线免费 | 亚洲欧美精品在线观看 | 国产二区视频 | 中文字幕视频在线 | 亚洲一区二区av在线 | 亚洲国产欧美日韩 | 精品国产一区二区三区久久久久久 | 欧美成人一级 | 欧美综合精品 | 天天综合天天 |