Meteor M-N2 Images

Tuesday 17 January 2017

VLF/LF Receiver implemented in microprocessor - Rotary encoder control and LCD (Part 4 of n)

The rotary encoder control works by switching between screen buttons on each push of the encoder button. The button that is activated is highlighted in blue when active, non-buttons that have actions are highlighted in red. Turning the encoder clockwise or anti-clockwise will change the option and activate it immediately. When the station name is red you can tune manually (the station name will change to 'User' after the frequency has been changed).

Having reviewed my code it is difficult to describe in detail exactly which changes need to be made to add rotary encoder control. However, as far as I am aware I have put a comment including the word 'rotary' in every place where I have added code for this reason. 

If you want to backport the rotary encoder code to the STM32F4 board I suggest you search all the code for the word 'rotary' - grep -r rotary * - and take it from there.

There are three main additions of code to support the rotary encoder. There is a:

  • new routine in SDR_initPeriphs.c called  initEncoder()
  • new routine in main.c called ManageEncoder()
  • new routine in stm32f7xx_hal_msp.c called HAL_TIM_Encoder_MspInit()
  • an additional section in the HAL_GPIO_EXTI_Callback routine in stm32f7xx_it.c
  • Elsewhere various variables are defined in main.h and Globals.h.

Adding the external LCD involved a lot of digging around in low level LCD controller code. It must have affected my brain because now I cannot see what I changed to make it work. There's some pin definitions for the LCD in main.h, maybe that's all it needs but I am sure the STemWin GUI controller is defined somewhere. If you want to look into this area then the file LCD_X_8080_8.h would be a good place to start. 

A video of the rotary encoder/LCD combination will be posted here shortly.

The code is available on github link

Monday 16 January 2017

VLF/LF Receiver implemented in microprocessor - Hardware Configuration (Part 3 of n)

This post assumes that the RF pre-amp and audio out circuits have been built as described by I2PHD in his original paper found under the ARM Radio section of his website.

Microprocessor - STM32F746-Nucleo board.
LCD - ILI9341 driver, looks the same as this one 
Rotary encoder with integrated push switch

My code uses the following pin connections:

Component Pin  STM32F746 Pin
LCD_D0                 PC0
LCD_D1                 PC1
LCD_D2                 PC2
LCD_D3                 PC3
LCD_D4                 PC4
LCD_D5                 PC5
LCD_D6                 PC6
LCD_D7                 PC7
LCD_RST              PE2
LCD_CS                PE3
LCD_RS                PE4
LCD_WR               PE5
LCD_RD                PE6

Rotary encoder clockwise         PB4
Rotary encoder anti-clockwise  PB5
Rotary encoder centre              GND
Rotary encoder push button     PA0

RF In         PA3
Audio Out  PA4

In the next post I will describe the code I have added to support the rotary encoder functionality as well as the changes to the screen layout.

The cide is available on github link

Sunday 15 January 2017

VLF/LF Receiver implemented in microprocessor - Introduction (Part 1 of n)

Alberto, I2PHD, developed a VLF to MF receiver entirely in a microprocessor utilising the STM32F4 Discovery board. I was intrigued by this so I purchased a STM32F746 Discovery board. The F7 board uses the faster ARM Cortex M7 processor rather than the M4 processor used in the STM32F4 range of boards.

However, I soon found that the STM32F7 Disco board does not make the same GPIO pins available to use. Specifically only the third analogue-digital converter (ADC3) of three is available to use. Alberto's design uses ADC's 1 & 2 in double buffered mode and this approach is fundamental, consequently I realised that I would not be able to use this board for the receiver. By the time I had worked this out ST had released the STM32F746-Nucleo board, this board is similar to the Discovery board except it makes all the GPIO pins available to use but it does not have a built in LCD display.

I was not able to compile the source code written for the F4 board for the F7 board. Whether this was through my lack of experience or for some other reason I do not know as the code is meant to be compatible between the two devices. Subsequently, I proceeded to rewrite the code to use the Hardware Abstraction Layer (HAL) provided by ST. Due to the fragmented and incomplete nature of documentation for the HAL a great deal of experimentation and trial & error was involved. However, this did mean that my understanding of C programming for embedded microprocessors and associated debugging using gdb increased quickly.

Currently the status of this project is as follows:
  • Code for STM32F4 ported to work with the STM32F7 devices using HAL firmware library version 1.3.0*
  • To overcome the lack of an LCD on the Nucleo board an inexpensive LCD was purchased on ebay which uses the ILI9341 LCD controller and this was integrated into the code.
  • To overcome zero documentation on how to use the touch screen capabilities of the LCD I bought I implemented control using a rotary encoder.
  • I have added a spectogram function which shows a display of the signals being received - this is a work in progress.
* I have looked at using the newer 1.5.1 HAL firmware but there have been significant changes made to the operation of some of the functions and I don't intend to rewrite the code to handle these at the moment.

The picture at the top of this post shows the receiver receiving the MSF time signal on 60kHz.

I plan a series of blog posts to document this project. My plan is for posts covering the following topics:
  • Setting up the development environment - using Eclipse IDE, GCC compiler, OpenSTM32, gdb.
  • My implementation and the hardware connections, particularly covering the LCD and rotary encoder.
  • Specifics around the rotary encoder control and the LCD.
  • The spectogram function.
  • Wrap-up, including some problems I have yet to overcome.
The code is available on github link