Verschillen
Dit geeft de verschillen weer tussen de geselecteerde revisie en de huidige revisie van de pagina.
Beide kanten vorige revisie Vorige revisie Volgende revisie | Vorige revisie | ||
tascam_rc10 [2018/09/20 21:44] – will | tascam_rc10 [2018/10/01 13:48] (huidige) – [Arduino code] will | ||
---|---|---|---|
Regel 23: | Regel 23: | ||
You can use either SignalGenerator or SerialPort class to send data, either one has its own advantages and disadvantages. | You can use either SignalGenerator or SerialPort class to send data, either one has its own advantages and disadvantages. | ||
- | {{: | + | {{: |
+ | |||
+ | |||
+ | {{: | ||
Regel 34: | Regel 37: | ||
Dim sg As New SignalGenerator(DirectCast(64, | Dim sg As New SignalGenerator(DirectCast(64, | ||
sg.SetBlocking(True, | sg.SetBlocking(True, | ||
+ | </ | ||
+ | < | ||
' Emulate Play button using SerialPort | ' Emulate Play button using SerialPort | ||
Dim uart As New SerialPort(" | Dim uart As New SerialPort(" | ||
Regel 44: | Regel 49: | ||
Thread.Sleep(150) | Thread.Sleep(150) | ||
uart.WriteByte(9) | uart.WriteByte(9) | ||
+ | </ | ||
+ | |||
+ | ==== github.com/ | ||
+ | TASCAM RC-10 remote control | ||
+ | |||
+ | https:// | ||
+ | |||
+ | TASCAM RC-10 remote control | ||
+ | |||
+ | This is a replacement for a TASCAM RC-10 remote control running on Arduino. | ||
+ | |||
+ | ==== Protocol ==== | ||
+ | |||
+ | The RC-10 communicates over a 2.5mm stereo headphone plug. The tip is the signal from the remote control to the device under control (such as an audio recorder), the ring is 3.3V DC from the device, and the sleeve is ground. | ||
+ | |||
+ | The protocol is standard TTL-level UART (mark is 3.3V, space is 0V) running at 9600 baud, 8 data bits, even parity, and 1 stop bit. | ||
+ | |||
+ | The RC-10 sends a start byte when a button is pressed, a repeat byte every 100ms afterward while the button is held down, and an end byte when the button is released. The lower 5 bits of the byte is the command, while the upper 2 bits indicate whether it's a start, repeat, or end byte. A start byte has bit 7 set and bit 6 cleared, a repeat byte has both bits 7 and 6 set, and an end byte has both bits 7 and 6 cleared. | ||
+ | |||
+ | == Button command values == | ||
+ | |||
+ | ^Button ^Value^ | ||
+ | |Stop |8 | | ||
+ | |Play |9 | | ||
+ | |Record |11 | | ||
+ | |Forward |14 | | ||
+ | |Back |15 | | ||
+ | |Mark |24 | | ||
+ | |F1 |28 | | ||
+ | |F2 |29 | | ||
+ | |F3 |30 | | ||
+ | |F4 |31 | | ||
+ | Note: F3 is marked (+) and F4 is marked (-). | ||
+ | |||
+ | == Features == | ||
+ | |||
+ | This replacement software also supports a " | ||
+ | |||
+ | == License == | ||
+ | |||
+ | Copyright 2016 Christopher Williams. All Rights Reserved. | ||
+ | |||
+ | Redistribution and use in source and binary forms, with or without modification, | ||
+ | |||
+ | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
+ | |||
+ | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
+ | |||
+ | The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. | ||
+ | |||
+ | THIS SOFTWARE IS PROVIDED BY CHRISTOPHER WILLIAMS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
+ | |||
+ | Acknowledgments | ||
+ | |||
+ | Special thanks to user iamin on www.ghielectronics.com for posting information about the RC-10 protocol. (See https:// | ||
+ | |||
+ | ==== Arduino code ==== | ||
+ | |||
+ | <code c++ RC10.ino> | ||
+ | /* | ||
+ | * Replacement for TASCAM RC-10 remote control. | ||
+ | * | ||
+ | * Copyright 2016 Christopher Williams. All Rights Reserved. | ||
+ | * | ||
+ | * Redistribution and use in source and binary forms, with or without | ||
+ | * modification, | ||
+ | * are met: | ||
+ | * | ||
+ | * 1. Redistributions of source code must retain the above copyright | ||
+ | | ||
+ | * | ||
+ | * 2. Redistributions in binary form must reproduce the above copyright | ||
+ | | ||
+ | | ||
+ | | ||
+ | * | ||
+ | * 3. The name of the author may not be used to endorse or promote | ||
+ | | ||
+ | | ||
+ | * | ||
+ | * THIS SOFTWARE IS PROVIDED BY CHRISTOPHER WILLIAMS "AS IS" AND ANY | ||
+ | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
+ | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
+ | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
+ | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
+ | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
+ | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | ||
+ | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
+ | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
+ | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
+ | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
+ | */ | ||
+ | |||
+ | /* | ||
+ | * Button mapping: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * 10 mic input level - | ||
+ | * 11 turbo | ||
+ | * | ||
+ | * (The actual pin mapping is currently up in the air.) | ||
+ | * | ||
+ | * Connector: 2.5mm stereo phone plug. | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | */ | ||
+ | |||
+ | /* | ||
+ | * N.B. This program is limited to one button press at a time because I | ||
+ | * don't know how the TASCAM DR-40 (or other models) responds to interleaved | ||
+ | * buttons, so I just avoid it in the first place. There' | ||
+ | * requires two or more simultaneous button presses anyway. | ||
+ | */ | ||
+ | |||
+ | /**** START OF CONFIGURABLES ****/ | ||
+ | |||
+ | struct function { | ||
+ | uint8_t pin; | ||
+ | uint8_t value; | ||
+ | }; | ||
+ | |||
+ | // map of pin numbers and values to send in response to a button | ||
+ | // press/ | ||
+ | /* | ||
+ | * XXX buttons are numbered 1..10 so we can return the negative value to | ||
+ | * indicate that the button was released. So we have a dummy button at | ||
+ | * index 0 to account for that. | ||
+ | */ | ||
+ | static const struct function functions[] = { | ||
+ | { 0, 0, }, // dummy | ||
+ | { 12, 8, }, // 1 stop | ||
+ | { 14, 9, }, // 2 play | ||
+ | { 15, 11, }, // 3 record | ||
+ | { 16, 14, }, // 4 forward | ||
+ | { 17, 15, }, // 5 back | ||
+ | { 18, 24, }, // 6 mark | ||
+ | { 19, 28, }, // 7 1/2 [SOLO] | ||
+ | { 20, 29, }, // 8 3/4 [SOLO] | ||
+ | { 21, 30, }, // 9 mic input level + | ||
+ | { 22, 31, }, // 10 mic input level - | ||
+ | { 23, 0, }, // 11 turbo | ||
+ | }; | ||
+ | |||
+ | #define TURBO_LED_PIN 13 | ||
+ | #define TURBO_BUTTON_PIN 23 | ||
+ | |||
+ | #define FIRST_REPEAT_PERIOD 100 | ||
+ | #define REPEAT_PERIOD 100 | ||
+ | |||
+ | #define TURBO_FIRST_REPEAT_PERIOD 100 | ||
+ | #define TURBO_REPEAT_PERIOD 50 | ||
+ | |||
+ | /**** END OF CONFIGURABLES ****/ | ||
+ | |||
+ | #define SIZEOF_ARRAY(a) (sizeof a / sizeof a[0]) | ||
+ | static const uint8_t numButtonInputPins = SIZEOF_ARRAY(functions); | ||
+ | |||
+ | static uint8_t firstRepeatPeriod = FIRST_REPEAT_PERIOD; | ||
+ | static uint8_t repeatPeriod = REPEAT_PERIOD; | ||
+ | static bool turboRepeat = false; | ||
+ | |||
+ | #define EACHBUTTON(b) (uint8_t b = 1; b < numButtonInputPins; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | Serial.begin(9600, | ||
+ | for EACHBUTTON(b) { | ||
+ | pinMode(functions[b].pin, | ||
+ | } | ||
+ | pinMode(TURBO_LED_PIN, | ||
+ | |||
+ | setTurbo(false); | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | static unsigned long lastRepeatTime; | ||
+ | static int8_t currentButton = 0; | ||
+ | static unsigned long repeat; | ||
+ | |||
+ | int8_t button = scanButtons(); | ||
+ | if (button) { | ||
+ | lastRepeatTime = millis(); | ||
+ | repeat = firstRepeatPeriod; | ||
+ | currentButton = button; | ||
+ | if (button > 0) { | ||
+ | handleButtonPress(button); | ||
+ | } else { | ||
+ | handleButtonRelease(-button); | ||
+ | } | ||
+ | } else if (currentButton > 0 && | ||
+ | | ||
+ | lastRepeatTime += repeat; | ||
+ | repeat = repeatPeriod; | ||
+ | handleButtonRepeat(currentButton); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | /**** Button event handlers ****/ | ||
+ | |||
+ | #define START_MASK | ||
+ | #define REPEAT_MASK 0xC0 | ||
+ | #define END_MASK | ||
+ | |||
+ | static void setTurbo(bool turbo) | ||
+ | { | ||
+ | turboRepeat = turbo; | ||
+ | if (turboRepeat) { | ||
+ | repeatPeriod = TURBO_REPEAT_PERIOD; | ||
+ | firstRepeatPeriod = TURBO_FIRST_REPEAT_PERIOD; | ||
+ | digitalWrite(TURBO_LED_PIN, | ||
+ | } else { | ||
+ | repeatPeriod = REPEAT_PERIOD; | ||
+ | firstRepeatPeriod = FIRST_REPEAT_PERIOD; | ||
+ | digitalWrite(TURBO_LED_PIN, | ||
+ | } | ||
+ | } | ||
+ | |||
+ | static void handleButtonPress(uint8_t b) | ||
+ | { | ||
+ | if (functions[b].value) { | ||
+ | Serial.write(functions[b].value | START_MASK); | ||
+ | } else if (functions[b].pin == TURBO_BUTTON_PIN) { | ||
+ | setTurbo(!turboRepeat); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | static void handleButtonRelease(uint8_t b) | ||
+ | { | ||
+ | if (functions[b].value) { | ||
+ | Serial.write(functions[b].value | END_MASK); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | static void handleButtonRepeat(uint8_t b) | ||
+ | { | ||
+ | if (functions[b].value) { | ||
+ | Serial.write(functions[b].value | REPEAT_MASK); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | /**** Debounced button scanner ****/ | ||
+ | |||
+ | #define DEBOUNCE_PERIOD 50 | ||
+ | |||
+ | // return zero if no change in button presses | ||
+ | // return button number if button is now pressed | ||
+ | // return negative button number if button is now released | ||
+ | static int8_t scanButtons(void) | ||
+ | { | ||
+ | static int8_t currentButton = 0; | ||
+ | |||
+ | static bool debouncing = false; | ||
+ | static unsigned long debounceTime = 0; | ||
+ | |||
+ | if (debouncing && millis() - debounceTime < DEBOUNCE_PERIOD) { | ||
+ | return 0; | ||
+ | } | ||
+ | debouncing = false; | ||
+ | |||
+ | if (currentButton <= 0) { | ||
+ | // no buttons currently pressed | ||
+ | // scan all buttons | ||
+ | for EACHBUTTON(b) { | ||
+ | if (readButtonState(b)) { | ||
+ | debouncing = true; | ||
+ | debounceTime = millis(); | ||
+ | currentButton = b; | ||
+ | return currentButton; | ||
+ | } | ||
+ | } | ||
+ | } else { | ||
+ | // scan only this button | ||
+ | bool pressed = readButtonState(currentButton); | ||
+ | if (!pressed) { | ||
+ | // button is released | ||
+ | debouncing = true; | ||
+ | debounceTime = millis(); | ||
+ | currentButton = -currentButton; | ||
+ | return currentButton; | ||
+ | } | ||
+ | } | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | // return true if button ' | ||
+ | static bool readButtonState(uint8_t b) | ||
+ | { | ||
+ | return digitalRead(functions[b].pin) == LOW; | ||
+ | } | ||
</ | </ |