Transmitter Sequencer

This page will be updated as the project progresses. The current schematic is here.

The project is designed to prevent hot switching of the RF bypass relay in an RF amplifier. It does this by putting the amplifier in transmit mode (activating the relay) as soon as a transmit request is received (on one of the key or PTT lines). After a user configurable delay (default 100 ms), the PTT or key signal is passed through to the transmitter. In addition, there is a user settable Key Operated Send dropout time. A front panel pot lets the user set the release time of the amplifier keying output to zero to 10 seconds after the key or PTT line is released. For example, as demonstrated in the video at the right, hitting the KeyB input immediately activates the amplifer enable output. 100 ms later, the KeyB output is enabled. When the KeyB input is released, the KeyB output is immediately released, but the amplifier enable output is not released. The amplifier stays in the transmit mode until the KOS timeout (I generally set it to 3 seconds) times out (such as 3 seconds after the KeyB input is released). KeyA behaves the same as KeyB. These two inputs and outputs typically pass a CW paddle signal through to the transmitter. If a straight key or bug is used, the KeyA and KeyB inputs can be tied together with the KeyA output driving one transmitter and the KeyB output driving another transmitter.

There are two additional keying inputs: MicPTT and AuxPTT. These operate similarly to the KeyA and KeyB inputs except that on release, the amplifier transmit enable is released immediately. The amplifier PTT is released after the user confiugrable delay, the same delay that was used on transmit start, with the default being 100 ms.

Finally, there is an RTTY Keyboard Operated Send input. This is wired ACROSS the Teletype. When a key on the Teletype is pressed, the start bit plus any space bits in the character result in a high voltage across the Teletype (the full loop supply voltage, which is typically 50 to 100 volts). This trips the KOS functionality of the device, causing the amplifier to be switched to transmit, then, after a delay, the transmitter PTT is enabled. However, during receive, a mark to space transition results in high voltage across the Teletype due to the selector magnet flyback voltage. However, this high voltage pulse is very short compared to a bit time (22 ms for 45.45 baud or 60 wpm). The firmware ignores any high voltage pulses shorter than 11 ms (half a bit time).

Hardware

Refer to the schematic.

  • Power Supply - The system is driven directly off the 5V USB power and is switched by the switch on the KOS drop out time front panel pot. The system draws about 7 mA plus about 4 mA for each LED that is lit.
  • USB Interface - U3 is a USB to UART bridge. The chip is configured using FT PROG. The following settings are made in FT PROG.
    • Press F5 to scan for FTDI chips and parse the EEPROM.
    • Under USB String Descriptors, change the manufacturer to "w6iwi.org". Change the product description to "Transmitter Sequencer".
    • Under Hardware Specific, select Battery Charge Detect. Check Battery Charge Enable and Force Power Enable. As described in FTDI AN 175, these settings will enable the detection of a charger (which supplies 5 volts and has the data pins shorted).
    • Under USB Config Descriptor, select Bus Powered, 100 mA, and USB Remote Wakeup.
    • All other settings can stay at their default values.
    • Hit control-P, then the program button to program the chip.
  • U3 interfaces the USB port to the UART in U1. The UART is configured to run at 19.2 kbps, 8N1, XON/XOFF, half duplex, and 1 millisecond delay between characters.
  • PTT Inputs - The Push To Talk inputs (and Key inputs) are active low. They are pulled to +5V with a 10k pullup resistor. The line then passes through a 470 ohm resistor, then a 0.1 uF capacitor to +5V. This resistor and capacitor provide RFI protection to prevent RF from getting into the system. The capacitors go to +5V instead of ground so that we do not have all inputs pulled low on power up.
  • KsrVoltage Input - This input is placed across a Teletype machine (across the keyboard and selector magnets in series). If there are multiple machines that can key the loop (such as a Transmitter Distributor), The KeyVoltage input can be across the series combination of these machines. The KeyVoltage input is looking for a high voltage indicating that the keyboard is open (such as during a start bit). There is also high voltage across the machine when the keyboard is not active but data is being printed. This is due to the flyback voltage across the selector magnets. However, this flyback voltage pulse is quite short compared with a start bit or data bit. The firmware requires the high voltage be present for at least 11 ms to trip the Keyboard Operated Send function.
  • Outputs - Separate floating SSR outputs are provided to key each piece of equipment. A variety of different SSRs can be plugged in to meet the voltage and current requirements of the driven equipment. The SSR part numbers are listed on the schematic and on the PCB. The SSRs consist of an LED driving a series pair of FETs. The outputs can drive DC or AC loads and are polarity independent. The SSR LEDs are in series with a front panel LED so operation of the system can be observed.
  • KOS Delay Seconds - The number of seconds between the last character in either CW or RTTY and the dropping of the transmitter followed by the dropping of the amplifier is set by R1, a front panel 10k pot.
  • Program/Debug - A debugger can be plugged onto J1 to program or debug U1. Tested debuggers include the Microchip PicKit3 and the Microchip SNAP. The PicKit3 is plugged onto the first 5 pins of J1. The SNAP is plugged onto all 8 pins of J1. A jumper is required between pins 7 and 8 of J1 to enable the CW sidetone. In addition, the command t1 is required to enable CW sidetone. The jumper should be removed when programming or debugging the chip since the transducer is between the PGC and PGD programming lines.
  • KOS Delay Seconds - R1, the front panel 10k linear taper pot provides a voltage between 0 and 5 volts to an ADC input of the microcontroller to set the Keyboard Operated Send dropout time.
  • Microcontroller - U1 provides all the logic and timing for the device. It also contains a simple command interpreter to receive configuration commands. Configuration data is stored in internal EEPROM and restored on system reset.

Firmware

The firmware is written in C and available here.

main.c

main.c initializes the hardware, reads configuration data from eeprom, then enters the main loop. Timer2 is set to time out once each millisecond. When it times out, PIR1bits.TMR2IF changes from 0 to 1. Instead of having an ISR increment or decrement a bunch of RAM timers, the main loop just waits for PIR1bits.TMR2IF to be 1, then decrements the various timers and polls the inputs. When PIR1bits.TMR2IF is 0, the CommandInterpreter() is run. It accepts single letter commands with an optional parameter.

KosMilliseconds is calculated from the pot ADC reading. KosMilliseconds is set based on a slope-intercept equation with m=2000/241 and b=364000/241. This causes the KosMilliseconds value to agree with the front panel markings. In addition, if KosMilliseconds is less than 2 times AmpDelayMilliseconds, KosMilliseconds is set to 2 times AmpDelayMilliseconds.

Bootloader

In the XC8 linker options, the Code Offset is set to 0x600. This shifts all code up by 0x600 bytes UNLESS the __at directive is used to specify an address. This causes the application code to start at 0x600 while the bootloader code is below that address.

bootloader.c uses the previously mentioned __at directive to manually place the functions used by the bootloader. Note that the optimization level is set to 1. Setting it to 0 would require moving things around. The function declarations include the __at directive setting the location of each function. Note that the BootVectors function has the naked attribute so no function prologue or epilog code is generated.

BootVectors() places goto instructions at the reset and interrupt vector locations (even though this application does not use interrupts). The goto at the reset vector (0x0000) sends us to BootInit() in bootloader.c. The goto at 0x0008 (high priority interrupt vector) redirects the interrupt to AppStartAddr+0x08 (0x0608), which is where the high priority interrupt code would be after the 0x600 address offset applied in the linker. The goto at 0x0018 (low priority interrupt vector) redirects the interrupt to AppStartAddr+0x18 (0x0618), the location of the low priority interrupt code after the 0x600 offset is applied by the linker.

BootInit() initializes the FSR registers that are used for the paramater and automatic local variables stack. This is normally handled by the application startup code, but that code has been moved above 0x600 as part of the application. Further, the startup code handles the allocation of global and static variables. This bootloader code uses only local automatic variables, so they are placed on the stack and disposed of on the function exit. The bootloader use of RAM therefore does not decrease the amount of RAM available to the application.

BootInit() then checks PORTAbits.RA4, the KeyB input. If this input is high, a goto sends the CPU to the relocated start vector at 0x600. If the input is low, Bootloader() is run.

Bootloader() initializes the UART that is driven by the USB bridge (U3). It then waits for characters of an Intel hex file sent to the USB port. These are buffered in LineBuf[]. LineBuf[8] holds the number of bytes in the record (usually 16). This is used to compute the location in LineBuf of the record checksum. If the checksum is zero, the the record type (00=data, 01=end, 04=ExtendedLinearAddress). If the record type is ELA, the ELA value is stored. If the record type is data, the start address specified in the record is determined, and the ELA added to yield the destination address in the PIC flash. Also, the hex data in LineBuf is converted to binaryIf in BinaryBuf. This is the binary bytes that will be put in flash. If the destination address is in the application area of flash, StreamProgramPicFlash() is called to program flash with the data contained in this record. The destination address check ensures that the bootloader is not corrupted by a bootloaded hex file. In addition, LATAbits.LATA6 (the AmpPTT output) is toggled on each record giving an indication of bootload activity.

StreamProgramPicFlash() is passed the flash address to be programmed, the number of bytes to be programmed, and a pointer to the binary data array. This particular chip erases blocks of 64 bytes and programs blocks of 8 bytes. When landing on a 64 byte boundary (either by being passed that address or by incrementing to it), the new block is erased. After 8 bytes have been sent to the program latches, the program sequence is called.

The programming of 8 bytes at a time requires the Intel Hex file to have an even multiple of 8 data bytes. The Format Hex For Download option in the linker configuration ensures that each record contains 16 bytes.

The erase on 64 byte boundaries raises another issue. If the start of the stream of code is not on a 64 byte boundary, that page of the chip will not be erased prior to programming resulting in corruption. To ensure that we do not miss a 64 byte boundary, a different technique is used to generate the Intel hex file. A chip is programmed with the debugger (in program mode, not debug), then the contents of the chip are read back to a hex file using the green up arrow in MPLABX and Read Device Memory to File. This results in a hex file containing all the flash data for the chip, including that not used. Use of this hex file ensures we will cross the 64 byte erase boundary before programming any memory in that section. The bootload process is longer, but this is a simple way to avoid the issue. The file TxSeqFullMemory.hex is the hex file containing the full flash image.

Memory Map

Below are a few points in the memory map

  • 0000 GOTO 0x20 ; Reset vector to BootInit()
  • 0008 GOTO 0x608 ; Redirect high priority interrupt vector
  • 0018 GOTO 0x618 ; Redirect low priority interrupt vector
  • 0020 LFSR 1, 0x0 ; Start of BootInit()
  • 0510 BRA 0x526 ; Start of bPrintString, last function in bootload.calculated
  • 0538 BRA 0x512 ; End of bPrintString
  • 053A to 05FE - Erased flash reads 0xff
  • 0600 NOP ; Start of application
  • 0602 GOTO 0x1FFC ; goto application C startup code
  • 1FFC GOTO 0x14F4 ; This appears to be a place to insert user reset code.
  • 14F4 MOVLW 0x27 ; Start of application C startup code which initializes stack and variables.
  • 0606 to 141E ; Erased flash
  • 1420 to 1fff ; Application code
Note that some of the programmed blocks to do not start on 64 byte blocks.

Installation

Inputs

  • KeyA - CW straight key, cootie, bug, or dit side of paddle. Other side of key goes to ground
  • KeyB - CW straight key, cootie, bug, or dah side of paddle. Other side of key goes to ground. Paddle dit and dah connections can be reversed. If KeyB is grounded on power up, system enters bootloader.
  • MicPTT - PTT switch from microphone. Other side goes to ground.
  • AuxPTT - Typically PTT line from a computer used to transmit digital signals (FT8, RTTY, PSK, etc.). The other side of this switch goes to ground.
  • KSR Sense - Wire across a KSR or ASR Teletype.
Note, all inputs are switched to ground and have a 10k pullup to +5V. These inputs can be driven with TTL, open collector, and open drain outputs.

Outputs

  • KeyA - Pair that closes when KeyA input is closed. If AmpPTT is not enabled, KeyA is delayed by the transmitter delay (typically 100 ms).
  • KeyB - Pair that closes when KeyB input is closed. If AmpPTT is not enabled, KeyB is delayed by the transmitter delay (typically 100 ms).
  • TxPTT - Pair that closes if MicPTT or AuxPTT inputs are closed or if data is detected on KSR Sense. If AmpPTT is not enabled, this is delayed by the transmitter delay (typically 100 ms).
  • AmpPTT - Closes when transmitting is desired as indicated by KeyA, KeyB, MicPTT, AuxPTT or KSR Sense. The appropriate transmitter PTT output is enabled after the transmit delay. AmpPTT releases TxDelay (tyically 100 ms) after TxPTT is released to avoid hot switching in the amplifier. AmpPTT is released KOS delay seconds after the release of KeyA, KeyB, or the last character detected on KSR Sense. This avoids having the amplifier follow CW or dropping after each character in RTTY.
  • TuPTT - This pair is closed TxDelay after detection of KSR Sense. This can drive the transmit enable line of a terminal unit (such as SEND-N on P1-9 of a Flesher TU-170A or TU-300.
All outputs are floating SSR outputs that can drive AC or DC loads and are not polarity sensitive. The SSRs are socket mounted to allow selection based on the required load voltage and current.
Part NumberVoltageCurrent
G3VM-41AY140 V2 A
G3VM-61AY160 V500 mA
G3VM-201AY1200 V250 mA
G3VM-351AY1350 V100 mA
G3VM-401AY1400 V120 mA
G3VM-601AY1600 V90 mA

Configuration

For many installations, the default configuration is fine (transmit delay of 100 ms). If the transmit delay needs to be changed for the CW sidetone enabled or disabled, do the following.

  1. Open Device Manager (Windows) or similar application.
  2. Turn on the transmitter sequencer while watching the COM port section of Device Manager. A new COM port should show up with the device is turned on.
  3. Open Tera Term.
  4. Select a serial connection and the COM port identified above.
  5. Select Setup - Serial Port. Set speed to 19200. Set Flow Control to XON/XOFF. Set the Transmit Delay to 1 ms/char. Click OK
  6. Select Setup - Terminal. Ceck Local Echo. Click OK.
  7. Type "r[enter]" without the quotes. This should reset the system, and you should see the screen showing information about the command interpreter.
  8. Use one of the displayed commands to change the configuaration. Changed settings are immediately saved to EEPROM.

Bootload New Firmware

  1. Configure Tera Term as shown above (in Configuration).
  2. Turn off the transceiver to ensure it does not transmit during this process.
  3. Close KeyB and either type r[enter] or power cycle the system to reset the system and enter the bootloader. The AmpPTT LED will be lit when the bootloader is ready. In addition, a prompt to send the hex file should appear in Tera Term.
  4. In Tera Term, select File - Send File.
  5. Select the hex file to be sent. The other settings do not need to be changed from their default values.
  6. Click OK. The file should be sent resulting in a slow flashing of the AmpPTT LED.
  7. When the new firmware has loaded, the system should reset and show the startup screen on Tera Term. That screen shows the firmware build date.

Operation

The system should properly sequence the transmitter and amplifier for CW, voice, and RTTY. The only routine adjustment is the KOS Delay Seconds. Adjust this to a value high enough to avoid having the amplifier drop out between characters on CW or RTTY.

Construction

The parts list is available as a Digikey List here.

I'm using a YIHUA 959D hot air rework station with Essmetuim ZB628 solder paste. The air temperature was set to 380 C. A small amount of solder paste is put on each pad for the 0603 parts. The part is then placed and soldered with the rework station. The air speed is set to minimum to reduce the chance of blowing the part off the pads. If there is excess solder paste, the part may float away on the melted flux. The high temperature tends to melt the solder and flux at close to the same time so the part does not have an opportunity to float away.

When soldering down the chips, I am applying solder paste to a few pins at a corner of the chip. Then carefully aligning the chip such that all the pins are on all the pads (this is best done under a microscope). The solder paste is heated to solder the part in place. The chip alignment is again checked under a microscope. If there is slight misalignment, the chip can be pushed into the correct position. If it cannot, only the few pins soldered need to be heated to remove the chip and try again. Once the chip is properly aligned, a thin stream of solder paste is applied where the pins meet the pads on the remainder of the pins. Heat the solder paste to solder the chip in place, starting with pins that are far away from those that are already soldered so the chip does not have an opportunity to move. Examine the soldering job with magnifiers or a microscope. Short circuits between pins can often be removed by dragging a hot soldering iron from the chip down the pins away from the chip. If this does not work, and there is excess solder, solder wick can be used to remove the excess solder.

Initial Programming

Plug the programmer (such as a Microchip PicKit3 or the Microchip SNAP. The PicKit3 is plugged onto the first 5 pins of J1. The SNAP is plugged onto all 8 pins of J1. The jumper between pins 7 and 8 of J1 should be removed during programming. Either load and compile the complete project in MPLABX or use MPLABX IPE to program the chip with TxSeqFullMemory.hex.



The video above shows the transmitter sequencer installed and running. The sequencer is delaying the bug keying signal to the transceiver until 100 ms after the PTT has been sent to the amplifier. The amplifier PTT is dropped about 2 seconds after the last key closure (this is the KOS (Keyboard Operated Send) delay that is set on the front panel. Front panel LEDs indicate the state of each output SSR. Although not audible in the video, the sequencer includes a piezoelectric transducer on the PCB. This provides 500 Hz CW sidetone.





The image above shows the PCB mounted in the case. Note that in this revision (rev B), the PCB mounting holes did not get drilled. The PCB is held in place by a drop of RTV adhesive on the center PCB mounting post in the enclosure. The front of the PCB is held in place by the bushing for the front panel pot and the LED light pipes. The round black object is a piezoelectric transducer that supplies CW sidetone at 500 Hz. It can be enabled and disabled through a jumper on J1 and also through a command on the terminal.





The above image shows the front panel. The pot at the right sets the KOS dropout delay and includes the power switch. The five indicators are LEDs in series with the output SSRs. The LEDs are 0603 SMT LEDs with light pipes above them to make the LED light appear on the front panel.





The image above shows the rear panel. The USB port is used for power. A terminal program (such as Tera Term, can be used to configure the system. The configuration commands are shown in a screen shot further down this page. The USB port is also used to load new firmware as shown later on this page. The left terminal block is inputs the sequencer. Everything except the KSR Sense is looking for a contact closure to ground. Each input has a 10k pullup to +5V. The KSR sense is opto isolated and is to be wired across a KSR printer (keyboard and selector magents in series). It a 1/4 inch TRS connector is used to plug equipment into the 60 mA loop, a 1/4 inch TRS Y connector such as this. When the keyboard opens, high voltage appears across the KSR sense input for 22 ms or more. This trips the Keyboard Operated Send sequence that switches the amplifier to transmit, delays, then turns on the transmitter and enables the terminal unit transmit. When the printer is receiving data, there is also high voltage across the machine. On a mark to space transition, the selector magnets generate a "flyback" voltage. On a space to mark transition, a high voltage pulse is also generated as the selector magnet current ramps up. These two voltage spikes are considerably shorter than the 22 ms bittime (60 wpm). They are about 2 ms. The software requires a pulse of at least 11 ms to trip the KOS, so KOS is activated on keyboard activity, not on received data.





The video above is a quick demo of the preliminary transmitter sequencer. The video says that the transmitter and amplifier drop at the same time when the microphone PTT is released. The current firmware drops the amplifier after the transmitter (default 100 ms). The video is showing a rev A board. It DOES have the three mounting holes, but the footprint for the USB interface chip is wrong. Rev B fixed the footprint but lost the mounting holes.






The image above shows the user interface through the USB interface with Tera Term. The serial port is set to 19.6 kbps, 8N1, XON/XOFF handshake, and a 1 ms character delay. In the setup terminal menu, local echo is enabled (half duplex operation(). Commands are a single letter. If followed immediately by a number (no space or tab) and terminated with a carriage return, the setting is changed to the specified value. If the letter is followed immediately by a carriage return, the current setting is shown. Any changed setting is written to EEPROM and restored on the next power cycle.





The image above shows the signal at U2-5 during RTTY reception. The selector magnet flyback voltage on a mark to space transition causes a high voltage across the Teletype turning on the LED in U2, causing the phototransistor to conduct and pull its output low. Note that the line is low for about 2 ms, much shorter than a 22 ms bit time, and much shorter than the 11 ms threshold the Transmitter Sequencer uses to sense Keyboard Operated Send.





The image above U2-5 on the transmission of a character by the keyboard. Note that U2-5 is low for about 24 ms (a bit longer than the 22 ms bit time) as the keyboard is open for the start bit. This is longer than the 11 ms threshold for Keyboard Operated Send, so the Transmitter Seqiemcer goes into transmit (brings up the amplifier, waits 100 ms, then brings up the transceiver and puts the terminal unit in transmit). The space to mark transition causes a sudden current change in the selector magnet again causing a flyback voltage. This is the seconds 1 ms low pulse. Each time a space bit is generated by the keyboard (keyboard open circuit), U2-5 again goes low for the bit time, resetting the Keyboard Operated Send dropout timer (front panel adjustable from 0 to 10 seconds).





The Dentron Clipperton-L was in standby and driven with low power RF. The amplifier was then taken out of standby. In the image above, the yellow trace going low is the signal telling the Dentron to go out of standby (RF bypass). The blue trace is the output of an RF detector on the output of the Dentron amplifier. At the beginning of the left end of the blue trace shows the output with the amplifier bypassed. About 10 ms after the amplifier is told to go out of bypass, the bypass relay in the amplifier starts switching leaving no RF output. About 12 ms after the amplifier was told to go out of bypass, the amplifier comes online with some contact bounce for the next millisecond. The amplifier is fully online about 13 ms after the amplifier was told to go online.





The image above shows the amplifier returning to standby (bypass). Once again, the yellow trace is the signal driving the bypass relay in the amplifier. About 10 ms after the bypass signal is sent, the relay opens, and no RF is passed. Another 4 ms later, the amplifier is in bypass with some contact bounce for the next millisecond. The amplifier is fully in bypass about 15 ms after the control line is released.





The image above shows the key or PTT line driving the SEA245 transceiver (yellow trace), and the RF output level (blue trace). RF ramps up about about 30 ms after PTT goes low. The amplifier has switched well before this time (about 13 ms after PTT goes true). This is an initial receive to transmit transition in CW mode. This 30 ms includes the transceiver receive to mode switch including the switching of its T/R relay.





The above image shows RF appearing about 4 ms after the PTT line goes low. The SEA245 was already in transmit mode (CW with a previous dit before the CW timeout).





The image above shows the SEA245 with the PTT line going false. Once again, the yellow trace is the PTT line, and the blue trace is the detected RF level. Some RF gets into both traces. RF is gone by about 11 ms after PTT is released. Note that the Dentron bypass relay goes open circuit about 10 ms after PTT is released.