The blog of a dedicated radio amateur and electronics enthusiast

"Having fun on the air and in the workshop - communicating and creating"

17 February 2019

Adding a RS485 interface to an embedded control project

A serial connection to a pc can be used to send/receive data to/from a micro-controller unit ( MCU ) based project. Instead of using usb I have programmed a MCU's serial (E)USART ( (Enhanced) Universal Synchronous Asynchronous Receiver Transmitter ) peripheral and written my own pc software in the past for this purpose.
The USART has receive (RX), transmit (TX) and ground (GND) connections like the RS232 type serial COM ports on older pc's. For higher speeds or longer distances, however, RS485 is a better choice. [ note: RS = Recommended Standard ]. The MCUs and development boards which I use don't have RS485 interfaces. So I made one to test its capabilities. I used a 32MHz MCU clock. Therefore the maximum data rate possible ought to be 4Mbits/s ( 4Mbaud ).
As RS485 is a physical and electrical specification for the bus ( not a protocol ), the protocol used by the USART for RS485 can be the same "start-stop signalling"; i.e., one start bit ( always 0 ), 8 bits ( data byte ), one stop bit (always 1).
TX output from MCU USART. L-R: idle 1, start bit 0, 8 data bits, stop bit 1, idle 1
The image above shows, reading left-right, binary data bits 11001001, with the least significant bit ( LSB ) actually sent first from the left. Reversing the order to put the LSB in the normal position on the far right when writing the value down gives binary 10010011, which is also decimal 147. What really interested me was when I measured the duration of a data bit with the vertical cursor lines; 250nS, equivalent to a data rate of 4Mbaud.
MCU board with RS485 interface fitted - inset view from above
I made a RS485 interface on a daughter board which plugs into a MCU development board. As this uses 3.3V logic levels, ( 0 = 0V, 1 = 3.3V ), I chose the MAX3485ESA chip for the RS485 line transceiver. This chip has one receiver and one line driver; so works in half-duplex mode. Unlike RS232, the RS485 physical link is a twisted pair of wires. I already had 4.5 metres of this. The data signal I used was the voltage on the slider of a pot ( blue knob ), sampled by the MCU 10bit analogue-to-digital converter peripheral and sent to the USART. So. for example, the value 147 would equate to 474mV.
Terminal RX window showing data received from MCU at 2Mbit/s
This setup worked perfectly up to 2MBaud, as shown above, using my favourite terminal emulation software. Unfortunately the same virtual COM port could not be opened when I tried 4MBd ! In future experiments I will see if this limitation was due to the USB-RS485 converter ( not shown ) which I used to connect to a pc at the other end of the link.   
            

04 February 2018

Software Defined Radio - RTL SDR


RTL.SDR hardware - connections for usb and antennas
SDR# software - tuned to VHF FM broadcast station on 105.6MHz

For several years usb 'dongles' for DVB-T reception have been available. The dongle consists of a tuner and down-converter. The frequency coverage of the tuner depends on the dongle variant, and typically from VHF to SHF. A common chip set is R820T tuner, RTL2832 down-converter and ADC ( analogue to digital converter, 8bit ). In-phase and Quadrature ( I - Q ) digital samples of the signal are sent at speeds up to 3.2MSamples/S over a USB2 connection for digital signal processing by a computer running appropriate software.
Using  a similar architecture, although a little different from the dongles in size and appearance, is the RTL SDR ( Software Defined Radio ), sometimes called RTL Downconverter. I recently bought one of this type online for GBP27 (  + free shipping + 10 week wait ) which has the new R820T2 tuner. This particularly interested me as the tuning range is continuous ( no gaps ) from 100KHz to 1.7GHz, ( LF-SHF ); so includes the amateur LF ( 136KHz ) and MF ( 475KHz ) bands. I plan to use the RTL SDR as a spectrum analyser to check some of the equipment I've built for these bands. I downloaded SDRSharp ( SDR# ) software, selected source RTL-SDR ( USB ), connected the supplied antenna and casually tuned and listened. The dynamic range seems to be about 60-65dB; not an impressive figure but should be enough for my purposes.
Further information is available from RTL-SDR.com and I downloaded SDR# from www.sdrsharp.com
There are also many video tutorials at www.youtube.com , e.g., Getting started with SDR# and an RTL SDR tuner - YouTube
An alternative software package which I haven't tried yet is 'SDR Console'.

27 January 2018

Class C transmit amplifier for the 630m MF band

I continue to try different amplifiers in order to improve my station for weak signal digital modes, such as JT9 and WSPR, on the 475KHz, 630m band.
unboxed prototype amplifier with space left for antenna relay
The amplifier posted here is a medium power, and physically small, two IRF640N mosfet class C design. I designed the amplifier so that the 13degC/W heatsinks would provide adequate cooling for up to 50 watts output power when run from a 54Vdc power supply, while still retaining the compact size. With 2.5W drive power at the input, I measured 33W output power, ( gain 11.2dB ).  This was deliberate because at that power level, the optimum mosfet drain load is almost 50 Ohm; so I avoided the need for any output matching circuit. It will be interesting to see what I can achieve on digital modes now.
antenna change-over circuit added (lower-right)
Using it for the first time yesterday evening, my WSPR beacon transmission was received at a record distance 1655kms in France, and I was rewarded with a JT9 digital mode contact with Scotland at a similar distance.
 finished amplifier in home-made enclosure
 
3 February 2023
I received a request from a radio amateur in the USA ( Jeff, callsign WB8RJY ) for the circuit diagram, as he wanted to construct the amplifier. A few days later Jeff sent me several pictures of his completed amplifier, and a summary of his WSPR activity using the amplifier detailing some very long distance reception reports.
amplifier built by WB8RJY based on my design


 
 
 
 
 
 

04 January 2018

Test jig for DDS module and Dongle

AD9850 DDS module on breakout board with interface dongle
CH1 sine wave output, CH2 comparator output +DUT 25%
This post is about using those cheap DDS, ( Direct Digital Synthesizer ), modules based on the AD9850 or AD9851 DDS chips, and found on auction sites for only a few dollars. I have been programming and using them for several years, going back as far as August 2013 ( see post 27/08/2013 ). I am now using the interface dongle, ( USB-SPI v1.00 ), and software from www.spectecs.com which makes the modules extremely quick and easy to use; the tuning word is created and uploaded to the DDS over USB with just a few mouse clicks.
The modules are ideal as a signal source for testing amplifiers etc or embedded in projects which is what I have done recently with the phasing exciter ( 02/11/2017 ) using an AD9851 DDS module on that occasion.
I made a simple jig, ( break-out board ), for speed and convenience when connecting the module for use as a stand-alone signal source. The SPI and output connectors are extended out to pin-strip headers. I also provided LEDs for testing the two GPOs from the dongle.
The module has two sine wave outputs, ( OUT1 & OUT2 ), two square wave outputs ( VO_P & VO_N ). Sine output OUT2 is present on the disconnected black jumper. Referring to the top picture, I've set the jumpers as follows:
J1 green, connected = serial data upload, ( disconnected = parallel data upload ).
J2 blue, connected = enable square wave output, ( disconnected = no square wave output ).
J3 yellow, connected = digital to analogue converter ( DAC ) full scale current set internally, ( disconnected = DAC current set externally ).
I uploaded a tuning word ( hex 010624DD ) for the DDS to generate an output signal at 500KHz. The duty cycle of the square wave is adjusted using the trim-pot next to J2. I found the range of adjustment to be about 12%-87%. The lower picture shows the signal on OUT1 ( 1V peak to peak ), and VO_P ( 5V peak to peak ), which I adjusted for 25% duty cycle.
Although the top picture features the AD9850 DDS module, the AD9851 module is identical in appearance apart from the chip type of course.  

19 December 2017

10 watt amplifier for MF phasing exciter


Internal view, cover off - amplifier built inside old pc psu box

Bias circuit bottom left, antenna changeover circuit top right
In my last post, ( 2nd November ), I described the phasing exciter I made especially for data mode communications on the 630m 475KHz MF band. I have been using it for beacon transmissions and 2-way contacts. I tweeted news of one such contact using JT9 mode. All this has been achieved with an output power of just 100mW. For consistent results, however, particularly when propagation conditions are not favourable, ( e.g., long periods of fading ), more power would be beneficial. So I have built a single-ended class AB rf amplifier rated for 10W max output which is connected externally between the phasing exciter, low pass filter and antenna.
Once again I have used a metal box from an old pc power supply, complete with cooling fan, for the enclosure. A type 2SC3039 power transistor is fitted to a 5K/W heatsink directly in front of the fan. I have included a variable bias circuit, based on a 2SC2958 transistor; actually it's the same transistor type as the driver in the exciter as I had spares. I have used this to set the current for my chosen no signal operating point for the 2SC3039 for class AB operation.
The amplifier has made a huge improvement to the reception range of my WSPR signal; so far up to 1632kms.

02 November 2017

Phasing exciter for the MF 630m band

DDS interface dongle left, antenna c/o top, main board below
antenna change-over circuit removed to reveal main circuit board
So that I can join in the fun of using weak signal data modes such as JT9, JT65, FT8 and WSPR on the 475KHz 630m band I have built a phasing exciter for a low power single-sideband transmitter. Audio input signal is generated by pc data mode software and sound card. The rf signal source is a cheap AD9851 DDS module bought at an online auction site. Its frequency of operation is changed using the usb dongle and interface software obtained from www.spectecs.com. The rf phase shifter is a dual J-K flip-flop chip, af phase shifter comprises two quad opamps, and the mixer is a dual 1to4 mux/demux fet bus switch.
To give the project a smart appearance I chose a Hammond type 1455N1201BK box for it. Even before the prototype was finished, I couldn't resist the temptation of connecting it to my inverted 'L' antenna and trying it out. The exciter on its own produces only 1mW ( 1 milli watt, 0dBm ); but this was sufficient for my WSPR beacon signal on 474.2KHz to be received with SNR -23dB at a distance of 11kms by a monitoring station.
The prototype was completed with the addition of a class A rf driver amplifier to increase the output power to 100mW, and an automatic rf sensed antenna change-over switching circuit. Since then my signal has been received in Norway, distance 1071kms, Estonia, distance 816kms and Germany, distance 700kms, which surprised me as the antenna's directionality favours the east. Sadly there don't seem to be any foreign receiving stations in the east at the moment.

28 September 2017

An UN-UN transformer for my end-fed wire antenna

Prior to installation; coax cable ( left ), insulated wire ( right )

Construction detail - eye bolt is for installation purposes

Raised into position above house roof ridge

Method of installation and connection
For many years, my general purpose antenna for short wave has been a horizontal 46m long end-fed wire; see post dated 12 August 2011. However it had always been difficult to match it's feed-point impedance to my transceiver's 50 Ohm antenna connector on some bands using my station antenna tuning unit, ( ATU ); the impedance being too high. For those particular bands I would sometimes temporarily change the length of the wire; but that wasn't very convenient. So instead I have now made an UNbalanced to UNbalanced ( UN-UN ) impedance step-down transformer, placed it in a small plastic food storage box, connected it to the feed-point of the antenna and to the ATU with coax cable.
The transformer windings consist of 9 turns, trifilar wound, on a T200-2 iron powder toroid core, using insulated wire. The core is held in place with a nylon bolt and a small piece of acrylic. The slots shown in the picture are not required; it had been used for something else. The coax cable is secured inside the box with a 'P' clip. The windings were interconnected to produce a turns ratio secondary:primary of 3:1; hence impedance ratio 9:1. This had the desired effect of transforming the impedance to lower values within the tuning range of the ATU on all bands.
With this modification I converted my simple end-fed wire antenna from a multi-band antenna to an all-band antenna !

21 September 2017

New mosfets for the dual band amplifier

Four IRFP360 mosfets mounted on heatsinks inside the dual band amplifier
In March I bought new mosfets for the dual band amplifier ( see post 6 December 2015), but only recently had the time to fit them. I always knew that the original IRF640 types were underrated when I started running the amplifier from a 54V power supply, and there were reliability issues with several of them failing with a loud bang. The new type I've now fitted is the IRFP360 which is a 400V mosfet. During the last couple of evenings I've been transmitting with the amplifier for long periods without any further mishaps occurring. I had to fit these mosfets with a different orientation from the IRF640 ( see previous amplifier images ) as the mounting hole is insulated ( no insulating collar required for the bolt ) and the drain connection was made to the centre pin, not the case. A mica insulator, however, was still necessary under each mosfet between it and the heatsink. The insulator required is slightly larger than the standard TO-220 size. To begin with I didn't have any suitable until I found that Farnell stock them, ( item code 520-214 ). The mosfet and data sheet can also be found at Farnell, ( item code 864-9359 ). 

31 May 2016

Vacuum pen for pick 'n place

vacuum pen apparatus
pen and an assortment of nozzles
As I get older my hand is becoming too unsteady for using tweezers to pick and place certain types of surface mount components onto a pcb ready for reflow-soldering. I wanted to see if a vacuum pen would help.
I converted a really cheap aquarium compressor pump to work as a vacuum pump, by reversing the valve action. The 'pen' is a 5ml syringe; plunger not required. The 4mm bore tube for the air-line was passed through two rubber grommets and forced into the syringe. Hot-melt glue was applied inside the barrel of the syringe at the entry point of the tube to form another seal and reduce pipe movement. A small hole drilled into the syringe near the nozzle end makes a simple finger operated vacuum switch.
T-piece vacuum switch
For even better precision and control I subsequently fitted a T-piece for the vacuum switch, close to the pump, to be operated by my other hand. And I made another pen; of course with no hole. 

04 May 2016

Half-wave filter for the MF amplifier

Two T200-26 iron powder toroids are used
It's called a half-wave filter because it functions like a half-wavelength of transmission line, ( e.g., coax cable ), regarding the terminating impedances at the design frequency of 475.5KHz. Using lumped circuit elements is a much more practical proposition than 200m of cable. It also has a low-pass frequency response; theoretically 2nd harmonic 951KHz -27dB, and 3rd harmonic 1426.5KHz -47.8dB. This is a useful amount of extra attenuation. So I built it for use with my MF amplifier, ( posted 6 December 2015 ), to provide additional suppression of harmonics in the transmitted signal. It is connected externally in-line with the amplifier output.  

09 January 2016

Schmidt trigger input for the dual band amplifier

50% +DUT drive signal on the gate of one of the four MOSFETs
Schmidt trigger circuit installed
I have improved the amplifier efficiency by increasing the duty cycle ( +DUT ) of the drive signal on the MOSFETs' gates from 43% to 50% with the addition of a Schmidt trigger first stage. After experimenting with several CMOS NAND and inverter logic chips, ( i.e., CD4093BE, CD74HCT132E, SN74HC14N, SN74HCT14N ), which already have Schmidt trigger inputs, I found I could only obtain the 50% +DUT I wanted by making my own Schmidt trigger circuit using a quad 2-input NOR gate chip ( CD4001BCN or HEF4001BP ). I eventually decided to retain the older CD4001BCN in the circuit as the low pulse rate doesn't really justify using the newer HEF4001BP for this application. I built the circuit on a tiny piece of pad board and fitted it above the main driver circuit board. ( See also post dated 6 December 2015 ).

06 December 2015

Dual band transmitter power amplifier for the LF ( 2190m ) and MF ( 630m ) bands

home made enclosure 25 x 24.5 x 12cm


band module for the 2190m band is shown installed
I've recently finished building another amplifier for my transmitting setup for the 2190m/136KHz and 630m/475KHz bands. It is a switching amplifier design based on Class 'E' topology, using four IRF640N  MOSFETs in parallel. To allow operation on both bands I constructed the output tuning and matching circuit for each band as a removable module; changing the frequency band of operation just requires installing the appropriate module. I have also fitted a RF voltage sensed automatic antenna changeover circuit.
In use the amplifier runs only slightly warm. Each MOSFET is mounted on a separate 4.4degC/W heat-sink, two cooling fans are running and there is ample ventilation. So my work on the thermal aspects of the design was worth the effort. By using 4 MOSFETs in parallel there is very little heat to be dissipated anyway as their combined 'on-resistance' is extremely low. Amplifier efficiency is about 83%.
I was very pleased to get a reception report of my signal on the 630m band from Bantry, south-west Ireland, ( distance 2085 kms ), as well as reports from Greece and Spain.
My future plans are to paint the front panel of the enclosure, and make a hinged top cover.
I can provide the circuit diagram on request by email.

15 February 2015

Improvements to the 475KHz amplifier

Note the new, larger heat-sink and its position

Automatic antenna changeover circuit
I've made a couple of changes to the amplifier since I first reported on this project on 22 September 2014.
The mosfet has now been fitted to a larger ( 4.5degC/W ) heat-sink for better cooling, and repositioned to make device replacement much quicker and easier than before, should it again be necessary !
I've also added a circuit for 'rf voltage sensed' automatic antenna changeover switching which is a much more convenient arrangement than a manually operated  coax switch which I was using.

By the way, my 'countries worked' total on the 475KHz / 630m band has now risen to 14.

22 September 2014

A compact transmitter power amplifier for 475KHz

Internal view: Right - input circuit, Left - output circuit and fan
Ex-pc power supply cases are ideal for small projects
With the previous amplifier, ( see 14 February ), I contacted a couple of countries on the 475KHz/630m band. I have now replaced that amplifier with a more efficient Class 'E' design. It uses a type IRF640N mosfet and 13.8Vdc supply to produce an output power of 50 watts with an efficiency of about 81%.
I built the amplifier in an old pc power supply case, measuring just 165 x 90 x 85mm, retaining only the original fan.
During the evenings I have been transmitting a beacon signal on 478.5KHz using my DDS frequency synthesiser as the drive signal source, and been getting reception reports from across Europe. So far Essex in England at 1380Kms is the farthest that reception of my signal has been confirmed. If the amplifier remains healthy during these tests I shall attempt to increase the output power to about 140 watts, and start making some more two-way contacts with other radio amateurs on the band.

19.10.2014. Till now my 50 watt beacon transmission has been received the farthest in NW England at 1602kms, and my 'countries-worked' total has risen to 4; Poland, Germany, Finland and France. So as planned, I have increased the output power of the amplifier to 140 watts by connecting it to a 24Vdc supply. The efficiency has improved to 86%.

01 July 2014

ARM - Advanced Reduced instruction set Microcontroller

Having used 8bit devices, ( PIC16f/18f, Atmega328 ), for several years, I shall be taking my future projects with embedded control to the next level with ARM Cortex-M3 core architecture 32bit processors. I have bought two ARM development boards, each having the 20 pin JTAG interface but a different processor from the STM32 family. Being so cheap these boards are ideal for the electronics hobbyist wanting to develop some really amazing hi-tech applications. I have downloaded two IDE's, ( Integrated Development Environment ), to try; emIDE and Keil uVision4. I also have the Segger J-Link, JTAG compatible, programmer and debugger, ( not shown in the pic below ).
That completes my preparations. Now I just have to think of a project to work on during the long winter evenings to come.
l
STM32F207VCT6 (l) and STM32F103RBT6 (r) ARM development boards

18 March 2014

Reflow soldering - Part (6) First circuit board soldered

"Done... Switch off and open door"
The first circuit board has had the surface-mount components soldered onto it using my new reflow-soldering system. On close inspection afterwards, there was no sign of any heat damage and no repairs or rework were necessary. The tiny parts all seemed to be perfectly soldered.  I later soldered the through-hole-terminated connectors and switches with a soldering iron.
As soon as the board was back to room temperature, I powered it up and successfully programmed the PIC microcontroller. Some initial electrical tests were also positive.
Earlier I had spent some time practicing picking up, holding steadily and placing the parts in a controlled manner onto the circuit board. After the solder paste has been applied there is limited time. A mistake would probably smear the paste, requiring cleaning and start-over. I found tweezers, curved at the ends, to be the best. In the interests of speed, I first took all the components I would be needing from my stock, and separated them by type in a compartmented tray. I decided to place the 44 pin PIC on the board first as a mistake was most likely to occur with the placement of that component.    

08 March 2014

Reflow soldering - Part (5) Using the stencil

Preparing to apply the solder paste
I now have the stencils through which solder paste is applied to the printed circuit board ( PCB ). The material is 0.1mm thick stainless steel. Manufactured using a laser cutting process, the minimum cut-out dimension and spacing is also 0.1mm. However the steel was far more suitable for laser cutting than the transparencies, mylar and plastic materials which were also evaluated.
The PCB is held securely between spare PCBs, or off-cuts of other material having exactly the same thickness as the circuit board; checked with vernier calipers. The stencil is then aligned on top so that the solder pads, ( where the SMT parts will be placed ), are visible, and then one edge is taped down to form a hinge.
I use two spreaders; a small spatula and a plastic card. The spatula is for getting the solder paste out of the pot and, after transferring the paste, the card is used to spread the paste over the stencil. As the paste is not cheap, any excess is returned to the pot.


14 February 2014

Getting ready for 630 metres

Experimental amplifier for 475KHz using a single 32N12 mosfet
Just a few days ago I read that the 630m / 475KHz band will be released to radio amateurs in Poland from 18 February. Having no transmitter for that band and wanting to radiate a signal from the first moment the band becomes available, I had to make something very quickly. It was a race against time and all I could hope to complete was an amplifier, ( based on a type 32N12PV2 mosfet device ), to boost the output signal of my frequency synthesizer by about 26dB.
For the antenna, I plan to use my existing 46m end-fed wire, ( posted on 12 August 2011 ), and part of the loading coil I already use on the 2190m / 136KHz band; ( posted on 19 February 2010 ).
With this setup I shall be amazed if I can even make contact with local radio amateurs, ( let's say those up to 10Kms away ), assuming there will be any of them also equipped and active on the band at the start. Still, it's worth a try.

26 January 2014

Logic analyser

Top-bottom: frequency update, data, clock
First data byte magnified - 8 clock pulses send 00000011
Arduino 'Uno' board and logic analyser connected
I have a new toy to play with; the Saleae 24MHz 8 channel logic analyser. Looking for some signals to analyse with it, I programmed my Arduino board's SPI ( serial peripheral interface ) pins, incorporating the appropriate library code, to send frequency update pulses, 4MHz clock and 6 bytes of data to an AD9850 DDS chip. I was unsure how the SPI modes had been implemented in the library code. With the logic analyser connected I was quickly able to determine where my own code required modification so that the desired signals were obtained.
I needed 3 of the 8 available channels of the logic analyser. Previously I would have had to use my dual channel oscilloscope, viewing only 2 signals at once.

29 December 2013

Reflow soldering - Part (4) First soldering test

Plot of actual temperature change
The board I used for the test, SMD 1206 resistor centre
I have been experimenting with the oven under the control of my programmable temperature controller, ( see 12 December ), and making minor changes to the software until I obtained the heating and cooling characteristic above. It closely resembles the ideal profile, ( see 8 October ).
Eager to try some soldering, I put several blobs of solder-paste and a surface-mount resistor on a scrap piece of copper clad circuit board material, placed it in the oven and started the process. After completion I inspected the board. The solder-paste had become metallic, the resistor was nicely soldered and the copper hadn't 'lifted'.
Without any stencil, I had applied far too much solder-paste.