The point of making a memory keyer without prior knowledge of PIC microcomputer (& C language)
- Find a homepage that explains how to turn on / off the LED with a PIC microcomputer
- The memory keyer has the same principle as blinking the LED of the I/F photocoupler at the desired timing, so if you devise a little, you can do something about it!
So what method did I actually take?
- Find a homepage that explains how to turn on / off the LED with a PIC microcomputer, and actually make it.
・Install the software called "MPLAB X IDE" that is provided free of charge from the Microchip website.
・Buy Microchip's "PICkit3" (5,000 yen at Akizuki Denshi) or "PICkit4"
・For example, I copied the LED blinking circuit of "Introduction to PIC Microcomputer Electronic Work Basics" of "Tool Lab".
・From the "Tool Lab" https://tool-lab.com/pic-basic/ figure (lower left and center figure), I made something like the picture on the lower right and tested it.
Program to install (after compiling) This is also quoted from "Tool Lab" (Thank you for your help!)
Extend to memory keyer
- 8pin PIC (PIC12F1822) is used as it is. Use 6 pins for I / F other than 2 pin which is power supply
・RA0 and RA1 are the switch status inputs and are the inputs for the electric keyer dash and dot.
・RA2 is for speed setting, and the external voltage (variable resistance set value) is read by the AD converter.
・RA3 and RA5 are switch inputs as memory keys
・RA4 is an output. (Photo coupler / LED light / buzzer, etc.)
It is a program to install (created by imitating what I see! I think there is a more elegant way of writing,hi)
- // PIC設定
OSCCON = 0b01011010;Set internal clock frequency to 1MHz
ANSELA = 0b00000100;Set RA2 to analog mode (all others set to digital mode)
>> RA0, RA1, RA2 ... from the right end (bit0), "1" for the third from the right end
TRISA = 0b00101111;Set RA4 to output mode (all others set to input mode (RA3 pin is always in input mode))
>> 5th from the right end is "1"
ADCON0 = 0b00001001;Set RA2 to AD converter pin and make AD converter function accessible
>> bit0 turns on ADC. Set bit1 to "0" and start ADC with "1". bit2-4 is "010" when using RA2 for ADC
ADCON1 = 0b10000000;The result value is right-justified, the clock is Fosc / 2 (000), and the reference power supply is VDD.
>>bit0-1 is the reference voltage setting, and "00" is the power supply voltage. bit4-6 is the conversion time setting, 2us at 1MHz "000". bit7 is right-justified with "1"
- When GO = 1 changes to GO = 0, AD conversion ends, and the AD conversion result goes into "ADRES", so adjust the coefficient appropriately.
GO = 1;
while(GO);
n = ADRES/8;
n3 = n*3;
- RA1 == 0 In other words, when SW1 is pressed, dash () is executed.
if(RA1==0){
dash();
}
- function dash() is
void dash(){
LATA = 0b00010000;
wait(n3);
LATA = 0b00000000;
wait(n);
}
- The function wait () is as follows
void wait(n){
int i;
for(i=0; i<n; i++){
__delay_us(1000);
}
}
Extend to a practical memory keyer with PIC16F1509
- Use 20pin PIC (PIC16F1509) and use 17pin out of 18pin other than 2pin of power supply (1ch is spare)
・RA4, RA5, RC3, RC4, RC5, RC6, RC7 are for memory (7ch)
・Connect the electric paddle (dash and dot) to RB4 and RB5
・DIP SW1 (RA2) enables reverse (long / short reversal) of the electric paddle
・DIP SW2 (RC0) and DIP SW3 (RC1) are for setting operational status (home, destination, separate home, etc.)
・RA1 is for speed setting, and the external voltage (variable resistance set value) is read by the AD converter.
・RA3 and RA5 are switch-connected as a memory keyer
・RA0 is for buzzer output (can be muted with DIP SW4), RB7 is for LED output, RB6 is for photocoupler output (to transmitter)
The program to install (only the initial settings and the number of switches / output have changed slightly)
Added reset switch (MLRC) and changed buzzer to piezoelectric speaker
- Added a reset switch to use when you notice a mistake in pressing during transmission
・Use RA3 (MLRC)
#pragma config MCLRE = ON // MCLR Pin Function Select (MCLR/VPP pin function is digital input)
・Added a small yellow tact switch (in front of the battery box)
- Change the buzzer to a piezoelectric speaker
・Added 1000Hz square wave
void tone(n){
int i;
for(i=0; i LATA = 0b00000001;
LATB = 0b11000000;
__delay_us(500); //500μs ON
LATA = 0b00000000;
LATB = 0b11000000;
__delay_us(500); //500μs OFF
}
}
・For example,"A" becomes the following function
void morsea(n,n3){
tone(n); //dot
LATA=0b00000000;
LATB=0b00000000;
wait(n);
tone(n3); //dash
LATA=0b00000000;
LATB=0b00000000;
wait(n3);
}
The program to install
Since it is a good idea, we will add a Morse code hearing practice function (switch with DIP SW 2).
- Switching according to the status of RC0 (DIP SW 2) in the main program
// Keyer mode (RC0=0) and Practice mode (RC0=1)
if(RC0==0) keyer(n,n3);
if(RC0==1) pract(n,n3);
- The contents of practice mode generate random numbers and assign Morse code to them.
void pract(n,n3){ // Practice mode
int i,x1;
int a=11;
int b= 3;
int M=1000; // Generate 1000 random numbers
int x=8;
for(i=0; i<M; i++){
x1 = (a*x+b)%M+1; // Generation of pseudo-random numbers by linear congruential method
if(x1>0 && x1<=20) morse1(n,n3);
if(x1>20 && x1<=40) morse2(n,n3);
if(x1>40 && x1<=60) morse3(n,n3);
(Continued ...)
}
The program to install
PIC16F1509 will not change and will challenge miniaturization
- Use 20pin PIC16F1509 and use 17pin out of 18pin other than 2pin for power supply (1ch (RC1) is spare)
・RA4 (tact SW: black), RA5 (brown), RC3 (red), RC4 (orange), RC5 (yellow), RC6 (green), RC7 (blue) are for memory (7ch)
・RA3 / MCLR (tact SW: white) is for reset (signal interruption)
・For RB4 and RB5, go to the 3.5mm stereo mini jack (left, red circle). Connect electric paddles (dash, dot)
・Photocoupler output to 3.5mm stereo mini jack (right). From here to the key jack of the transmitter.
・Change of electric mode / Morse reception mode by DIP SW1 (RA1)
・DIP SW2 (RA2) enables reverse (long / short reversal) of the electric paddle
・DIP SW3 (RC0) switches between high and low monitor sounds
・Monitor sound ON / OFF with DIP SW5 (DIP SW4 is empty)
・VR (left) is a variable resistor for monitor sound
・VR (right) is for Morse code speed setting
・Power supply is LR44 (1.5V) x 2
The program to install
Small & Light weight Memory Keyer for SOTA
(with Morse code hearing practice function)
The document to DL