From a633a90660e67dd52b44ea89420507f5d0fcd05f Mon Sep 17 00:00:00 2001 From: "Torsten Edeler (AEF)" Date: Sat, 29 Aug 2020 21:40:46 +0200 Subject: [PATCH 1/7] inital version --- pulsecounter.md | 134 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 pulsecounter.md diff --git a/pulsecounter.md b/pulsecounter.md new file mode 100644 index 0000000..0b7bd11 --- /dev/null +++ b/pulsecounter.md @@ -0,0 +1,134 @@ +#Pulsecounter Feature +Provides pulse counting with a total number of four counters for each pin: +* cnt_pulse: Number of valid pulses detected +* cnt_longPulse: Number of too long pulses +* cnt_shortPulse: Number of too short pulses +* cnt_shortPause: Number of too short pauses before a pulse + +A valid pulse length is defined by two times: +* minPulseLength_us: Minimal pulse length in micro seconds +* maxPulseLength_us: Maximal pulse length in micro seconds + +A third time defines the minmal pause length before a pulse. This is +* minPauseBefore_us + +A pulse is valid if it's length is within the min/max boundaries and the state of the pin was stable for at least minPauseBefore_us before the beginning of the pulse. + +Example implementation : + * Pulsecounter Feature is available [here](https://github.com/tedeler/FirmataPulseCounter) + * A dedicated example is available. See [here](https://github.com/tedeler/FirmataPulseCounter/blob/master/example/main.cpp). + +## Tested boards +This feature has been tested on : + * Wemos with SAMD21 + +## Protocol details +The protocol below use exclusively SysEx queries and SysEx responses. + +### Attach encoder query +Query : +```c + /* ----------------------------------------------------- + * 0 START_SYSEX (0xF0) + * 1 PULSECOUNTER_DATA (0x63) + * 2 PULSECOUNTER_ATTACH (0x00) + * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) + * 4 pin (pin) + * 5 polarity (0=>Active LOW, 1=>Active HIGH) + + * 6 minPauseBefore_us (Bit 27-21) + * 7 minPauseBefore_us (Bit 20-14) + * 8 minPauseBefore_us (Bit 13-7) + * 9 minPauseBefore_us (Bit 6-0) + + * 10 minPulseLength_us (Bit 27-21) + * 11 minPulseLength_us (Bit 20-14) + * 12 minPulseLength_us (Bit 13-7) + * 13 minPulseLength_us (Bit 6-0) + + * 14 maxPulseLength_us (Bit 27-21) + * 15 maxPulseLength_us (Bit 20-14) + * 16 maxPulseLength_us (Bit 13-7) + * 17 maxPulseLength_us (Bit 6-0) + * 18 END_SYSEX (0xF7) + * ----------------------------------------------------- + */ +``` +No response. + +### Report of counter values +Sent on request or if any counter changes +Format : +```c + /* ----------------------------------------------------- + * 0 START_SYSEX (0xF0) + * 1 PULSECOUNTER_DATA (0x63) + * 2 pulsecntID ([0 - MAXPULSECOUNTER-1]) + + * 3 cnt_shortPause (Bit 27-21) + * 4 cnt_shortPause (Bit 20-14) + * 5 cnt_shortPause (Bit 13-7) + * 6 cnt_shortPause (Bit 6-0) + + * 7 cnt_shortPulse (Bit 27-21) + * 8 cnt_shortPulse (Bit 20-14) + * 9 cnt_shortPulse (Bit 13-7) + * 10 cnt_shortPulse (Bit 6-0) + + * 11 cnt_longPulse (Bit 27-21) + * 12 cnt_longPulse (Bit 20-14) + * 13 cnt_longPulse (Bit 13-7) + * 14 cnt_longPulse (Bit 6-0) + + * 15 cnt_pulse (Bit 27-21) + * 16 cnt_pulse (Bit 20-14) + * 17 cnt_pulse (Bit 13-7) + * 18 cnt_pulse (Bit 6-0) + + * 19 END_SYSEX (0xF7) + * ----------------------------------------------------- + */ +``` + + +### Reset of all counters +Query : +```c + /* ----------------------------------------------------- + * 0 START_SYSEX (0xF0) + * 1 PULSECOUNTER_DATA (0x63) + * 2 PULSECOUNTER_RESET_COUNTER (0x02) + * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) + * 4 END_SYSEX (0xF7) + * ----------------------------------------------------- + */ +``` +Response is the counter report (PULSECOUNTER_DATA) + +### Request report of counter values +Query : +```c + /* ----------------------------------------------------- + * 0 START_SYSEX (0xF0) + * 1 PULSECOUNTER_DATA (0x63) + * 2 PULSECOUNTER_REPORT (0x01) + * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) + * 4 END_SYSEX (0xF7) + * ----------------------------------------------------- + */ +``` +Response is the counter report (PULSECOUNTER_DATA) + +### Detach pulse counter +Query : +```c + /* ----------------------------------------------------- + * 0 START_SYSEX (0xF0) + * 1 PULSECOUNTER_DATA (0x63) + * 2 PULSECOUNTER_RESET_COUNTER (0x02) + * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) + * 4 END_SYSEX (0xF7) + * ----------------------------------------------------- + */ +``` +No response. From 8ecfb4f571bcc52e938e89b438ef9159017cf81c Mon Sep 17 00:00:00 2001 From: "Torsten Edeler (AEF)" Date: Sat, 29 Aug 2020 21:43:24 +0200 Subject: [PATCH 2/7] . --- pulsecounter.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pulsecounter.md b/pulsecounter.md index 0b7bd11..8924cbb 100644 --- a/pulsecounter.md +++ b/pulsecounter.md @@ -1,4 +1,5 @@ #Pulsecounter Feature + Provides pulse counting with a total number of four counters for each pin: * cnt_pulse: Number of valid pulses detected * cnt_longPulse: Number of too long pulses From ad457072edda405887e29a672604fca50e1ca65d Mon Sep 17 00:00:00 2001 From: tedeler Date: Sat, 29 Aug 2020 21:46:33 +0200 Subject: [PATCH 3/7] Update pulsecounter.md --- pulsecounter.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pulsecounter.md b/pulsecounter.md index 8924cbb..b818dbd 100644 --- a/pulsecounter.md +++ b/pulsecounter.md @@ -1,22 +1,22 @@ -#Pulsecounter Feature +# Pulsecounter Feature Provides pulse counting with a total number of four counters for each pin: -* cnt_pulse: Number of valid pulses detected -* cnt_longPulse: Number of too long pulses -* cnt_shortPulse: Number of too short pulses -* cnt_shortPause: Number of too short pauses before a pulse +* `cnt_pulse`: Number of valid pulses detected +* `cnt_longPulse`: Number of too long pulses +* `cnt_shortPulse`: Number of too short pulses +* `cnt_shortPause`: Number of too short pauses before a pulse A valid pulse length is defined by two times: -* minPulseLength_us: Minimal pulse length in micro seconds -* maxPulseLength_us: Maximal pulse length in micro seconds +* `minPulseLength_us`: Minimal pulse length in micro seconds +* `maxPulseLength_us`: Maximal pulse length in micro seconds A third time defines the minmal pause length before a pulse. This is -* minPauseBefore_us +* `minPauseBefore_us` -A pulse is valid if it's length is within the min/max boundaries and the state of the pin was stable for at least minPauseBefore_us before the beginning of the pulse. +A pulse is valid if it's length is within the min/max boundaries and the state of the pin was stable for at least `minPauseBefore_us` before the beginning of the pulse. Example implementation : - * Pulsecounter Feature is available [here](https://github.com/tedeler/FirmataPulseCounter) + * Pulsecounter feature is available [here](https://github.com/tedeler/FirmataPulseCounter) * A dedicated example is available. See [here](https://github.com/tedeler/FirmataPulseCounter/blob/master/example/main.cpp). ## Tested boards From 12f40c4f1da26fe6a8f25d4d5b440e83ffb262dc Mon Sep 17 00:00:00 2001 From: "Torsten Edeler (AEF)" Date: Sat, 29 Aug 2020 21:47:40 +0200 Subject: [PATCH 4/7] . --- pulsecounter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsecounter.md b/pulsecounter.md index b818dbd..601c705 100644 --- a/pulsecounter.md +++ b/pulsecounter.md @@ -26,7 +26,7 @@ This feature has been tested on : ## Protocol details The protocol below use exclusively SysEx queries and SysEx responses. -### Attach encoder query +### Attach pulse counter query Query : ```c /* ----------------------------------------------------- From ea37ca7bbee78b48e643a725b058da1ed552d33f Mon Sep 17 00:00:00 2001 From: tedeler Date: Sat, 29 Aug 2020 21:55:26 +0200 Subject: [PATCH 5/7] Update feature-registry.md --- feature-registry.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/feature-registry.md b/feature-registry.md index b0402c5..5f7dff3 100644 --- a/feature-registry.md +++ b/feature-registry.md @@ -58,7 +58,8 @@ Each feature should be documented in a markdown file and versioned independently | Feature ID | Feature name | Link to documentation | Status | | ----------- | ---------------------------------- | ---------------------- | ---------- | -| 5CH | RCOUTPUT_DATA | [rcswitch-proposal.md](https://github.com/firmata/protocol/blob/master/proposals/rcswitch-proposal.md) | proposed | +| 5BH | PULSECOUNTER_DATA | [pulsecounter.md](https://github.com/tedeler/protocol/blob/proposal_pulsecounter/pulsecounter.md) | proposed | +|5CH | RCOUTPUT_DATA | [rcswitch-proposal.md](https://github.com/firmata/protocol/blob/master/proposals/rcswitch-proposal.md) | proposed | | 5DH | RCINPUT_DATA | [rcswitch-proposal.md](https://github.com/firmata/protocol/blob/master/proposals/rcswitch-proposal.md) | proposed | | 5EH | DEVICE_QUERY | [proposal](https://github.com/finson-release/Luni/blob/master/extras/v0.9/v0.8-device-driver-C-firmata-messages.md) | proposed | | 5FH | DEVICE_RESPONSE | [proposal](https://github.com/finson-release/Luni/blob/master/extras/v0.9/v0.8-device-driver-C-firmata-messages.md) | proposed | From 55472e575bc16d3ee5516dd53c286791e8c994d9 Mon Sep 17 00:00:00 2001 From: "Torsten Edeler (AEF)" Date: Sat, 29 Aug 2020 21:56:32 +0200 Subject: [PATCH 6/7] . --- pulsecounter.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pulsecounter.md b/pulsecounter.md index 601c705..ad451f6 100644 --- a/pulsecounter.md +++ b/pulsecounter.md @@ -31,7 +31,7 @@ Query : ```c /* ----------------------------------------------------- * 0 START_SYSEX (0xF0) - * 1 PULSECOUNTER_DATA (0x63) + * 1 PULSECOUNTER_DATA (0x5B) * 2 PULSECOUNTER_ATTACH (0x00) * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) * 4 pin (pin) @@ -63,7 +63,7 @@ Format : ```c /* ----------------------------------------------------- * 0 START_SYSEX (0xF0) - * 1 PULSECOUNTER_DATA (0x63) + * 1 PULSECOUNTER_DATA (0x5B) * 2 pulsecntID ([0 - MAXPULSECOUNTER-1]) * 3 cnt_shortPause (Bit 27-21) @@ -97,7 +97,7 @@ Query : ```c /* ----------------------------------------------------- * 0 START_SYSEX (0xF0) - * 1 PULSECOUNTER_DATA (0x63) + * 1 PULSECOUNTER_DATA (0x5B) * 2 PULSECOUNTER_RESET_COUNTER (0x02) * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) * 4 END_SYSEX (0xF7) @@ -111,7 +111,7 @@ Query : ```c /* ----------------------------------------------------- * 0 START_SYSEX (0xF0) - * 1 PULSECOUNTER_DATA (0x63) + * 1 PULSECOUNTER_DATA (0x5B) * 2 PULSECOUNTER_REPORT (0x01) * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) * 4 END_SYSEX (0xF7) @@ -125,7 +125,7 @@ Query : ```c /* ----------------------------------------------------- * 0 START_SYSEX (0xF0) - * 1 PULSECOUNTER_DATA (0x63) + * 1 PULSECOUNTER_DATA (0x5B) * 2 PULSECOUNTER_RESET_COUNTER (0x02) * 3 pulsecntID ([0 - MAXPULSECOUNTER-1]) * 4 END_SYSEX (0xF7) From ea1ca0229fbc557115a9ea2cc846b1ccbba1b4bc Mon Sep 17 00:00:00 2001 From: "Torsten Edeler (AEF)" Date: Thu, 10 Sep 2020 08:37:59 +0200 Subject: [PATCH 7/7] proposal of new serial protocol --- serial-1.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/serial-1.0.md b/serial-1.0.md index 160bca0..813965f 100644 --- a/serial-1.0.md +++ b/serial-1.0.md @@ -69,6 +69,9 @@ only be specified if the platform requires them to be set. 5 baud (bits 14 - 20) // need to send 3 bytes for baud even if value is < 14 bits 6 rxPin (0-127) [optional] // only set if platform requires RX pin number 7 txPin (0-127) [optional] // only set if platform requires TX pin number +8 mode (bits 0-6 => 0-6) [optional] //Mode (second parameter of Serial.begin(...) +9 mode (bits 0-6 => 7-13) [optional] +10 mode (bits 0-3 => 13-16) [optional] 6|8 END_SYSEX (0xF7) ```