作者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/cn.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