Articles Posted in the " " Category

  • attachInterrupt()

    attachInterrupt()

    描述 挂载编码器介面的中断服务函式。 在不同工作模式下,可以触发中断的条件也不同: Pulse/DIR、CW/CCW、A/B Pulse 模式:有 index 讯号中断(由 setIndexReset() 设定)、比较器中断(由 setComparator() 设定)。 PWM 脉波捕捉模式:有脉波由 LOW 变 HIGH 的边缘触发中断与由 HIGH 变 LOW 的边缘触发中断。 SSI 模式:没有中断触发条件。 语法 Enc0.attachInterrupt(isr) Enc1.attachInterrupt(isr) Enc2.attachInterrupt(isr) Enc3.attachInterrupt(isr) 参数 Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。 isr:中断服务函式。此函式必须有一个 int 型别的参数,用来接收触发中断的事件类型,共有以下 8 种: INTR_COMPARE:代表发生比较器中断事件。 INTR_INDEX:代表发生index 讯号中断事件。 INTR_A_PULSE_LOW:代表 A 针脚上发生脉波由 LOW 变 HIGH 的边缘触发中断事件。 INTR_A_PULSE_HIGH:代表 A 针脚上发生脉波由 HIGH 变 LOW 的边缘触发中断事件。 […]


  • pulseIn()

    pulseIn()

    描述 读取 pin 脚上的脉冲(高或低电位)持续时间。举个例子,如果 state 输入值是 HIGH,pulseIn() 会等 pin 脚上的电位变成 HIGH 之后开始计时,等到又变回 LOW 才停止;之后会回传脉冲的持续时间,单位是微秒,最长量测宽度约 71 分钟。假如在指定的时间内没有出现任何脉冲,则会放弃读取并回传 0。 注意:此函式只可在 PWM 脉波捕捉模式下使用。另外,此函式不能和同 Encoder 函式库内的 attachInterrupt() 共用,在用 attachInterrupt() 挂载 ISR 后,呼叫 pulseIn() 是没作用的。 语法 Enc0.pulseIn(pin, state) Enc0.pulseIn(pin, state, timeout) Enc1.pulseIn(pin, state) Enc1.pulseIn(pin, state, timeout) Enc2.pulseIn(pin, state) Enc2.pulseIn(pin, state, timeout) Enc3.pulseIn(pin, state) Enc3.pulseIn(pin, state, timeout) 参数 Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。 […]


  • readNanoseconds()

    readNanoseconds()

    描述 此函式只能在 PWM 脉波捕捉模式下使用,功能和 read() 相同,但回传 ns (Nanosecond)单位的脉波宽度。 语法 Enc0.readNanoseconds() Enc1.readNanoseconds() Enc2.readNanoseconds() Enc3.readNanoseconds() 参数 Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。 回传 回传脉波 LOW 或 HIGH 的宽度(单位:ns),最长回传宽度约 4.2 秒。注意:readNanoseconds() 只能在 ISR 函式内被呼叫,如果在其它地方被呼叫,将总是回传 0。 范例 See also - begin() - attachInterrupt() 函式库参考主页面 The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in […]


  • indexRead()

    indexRead()

    描述 回传 Z 针脚上的电位。此函式只可在 Pulse/DIR、CW/CCW、A/B Pulse 工作模式下使用。 语法 Enc0.indexRead() Enc1.indexRead() Enc2.indexRead() Enc3.indexRead() 参数 Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。 回传 LOW 或 HIGH 范例 See also - begin() - setIndexReset() 函式库参考主页面 The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.


  • read()

    read()

    描述 读取编码器计数器数值或脉波宽度。此函式回传值在不同工作模式下有不同意义,请见下面说明。 语法 Enc0.read() Enc1.read() Enc2.read() Enc3.read() 参数 Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。 回传 Pulse/DIR、CW/CCW、A/B Pulse 模式:回传编码器所计数的值。 PWM 脉波捕捉模式:回传脉波 LOW 或 HIGH 的宽度(单位:us),最长可量测宽度约 71 分钟。注意:在此模式下,read() 只能在 ISR 函式内被呼叫,如果在其它地方被呼叫,将总是回传 0。 SSI 模式:回传由 SSI 绝对编码器读到的数值。 范例 设定 ENC0 为 A/B Pulse 模式,并读取编码器计数器数值: 设定 ENC1 为 PWM 脉波捕捉模式,并读取脉波的 HIGH、LOW 宽度: See also - attachInterrupt() 函式库参考主页面 The text of the 86Duino […]


  • write()

    write()

    描述 将 86Duino 编码器计数器设定为指定值。此函式只可用于 Pulse/DIR、CW/CCW、A/B Pulse 工作模式。 语法 Enc0.write(number) Enc1.write(number) Enc2.write(number) Enc3.write(number) 参数 Enc0、Enc1、Enc2、Enc3:分别对应 ENC0、ENC1、ENC2、ENC3 编码器介面。 number:指定给编码器计数器的值。(unsigned long 型别) 回传 无回传值 范例 See also - read() 函式库参考主页面 The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.


  • begin()

    begin()

    描述 初始化 86Duino 编码器介面,并指定工作模式。 语法 Enc0.begin(mode) Enc0.begin(mode, bits) Enc0.begin(mode, bits, clock) Enc0.begin(mode, bits, clock, wtime) Enc0.begin(mode, bits, clock, wtime, gray2bin) Enc1.begin(mode) Enc1.begin(mode, bits) Enc1.begin(mode, bits, clock) Enc1.begin(mode, bits, clock, wtime) Enc1.begin(mode, bits, clock, wtime, gray2bin) Enc2.begin(mode) Enc2.begin(mode, bits) Enc2.begin(mode, bits, clock) Enc2.begin(mode, bits, clock, wtime) Enc2.begin(mode, bits, clock, wtime, gray2bin) Enc3.begin(mode) Enc3.begin(mode, bits) Enc3.begin(mode, bits, […]


  • write()

    write()

    描述 从音频缓冲区播放音频讯号。 语法 Audio.write(buffer, length); 参数 buffer(short):储存音频样本的缓冲区。 length(int):要输出的样本数量。 回传 无回传值 范例 函式库参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.


  • prepare()

    prepare()

    描述 预备从档案读取至缓冲区的音频样本并且设置音量。 语法 Audio.prepare(buffer, samples, volume); 参数 buffer(short):储存音频样本的缓冲区。 samples(int):缓冲区中储存的音频样本数量。 volume(int):一个 10 位元的数字,代表音频的音量。0 表示没有声音,1023 是最大声。 回传 无回传值 范例 函式库参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.


  • begin()

    begin()

    描述 藉由给予取样率和缓冲时间的大小初始化 Audio 函式库。 语法 Audio.begin(rate, size); 参数 rate(int):音频档案的取样率。如果音频是立体声,取样率必须乘以 2(如. 44100hz 立体声 = 88200)。 size(int):音频缓冲时间的大小,以毫秒为单位。 回传 无回传值 Example 函式库参考主页面 The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.