Wednesday, 26 August 2015

Olympus RS-24 Foot Pedal Mod


For a while now, I have been toying with the idea of modifying a transcriber foot pedal into a programmable HID device. This could be useful for those complicated keyboard macros , Push to Talk  or even for a more natural feel in racing type games, although not with proportional control.
Your feet are generally wasted whilst sat at the computer, other than tapping to a beat. With a whole industry and trend built from standing desks and the health issues in the media regarding sitting for hours at a time, maybe it's time to get a free leg exercise.


Meet the Olympus RS-24 foot pedal... sporting three proprietary software driven functions, rewind, fast forward and listen, all your secretary could ever dream of.




The unit is weighted with a steel plate to the bottom, held together by a series of catches and two screws. Yet, the glass fibre reinforced plastic is robust enough to withstand the most hardy kitten heel or stiletto in anger!




At this point the factory Ferranti microprocessor is of no use to us, time for a lobotomy...




Out with the old in with the new... the £3.00 eBay  Atmega 32u4 Pro Micro is a direct clone of the Sparkfun Pro Micro.




With the old PCB removed, I played around with a few different mounting positions for the Pro Micro.


With each of the foot pedal switches removed, longer wires were soldered in place.

Tip:

Using a drill, a nice tight twisted pair cable can be made.



I marked each of the wired pairs with a coloured marker.



Each of the pairs can now be wired back to the Pro Micro. The grounds were connected together and   a fly lead used for the connection to the Pro Micro. You may ask why I did not run the ground in series to each switch? The reason for this was for flexibility to position the wires and to also ensure clearance from the moving pedals. If I had been many more switches then it would have become more of an issue.

Hot glue or hot snot was all that was required to hold the Pro Micro PCB in place.



The micro switches used are very lightweight yet responsive!  Unfortunately, having no reassuring audible contact click, like a tradition micro switch, for fun I decided to emulate the audible feedback with a piezo speaker or transducer (maybe have some fun later).



I found a nice hidey hole up in the top right of the unit, where the piezo would not come into contact with the moving section of the foot pedal.



I then ran the wires for the piezo back to the Pro Micro.



With the foot pedal enclosure being so low profile, I made a low profile Micro USB connector with a header that could plug directly into a salvaged USB keyboard PCB plug, using a standard PCB header strip.



Although the assembled pedal is slightly on the small side for my size 11 feet, a socked foot can navigate the pedal with ease!!


Arduino Code:


The Pro Micro, like the Leonardo, has native USB HID using the Atmel Atmega 32u4 meaning that it can easily be used to emulated actual keyboard key press and combinations, such as short-cuts or single key presses.

The Arduino IDE provides us with a simple solution to program the desired keys on the fly.

Considerations:


I am usually a big fan of hardware switch debouncing using a capacitor in the 0.01 to 0.1uf range directly across the switch contacts. In this scenario absolute speed, as when touch typing is not required, a simple delay in the code should be adequate.

The debounce (delay(100); // debounce) delay time was chosen to give a unhindered natural feel between presses.

Build Time:

2 hours, And basic Arduino experience

Basic Key Press Arduino Sketch:

// Arduino Pro Micro Olympus RS-24/28 Dictation Foot pedal (32u4 Pro Micro) R.Hirst 2015

int pin_ff = 2; // Set FF (Fast Forward) to a pin
int pin_listen = 3; // Set LISTEN to any pin
int pin_rew = 4; // Set REWIND to a pin


void setup()
{
pinMode(pin_rew, INPUT); // Set the button as an input
digitalWrite(pin_rew, HIGH); // Pull the button high

pinMode(pin_ff, INPUT); // Set the button as an input
digitalWrite(pin_ff, HIGH); // Pull the button high

pinMode(pin_listen, INPUT); // Set the button as an input
digitalWrite(pin_listen, HIGH); // Pull the button high
}


void loop()
{
if (digitalRead(pin_rew) == 0) // if the button goes low
{
Keyboard.write('1'); // send a '1' to the computer via Keyboard HID
Serial.print(" Rewind Pedal Button Pressed Pin: ");
Serial.println(pin_rew);
Serial.println("");
delay(100); // debounce
}

if (digitalRead(pin_ff) == 0) // if the button goes low
{
Keyboard.write('2'); // send a '2' to the computer via Keyboard HID
Serial.print(" Fast Forward Pedal Button Pressed Pin: ");
Serial.println(pin_ff);
Serial.println("");
delay(100); // debounce
}
if (digitalRead(pin_listen) == 0) // if the button goes low
{
Keyboard.write('3'); // send a '3' to the computer via Keyboard HID
Serial.print(" Listen Pedal Button Pressed Pin: ");
Serial.println(pin_listen);
Serial.println("");
delay(100); // debounce
}
}


//-----------------------------------------------------------------------

Debug using the Arduino IDE serial monitor:

Once the above sketch is uploaded to the Pro Micro, we can  test the pedal using the Arduino IDE serial monitor.
The top line will show our emulated keyboard presses and the box below the outputs the pedal pressed. Also, which digital pin was used on the Pro Micro for that particular foot pedal switch.




Advanced 3 key Atmel 32u4 Arduino Sketch,  acts just like a true keyboard!


Push to Talk example:


The requirements for a PTT key differ from that of most arduino keyboard examples.
When a key or combination of keys are pressed, they need to be held ,with no repeat on the micro controller side,  like a true keyboard,  although without rollover. Any repeat will make your voice choppy over the communication software. As it mutes and un-mutes many times a second.


  • All defined pedal keys/combos are held till the pedal is released.
  • Especially useful for "Push to Talk" applications
  • Repeating keys are handled by the operating system, as it is with true keyboard!
  • This example does not support key rollover. No pressing multiple pedal switches at once.

CODE:


//------------------------------------------------------------------------------------------------------------------------

 /*

 Atmel 32u4/Leonardo USB Keypedal  R.Hirst & Colin Russell  2016 v1

 All defined pedal keys/combos are held down till the pedal is released. Repeating keys are handled by the operating system, as with a real keyboard!

 This sketch does not support key rollover Eg. pressing multiple pedal switches at once.

 Test Virtual Keyboard URL below

 Windows7 and above onscreen keyboard "OSK.exe" or  https://www.microsoft.com/appliedsciences/content/projects/MultiKeyDisplay.aspx

 Keyboard Modifiers see https://www.arduino.cc/en/Reference/KeyboardModifiers

 Keybinding Syntax example for characters
 -----------------------------------------
 Keyboard.press('A');

 Keybinding Syntax Example for Modifiers 
 -----------------------------------------
 Keyboard.press(KEY_LEFT_CTRL);

 */

#include <Keyboard.h>

#define PedalPin1 4
#define PedalPin2 2
#define PedalPin3 3

// Small delay for combos if used, so the PC thinks its a human  
#define ComboDelay_1 50   // specify Combo Key press delaytime in ms here
#define ComboDelay_2 50   // specify Combo Key press delaytime in ms here
#define ComboDelay_3 50   // specify Combo Key press delaytime in ms here

void setup() {

  pinMode(PedalPin1, INPUT_PULLUP);
  pinMode(PedalPin2, INPUT_PULLUP);
  pinMode(PedalPin3, INPUT_PULLUP);
  
  delay(4000);
  Keyboard.begin();
}

void loop() {
  //------------------- Left Pedal---------------------

  while (digitalRead(PedalPin1) == LOW){
    
    Keyboard.press(KEY_LEFT_CTRL);
    delay(ComboDelay_1);  // Small delay for combos, so the PC thinks its a human
    Keyboard.press('1');
  }

  //------------------- Middle Pedal---------------------

  while (digitalRead(PedalPin2) == LOW){
    
    Keyboard.press(KEY_LEFT_CTRL);
    delay(ComboDelay_1);  // Small delay for combos, so the PC thinks its a human    
    Keyboard.press('2');
  }

  //------------------- Right Pedal---------------------

  while (digitalRead(PedalPin3) == LOW){
    
    Keyboard.press(KEY_LEFT_CTRL);
    delay(ComboDelay_1);  // Small delay for combos, so the PC thinks its a human
    Keyboard.press('3');
  }
  if ((digitalRead(PedalPin1) == HIGH) && (digitalRead(PedalPin2) == HIGH) && (digitalRead(PedalPin3) == HIGH)){
    Keyboard.releaseAll();
    delay(10);
  }
}

//------------------------------------------------------------------------------------------------------------------------




Advanced 3 key Adafruit ProTrinket 328P Arduino Sketch

//------------------------------------------------------------------------------------------------------------------------

/*

 Adafruit ProTrinket USB Keypedal  R.Hirst & Colin Russell  2016 v1

 NOTE: There may well be some known issues associated with using a ProTrinket on USB3 ports

 All defined pedal keys/combos are held down till the pedal is released. Repeating keys are handled by the operating system, as with a real keyboard!

 This sketch does not support key rollover Eg. pressing multiple pedal switches at once.

 Test Virtual Keyboard URL below

 Windows7 and above onscreen keyboard "OSK.exe" or  https://www.microsoft.com/appliedsciences/content/projects/MultiKeyDisplay.aspx

 ProTrinket Keyboard Library: https://github.com/adafruit/Pro_Trinket_USB_Keyboard_Library


 Keybinding Syntax example for characters
 -----------------------------------------
 TrinketKeyboard.pressKey(0, KEYCODE_A);

 Keybinding Syntax Example for Modifiers
 -----------------------------------------
 TrinketKeyboard.pressKey(KEYCODE_MOD_LEFT_SHIFT,0);

 Modifier examples:
 KEYCODE_MOD_LEFT_CONTROL , KEYCODE_MOD_RIGHT_ALT , KEYCODE_MOD_LEFT_SHIFT

 Keybinding Syntax Example for strings
 -----------------------------------------
 TrinketKeyboard.print("Hello World! ");


 */

#include <ProTrinketKeyboard.h>  // Ensure the library is installed

// MCU Pins

#define PedalPin1 5
#define PedalPin2 6
#define PedalPin3 8

// Optional Small delay for combos if required, so the PC thinks its a human
#define ComboDelay_1   5   // specify Combo Key press delaytime in ms here
#define ComboDelay_2   5   // specify Combo Key press delaytime in ms here
#define ComboDelay_3   5   // specify Combo Key press delaytime in ms here


// Optional small delay for switch debounce if required
#define BounceDelay_1  0   // specify debounce key press delaytime in ms here
#define BounceDelay_2  0   // specify debounce key press delaytime in ms here
#define BounceDelay_3  0   // specify debounce key press delaytime in ms here



void setup() {


  // Set MCU Pins to be an input,

  pinMode(PedalPin1, INPUT);
  pinMode(PedalPin2, INPUT);
  pinMode(PedalPin3, INPUT);
  
  // Set MCU Pins to be an HIGH,
  
  digitalWrite(PedalPin1, HIGH);
  digitalWrite(PedalPin2, HIGH);
  digitalWrite(PedalPin3, HIGH);
  

  delay(4000); // give some time for PC to detect the device



  TrinketKeyboard.begin(); // start keyboard
}

void loop() {

  // the poll function must be called at least once every 10 ms
  // or cause a keystroke
  // if it is not, then the computer may think that the device
  // has stopped working, and give errors
  TrinketKeyboard.poll();

  //------------------- Left Pedal---------------------

  while (digitalRead(PedalPin1) == LOW) {

    TrinketKeyboard.pressKey(0, KEYCODE_A);
    delay(ComboDelay_1);  // Small delay for combos, so teh PC thinks its a human
    

  }

  delay(BounceDelay_1);

  //------------------- Middle Pedal---------------------

  while (digitalRead(PedalPin2) == LOW) { // Middle Pedal

    TrinketKeyboard.pressKey(0, KEYCODE_B);
    delay(ComboDelay_2);   // Small delay for combos, so teh PC thinks its a human



  }

  delay(BounceDelay_2);
  //------------------- Right Pedal---------------------

  while (digitalRead(PedalPin3) == LOW) {

    TrinketKeyboard.pressKey(0, KEYCODE_C);
    delay(ComboDelay_3);   // Small delay for combos, so teh PC thinks its a human

  }

  delay(BounceDelay_3);

  if ((digitalRead(PedalPin1) == HIGH) && (digitalRead(PedalPin2) == HIGH) && (digitalRead(PedalPin3) == HIGH)) {

    TrinketKeyboard.pressKey(0, 0); // Release all keys

    delay(10);
  }
}
//------------------------------------------------------------------------------------------------------------------------


Test your footpedal on the below keyboard then start typing to test combinations

 


This guide pertains to the Olympus foot pedal, yet will be valid for any footpedal of this type. As they all share a similar construction, only varying in type of switch and the volume of the enclosure.

The below generic foot pedal was sent to me by a friend, and is probably more suited to this modification.




Post a Comment