The blog of a dedicated radio amateur and electronics enthusiast

"Having fun on the air and in the workshop - communicating and creating"
Showing posts with label SPI. Show all posts
Showing posts with label SPI. Show all posts

31 December 2024

Programming AD9850 & AD9851 DDS

๐Ÿ”˜I previously posted about using the AD9850 & AD9851 DDS chip evaluation modules in 2018 and again in 2023. To recap, before these devices can be used as a signal source they require programming with 5 bytes of data related to frequency and phase, which form a 'tuning word'.
A ยต-controller and a smart phone๐Ÿ– App could be used to upload ๐Ÿ  the tuning word ( see 16 July 2023 ), or a USB dongle and pc๐Ÿ’ป interface software, ( see 4 January 2018 ).  As I have recently updated that software it would now be a good time to give a description.

My dedicated pc ๐Ÿ’ป software, called "DdsModTerm", is the user interface which I started developing in about 2015. Since then I have updated it 15 times; the latest revision appearing this month.

DdsModTerm user window
The clock ๐Ÿ•ฐ frequency and the required output frequency ∿ & phase are entered either manually or by recall from memory. By clicking 'Confirm' the software generates the 5 configuration bytes required from the user input data. In the example in the image above the output frequency is 137700Hz* & bytes hex 00C88AC604. The pc ๐Ÿ’ป is connected to the serial data interface of the DDS module via a COM port and a USB-SPI protocol converter dongle.
(L) USB-SPI dongle (R) AD9851 DDS module on adaptor
Clicking 'Update DDS' then uploads the bytes to the registers of the DDS chip using SPI and a voltage having an amplitude 1V peak to peak at the programmed frequency ∿ is then present on the output.
DDS output signal, 1Vp-p, 137.7KHz
Other features of the software include up/down step ๐Ÿชœtuning, slider tuning control, view of 255 byte eeprom addresses E0-FF, 3 memories for storing frequency, saving custom clock๐Ÿ•“, alias frequencies calculated, and general purpose output ( GPO ) toggling on/off.
The dongle and software are available from me. Post a comment to receive more information. Note that both AD9850 & AD9851 DDS devices are supported.๐Ÿ”˜
( Click on images to enlarge detail. )
* 137.7KHz is a calling frequency on the radio amateur 2190m long-wave band, 135.7-137.8KHz.
SPI = Serial Peripheral Interface, 3-wire bus.
AD9850, AD9851 : ๐Ÿ”—Analog Devices Inc. parts, 32-bit CMOS Direct Digital Synthesiser (DDS) chips.

16 July 2023

Mobile App User Interface for a DDS Module ๐Ÿ“ถ

I previously featured a DDS module based on the Analog Devices AD9850 32bit device on 4.1.2018. The method I used then to generate an output frequency from the DDS board involved an SPI-USB protocol converter dongle with pc terminal software.
Another method I recently devised uses a micro-controller and my custom "DDSTerm" App installed on a mobile phone๐Ÿ“ฑ. As before SPI protocol is still needed to upload the tuning word, phase and power control bytes to the DDS configuration register and this operation is now performed by the micro-controller. But instead of software running on a pc, the App is now used to generate the bytes required, which are then sent using BluetoothⓇ Low Energy ( BLE ) to the micro-controller. An ESP32 micro-controller has SPI peripherals and built-in BluetoothⓇ, and so was used.
App 'DDSTerm_v1.06' opened
The micro-controller functions as a BLE server 'AD9850_DDS'. The App on the client device scans for this server and connects to it. The desired frequency, phase and power mode are entered. Clicking "Generate" produces the required 5 bytes ( hex 004831C8C4 in the image example ), and clicking "Send to DDS" sends the bytes using BluetoothⓇ to the ESP32, which then uploads them to the DDS board on the SPI.  An output is generated on the selected frequency, e.g., 137.7KHz. Clicking 'PWR DWN' puts the DDS in 'sleep' mode. The two yellow LEDS ( see image below ) are toggled on/off with GPO1 & GPO2. The last uploaded frequency is saved and automatically recalled whenever the App connects.
The hardware setup during development & testing
The hardware ( image above ) consists of an AD9850 DDS module board bought very cheaply on-line and mounted on my test jig from 4.1.2018. Inside the 3D-printed blue and yellow enclosure is the ESP32 micro-controller development board which is a typical one having the ESP32-WROOM-32 processor. Both the DDS and ESP32 are 3.3v supply and logical level compatible. No level shifting is therefore required when interconnecting.
I also use DDS modules fitted with the AD9851 chip; see 2.11.2017. The only changes to the App, ( other than selecting the correct device ), would be a 'x6 Reference Clock Multiplier' checkbox, and extending the frequency range of the 'slider control'; both optional.

DDS = Direct Digital Synthesis.
GPO = General Purpose Output
SPI = Serial Peripheral Interface ( 3-wire bus ). 
 

06 January 2023

Touch Screen Displays

Nowadays it seems almost obligatory that electronic gadgets have a touch screen display user-interface.
The particular display type I have been trying out recently is a 2.8" 240x320 pixel TFT LCD touch panel display with SPI and using the ILI9341 driver chip. On the back is an SD card slot. Cost when purchased was just under GBP11.
The display and an ESP32 micro-controller development board, ( with my code uploaded to it ), were mounted on a prototyping board and connected up. The ESP32 micro-controller has two built-in sensors; a temperature sensor which measures the CPU temperature, and a Hall-Effect sensor which responds to magnetic fields. Either cpu temperature or magnetic field data can be displayed separately in real-time by tapping on a displayed 'button', which is then highlighted in green.
The CPU temperature measurement has been selected
Although both measurement values could easily have been displayed together, I now have my ready made code to import into future projects which really would benefit from a touch screen.
( SPI = Serial Peripheral Interface, 4-wire bus )

10 June 2020

Nokia 5110 Liquid Crystal Display

I recently discovered surplus Nokia 5110 Liquid Crystal Displays ( LCD ) which were used in Nokia 5110 phones, circa 1998. Thousands of these interesting display modules are available at on-line auction sites. I bought four, about GBP2.30 each; two having a blue back-light and two with white. The resolution is 84 x 48 pixels; overall dimensions 4.5 x 4.5cms. The controller/driver chip is PCD8544. I searched for and downloaded the data sheet; essential reading !
Nokia 5110 LCD types: back-light colour (L) blue (R) white
Communicating with the display uses the SPI ( Serial Peripheral Interface ) bus specification, which is a synchronous MASTER/SLAVE configuration with the MASTER generating the clock. As well as supply and ground, the following 5 connections to the display are needed; Chip Enable ( CE ), Serial Clock ( CLK ), & Serial Data ( DIN ), and additionally, for control purposes, Data/Command ( DC ), and Reset ( RST ). Back-light ( BL ) connection is optional.
6 config bytes being sent to display on SPI: top CE, mid CLK, bottom DIN
Basically, using the display requires (i) configuring display settings, and (ii) knowing how the addressing of the DDRAM works when writing data for displaying. To try out the display I connected it to the PIC microcontroller ( MSSP module ) on my prototyping board, and ran some code to measure and display temperature and voltage. The bus speed I chose was 1MBit/s.
The display lacks a built-in font. But that was quickly remedied by finding a ASCII character set 5x7pixel font file online, and including it as a header file in my C-code.
Nokia 5110 LCD with white back-light in use
I was disappointed with the blue back-lit display being hard to read, despite spending a lot of time experimenting with contrast, bias and temperature coefficient settings. The white back-light variant is much better in this respect.
I found the display very easy to use; now ready for a suitable future project.
( Click on images to zoom ).
MSSP = Master Synchronous Serial Port, DDRAM = Display Data RAM

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.  

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.