To wire up the Keypad to the Arduino Leonardo I've soldered some thin copper wire to the connector of the PCB and connected it to an external proto board as you can see in the picture below.
After that was done I wired up a simple adapter board for the Arduino Leonardo.
The schematic for this board is quite simple. It just consists of a 10Pin connector for the keypad, an RGB LED and two connectors for the LC-Diaplay and the Serial debug connection.
Creating the Program / Sketch
After the Keypad was wired up to the Leonardo I had to figure out a way to find get the key presses properly into the Arduino. THANKFULLY there was already a library on the Arduino page which does exactly THAT. I've played around a little bit with it and it seem to work properly.
I've created some test sketches and uploaded them into my GitHub repository.
Now I will need to find a way to replace the original PCB of the Keypad.
I'm using my Hotkey device now since some days and it is pretty practical for the daily workflow. So I've decided to make a more clean or professional version of the HotKey device.
The surprise
I've ordered one of these external USB number pads for notebooks just to have a look inside if there would be enough space to replace the electronics and maybe reuse the keypad matrix.
JACKPOT! After I have opened it I figured out that there is plenty of space for my upcoming PCB design and also the Keypad Matrix is not glued to the PCB its connected by a flat flex connector, so that it could be reused completely.
Some reverse engineering
A closer look to the area above the connector of the keypad shows us that the designer of the PCB was so kind to add some labelled test points for me.
This gave me the ability to quickly figure out which button triggers which row and column.
Ordered by key:
NUM
C1 R1
TAB
C5 R4
/
C4 R1
*
C3 R1
BCKSPC
C4 R2
7
C1 R2
8
C2 R2
9
C3 R2
"-"
C2 R1
4
C1 R3
5
C2 R3
6
C3 R3
"+"
C4 R3
1
C1 R4
2
C2 R4
3
C3 R4
Enter
C4 R4
0
C1 R5
00
C2 R5
.
C4 R5
Ordered by column and row:
C1 R1
NUM
C2 R1
-
C3 R1
*
C4 R1
/
C5 R1
C1 R2
7
C2 R2
8
C3 R2
9
C4 R2
BCKSPC
C5 R2
C1 R3
4
C2 R3
5
C3 R3
6
C4 R3
+
C5 R3
C1 R4
1
C2 R4
2
C3 R4
3
C4 R4
ENTER
C5 R4
TAB
C1 R5
0
C2 R5
00
C3 R5
C4 R5
.
C5 R5
Then it was quite easy to also figure out the pin out of the connector:
1
2
3
4
5
6
7
8
9
10
11
C1
C2
C3
C4
NC
R1
R2
R3
R4
R5
C5
What's Next?
The next step would be to wire up the keypad matrix to the Arduino Leonardo and figure out a proper algorithm to read the key presses from the matrix.
I use EAGLE, LTspice and a lot of other programs which gain a lot of more power an usability if the commands of the Hotkeys are known. But the main problem is that these program have all different Hotkeys/Commands which will vary from [CTRL]+C over the command "copy" to [F6] for copy something.
Even though I know most of the Hotkeys for each program I have often the problem to mistake them when I quickly switch between the different programs. So I thought about that problem and how I could get rid of it. I saw an Arduino sitting on one of my shelfs collecting some dust and I came to my mind that this litte device can "fake" the behaviour of mouse and keyboard on a computer.
I used this feature of the Leonardo before as it can be seen in one of my previous articles. So I've decided to give it a chance to solve my problem.
The proof of concept
I wired up a "shield" with some buttons for my Arduino Leonardo to test the concept and how I would like it.
I Know it looks ugly but it has worked quite well. Below I prepared the schematic for this shield to get a quick overview over the wiring.
The Shield has nine buttons for the Hotkeys and two to select the current configuration. I also added a RGB LED and a 16x2 LC-Display through the I2C connection to show additional information on the currently active configuration. It also got a connector for the serial output for debugging purposes.
All buttons are biased trough the internal pull up resistors of the MCU so that they switch to ground when they are pushed. This saved me 11 Resistors of wiring effort for the board.
I've added the corresponding Arduino sketch to my github repository. You will need a library for the I2C connection of a LC-Display or just comment the line with the definition of LCD_I2C_ACTIVE out.
#defineLCD_I2C_ACTIVE// Uncomment to activate the LCD Output
After some tests...
... I decided that I should follow the idea with a HotKey pad to increase the usability of my favourite programs. So stay tuned for the upcoming articles if you want further information about the HotKey pad.
At the moment I'm playing around with a Wien Bridge Oscillator, or to say it better I have tried the last two days to get it working.
I have found an application note from Analog Devices (AN580) which describes an circuit of the Wien Bridge Oscillator with two diodes for the stabilization of the output swing. In the schematic of the application note are also two digital potentiometers used to set the frequency and to manipulate the size of the output swing. This two potentiometers could be replaced by common potentiometers.
On this page I have found additional informations about this circuit which also helped me to finally get it run.
The Circuit
Some notes for the schematic:
The values for R1 and R2 must be equal and also the values for C1 and C2.
By increasing or decreasing the values of C1,C2 or R1, R2 the frequency can be changed. I would recommend a linear stereo potentiometer for R1 and R2 this makes it easy to change the values simultaneously.
If the capacitance or the resistance gets larger the frequency becomes slower.
LED1 and LED2 control the amplitude of the output swing. As higher the forward voltage of the LEDs the higher the amplitude of the output swing.
Set the gain with the potentiometer R4 so that the LEDs (both) just begin to light up. If the gain is to large the distortion will be very high.
IMPORTANT!!!
In the schematic I also have implemented a voltage divider to connect my Arduino Leonardo. ATTENTION both, the Arduino and the Wien Bridge Oscillator are powered form independent and insulated power sources. Only in this case it is possible to connect the negative 12V to the GND of the Arduino. YOU CAN KILL YOUR USB PORT AND/OR YOUR COMPLETE PC !!!
To make sure that both power supplies are independent from each other Measure the voltage between the GND pin of the Arduino while it is connected to its power source (USB-Port) and the three supply rails (+12V GND -12V) of the Wien Bridge Oscillator. The Voltage in this case should be very close to 0 (I have measured values below 20mV for each line).
DO !NOT! CONNECT THE GND OF THE ARDUINO TO THE GND OF THE WIEN BRIDGE OSCILLATOR. THE ARDUINO IS GOING TO BE KILLED!!
The next important part is to make sure that the output of the voltage divider (R6, R7) never can have more than 5V otherwise you are going to kill the Arduino.
The calculation for the voltage divider is quite simple. To calculate the voltage divider the maximum possible voltage (even in a case of failure) between the GND of the Arduino and the the OUT of the Oscillator must be known. In this case the GND of the Arduino is connected to the -12V of the Oscillator. The maximum positive voltage is +12V both together have 24V.
Vmax / (R6+R7) * R7
24V / (39k+10k) * 10k = 4.9V
With a maximum output voltage of 4.9V after the voltage divider it would be no problem to connect the Arduino.
The Problem
The main problem was that I was not able to see the waveform of the output, which makes it more or less impossible to see if the output swing of the OPAMP goes to its positive or negative maximum values so that the result is more like a square wave with sinus parts at the rise and fall.
Due to the fact that I only want to use very low frequencies (<500Hz and in this sample approximately 160Hz) I thought it could be possible that the analog inputs of an AVR are fast enough to get a rough look at the waveform.
After first tests I have figured out that I'm able to measure approximately 8 times per ms (each 120ns) which is a sampling rate of 8330 kHz. For me it would be OK to use this for frequencies below 500Hz because at 500Hz we still have more than 10 Measure points per period. With 10 measured points per period a sinus signal does not look very beautiful but it could be identified as a sinus signal.
I assume that the speed could be increased if the analog value is measured directly without the Arduino libraries. The datasheet of the ATmega32U4 says that a sample rate of up to 15k samples per second is possible at full resolution (10Bit). And in the datasheet of the ATmega328 is the same statement for the full 10Bit measurements.
The Waveform Viewer
To make it short: Here is the code it can be downloaded from my Github repository.
The code itself is quite simple. My first attempt was to sample 255 times the analog value into an array and then send the array formatted to the Arduino serial monitor so that I only have to make copy and paste into the spreadsheet.
This has worked very well but I am lazy. So I remembered that I have an Arduino Leonardo in the drawer which could type the values directly into the spreadsheet.
I've added the keyboard code to the sketch and programmed it to my Arduino Leonardo and it worked more or less instantly.
Now the life got very easy, I only have to push one button to get all the values including the time stamp into the spreadsheet. The next step would be to just look onto the Arduino to start the sampling :-)
After the values have been entered into the spreadsheet I have made a graph from the values to watch the waveform.
Here I have the OpenOffice file which I have used to show the graph. To let the Arduino enter the values into the sheet just select the box A1 and press the startButton (pull pin 7 to GND). You can repeat this as often as you want because the graph automatically changes after the values have been entered, just push the button again.