Web: www.qsl.net/dl4yhf/USB_CW_Keying_Adapter/index.htm Author: Wolfgang Büscher, DL4YHF Date: 2025-11-14
Under construction !
This file describes a microcontroller project for a CW Keying Adapter
for the USB port, with a Virtual COM Port implemented in firmware
(to eliminate the need for a USB/UART adapter like the famous FTDI chips).
Features:

Screenshot of the author's 'Remote CW Keyer' with the USB CW Keying Adapter selected.
// WB's breadboard sketched below, based on the PIC18F46J50/PIC18F25J50
// datasheet, DS39931D, Page 5 (Pin Diagram for 28-pin SPDIP).
//
// Not shown here: Application-specific use of the "remaining"
// I/O pins, e.g. inputs from the Morse key, keying output,
// sidetone / "beeper" output,
// rotary encoder, TFT display or LED indicators,
// 'analog potentiometer', SPI, I2C, UART, etc.
// Even the "XTAL" (external crystal on OSC1/RA7 + OSC2/RA6)
// later turned out unnecessary, because even "USB Full Speed"
// worked flawlessly when the 48 MHz clock was provided by
// the PIC's *internal* oscillator.
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// 100 ____
// ,--|____|-------------------------------------------------------------<-- (1) PICkit4 RESET output
// | ,-------------------------------------------------------------, (2) PICkit4 Target-Vdd (measured)
// *->--| 1 /MCLR (Reset input, see text) RB7/KBI3/PGD/RP10 28 |--<-> (4) PICkit4 DATA via 100 Ohm
// | 2 RA0/AN0/C1INA/ULPWU/RP0 RB6/KBI2/PGC/RP9 27 |--<-- (5) PICkit4 CLOCK via 100 Ohm
// | 3 RA1/AN1/C2INA/RP1 RB5/KBI1/SDI1/SDA1/RP8 26 | (3) PICkit4 GROUND
// | 4 RA2/AN2/Vref-/CVref/C2INB RB4/PMA1/KBI0/SCK1/SCL1/RP7 25 | _|_ (see PICkit4 pinout below)
// 10uF | 5 RA3/AN3/Vref+/C1INB RB3/AN9/CTED2/VPO/RP6 24 |
// ,-||--| 6 VddCORE/Vcap RB2/AN8/CTED1/VMO/REFO/RP5 23 |
// | | 7 RA5 /AN4/SS1/HLVDIN/RCV/RP2 RB1/AN10/RTCC/RP4 22 |
// *-----| 8 Vss (aka GROUND) RB0/AN12/INT0/RP3 21 |
// _|_ ,--| 9 OSC1/CLKI/RA7 Vdd 20 |--------*---O +3.3V
// |,-| 10 OSC2/CLKO/RA6 Vss (aka GROUND) 19 |----, _|_
// XTAL? | 11 RC0/T1OSO/T1CKI/RP11 RC7/RX1/DT1/SDO1/RP18 18 | | ___ 100 nF
// | 12 RC1/T1OSI/UOE/RP12 RC6/TX1/CK1/RP17 17 | _|_ _|_ GND
// 3.3V | 13 RC2/AN11/CTPLS/RP13 RC5/D+/VP 16 |--> USB D+ : GREEN
// O--*--| 14 Vusb PIC18F25J50-I/SP RC4/D-/VM 15 |--> USB D- : WHITE
// _|_ '-------------------------------------------------------------' USB +5V: RED
// ___ 100 nF (see DS39931D page 360, "USB Internal Transceiver". USB_GND: BLACK
// _|_ The PICs "Vusb" MUST NOT BE CONNECTED to the "USB +5V"!)
//
// PICkit4 pinout: 1=/MCLR/Vpp, 2=Target-Vdd, 3=GROUND, 4=PGD, 5=PGC, 6..9: DON'T CONNECT
// For 'standalone' operation without debugger control, add this
// passive circuitry for /MCLR shown in the PIC18F46J50 datasheet
// (DS39931D page 29, "FIGURE 2-1: RECOMMENDED MINIMUM CONNECTIONS") :
// ____ ____
// Vdd (+3.3 V) O----|____|---*---|____|----> "/MCLR" (PIC pin 1)
// 100 kOhm | 1 kOhm
// _|_ \__ prevents shunting "MCLR/Vpp"
// ___ 100 nF to ground via the cap, because
// | ICSP needs fast switching of MCLR !
// _|_ GND
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Keyer signal | USB CDC signal | PIC18F25J50 pin number, port
----------------+----------------+---------------------------------
"Dot" input | DCD | 25, "RB4", with internal pull-up
"Dash" input | DSR | 26, "RB5", with internal pull-up
Keying output | - (**) | 23, "RB2" H=carrier on, L=off (*)
PTT output | - (**) | 24, "RB3" H=transmit, L=receive (*)
(*) These "digital" outputs at the PIC are intended to drive
NPN transistors or N-Channel MOSFETs, thus "H" = active.
(**) At the time of this writing, it wasn't clear if the two
precious 'emulated outputs' (DTR, RTS, from host to device)
would be used to drive these 'digital outputs' on the PIC,
in addition to driving them from the planned 'Elbug emulator'.
Most likely, the keying- and PTT output can be controlled
from the host via special test command (character string),
to reduce the risk of the transceiver starting to send
just because an application was 'talking to the wrong COM
port'.