
Capacitive Touch Sensor based morse key
by Sebastian Heyn, DL3SEH
Elektronik-Labor
Projekte
AVR
This
is another quick and dirty project of mine. I made it in two evenings.
I am trying to learn CW and I am not good with mechanical stuff, and
buying a finished morse key can be very expensive so another solution
had to be found. I read about capacitive touch sensors.
What
happens is basically, as you touch the sensor paddles, you increase the
capacity of the padle. The microcontroller can measure and detect that
change. The internal pullup resistors are used to "charge" the sensor
paddle. Its not really a measurement because its only a "if bigger
than" comparison, where the threshold is set to a fixed level based on
the final hardware build.
The
sourcecode and schematics on the bottom include another switch for
adjusting the speed. That switch is not shown on the pictures and
video. If you push & hold the key while touching one of the
sensors, the speed will decrease continously and then start from max
speed...
Materials:
- Electrical Junction box (Housing)
- PCB (I made the paddles from that)
- 4 sockets for connecting to power and the TX
- Capacitor
- 4007 Diode (SMD) for Protection
- 7805 SMD Regulator
- Attiny45
- 3 BC847 Transistors
- Some 0805 100nF's and resistors
- LED
- Speaker
- Breadboard PCB
Bascom Souces
$regfile = "attiny45.dat"
$crystal = 8000000 'Internal clock needs to be set in fuses!
'Short And Long Push - use byte as its faster to access than bit
Dim S As Byte
Dim L As Byte
Dim I As Byte
Dim A As Byte
Dim Length As Byte
'Speaker Out
Config Pinb.0 = Output
'LED / Transistor
Config Pinb.1 = Output
'Key for speed adjustment
Config Pinb.2 = Input
'Sensors
Config Pinb.3 = Output
Config Pinb.4 = Output
Const Verz = 2
Length = 100 'Initial Speed
Do
Ddrb.4 = 1 'Set to output
Portb.4 = 0 'Discharge the Sensor input (0)
Ddrb.4 = 0 'Set the Pin to INPUT
Portb.4 = 1 'pullup ON
nop 'Wait some time
nop
nop
nop
nop
nop
nop
nop
If Pinb.4 = 1 Then 'check if the PIN is at logical high level
S = 0
Else
S = 1
End If
Ddrb.4 = 1 'Set to
Portb.4 = 0 '
Ddrb.3 = 1
Portb.3 = 0
Ddrb.3 = 0
Portb.3 = 1
nop
nop
nop
nop
nop
nop
nop
nop
If Pinb.3 = 1 Then
L = 0
Else
L = 1
End If
Ddrb.3 = 1
Portb.3 = 0
If L > 0 Then Gosub Dah
If S > 0 Then Gosub Dit
' When both buttons are "pressed" dah-dit sequence is produced
Waitms 2
Loop
End
Dit:
Portb.1 = 1 'Set the LED
Gosub Sound1 'Sound procedure creates the tone and its also the delay procedure
Portb.1 = 0 'reset the LED
Gosub Nosound 'Delay without outputting the sound
If Pinb.2 = 0 Then Length = Length + 5 'If the third button (Not a touch sensor) is pushed, the speed gets slower
If Length > 200 Then Length = 0
Return
Dah:
Portb.1 = 1
Gosub Sound1 'Dah is tripple length then dit
Gosub Sound1
Gosub Sound1
Portb.1 = 0
Gosub Nosound
If Pinb.2 = 0 Then Length = Length + 5
If Length > 200 Then Length = 0
Return
Sound1:
For I = 1 To Length
Portb.0 = 1
Waitus 500
Portb.0 = 0
Waitus 700
Next
Return
'Same as above, but without setting any ports
Nosound:
For I = 1 To Length
nop
nop
Waitus 500
nop
nop
Waitus 700
Next
Return
Elektronik-Labor
Projekte
AVR