作者ru4m3 (宇)
看板ASM
標題[問題] Arduino 使用HTCL-2032
時間Thu Aug 4 19:53:10 2016
想請教各位依些問題
我想利用HCTL-2032 來幫助arduino 量取光學尺的訊號
我是直接使用這個網站的lib以及他附的程式先測試
http://www.robogaia.com/two-axis-encoder-counter-mega-shield.html
但不管怎麼配合datasheet檢查程式或是接線
可以量到有訊號輸入進去,但D0~D7完全沒有訊號出來
不知道問題在哪個方向
麻煩大家了
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.177.14.208
※ 文章網址: https://webptt.com/m.aspx?n=bbs/ASM/M.1470311592.A.A1A.html
1F:推 god145145: countMode? 08/05 07:35
2F:→ ru4m3: 用他的lib 是在4X解析,只讀取x軸 08/05 09:13
3F:→ god145145: sorry應該跟countMode沒關係,程式可以PO一下嗎? 08/05 21:40
/////////////digital pin/////////////////////////
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D0 22
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D1 23
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D2 24
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D3 25
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D4 26
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D5 27
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D6 28
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D7 29
/////////////////////////////////////////////////
/////////////
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_RSTY 30
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_RSTX 31
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_SEL2 32
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_SEL1 33
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_EN2 34
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_EN1 35
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_OE 36
#define MEGA_QUADRATURE_ENCODER_COUNTER_PIN_XY 37
void setup()
{
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_XY, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_OE, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_EN1, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_EN2, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_SEL1, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_SEL2, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_RSTX, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_RSTY, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D0, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D1, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D2, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D3, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D4, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D5, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D6, OUTPUT);
pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D7, OUTPUT);
Serial.begin(9600);
///////////////////count mode//////////////////////////////
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_EN1, HIGH);
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_EN2, LOW);
//////////////////////// XY ////////////////////////////
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_XY, LOW);
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_OE, LOW); // Active LOW
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_SEL1, LOW);
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_SEL2, HIGH);
/////////////////////// reset //////////////////////////////
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_RSTX, HIGH); // Active
LOW
digitalWrite(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_RSTY, HIGH); // Active
LOW
}
void loop()
{
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D0));
Serial.print(" ");
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D1));
Serial.print(" ");
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D2));
Serial.print(" ");
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D3));
Serial.print(" ");
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D4));
Serial.print(" ");
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D5));
Serial.print(" ");
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D6));
Serial.print(" ");
Serial.print(digitalRead(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D7));
Serial.println(" ");
delay(100);
}
※ 編輯: ru4m3 (101.139.165.90), 08/09/2016 08:16:37
4F:推 god145145: pinMode(MEGA_QUADRATURE_ENCODER_COUNTER_PIN_D0, OUT 08/09 23:10
5F:→ god145145: PUT); 改成input? 08/09 23:10