Ad9833 arduino 1602

Signal Generator AD9833

Introduction: Signal Generator AD9833

A signal generator is a very useful piece of test gear. This one uses an AD9833 module and an Arduino Nano — that’s all, not even a PCB. You can optionally add an OLED display. The AD9833 can gererate sine, triangle and square waves from 0.1 Hz to 12.5 MHz — the software in this project is limited to 1Hz to 100kHz.

There have been other Instructables using an Arduino and an AD9833, here and here. This is simpler and can be used as a sweep generator. Sweep generators help test the frequency response of filters, amplifiers and so on. Unlike the other Instructables designs, this does not include an amplifier or amplitude control but you could add them if you wanted.

Step 1: Simplest Signal Generator

For the simplest Signal Generator, you just solder the AD9833 module onto the back of the Arduino Nano. No PCB is needed.

The AD9833 module I chose is similar to this one. I’m not saying that’s the best or cheapest supplier but you should buy one that looks like that photo (or the photo above).

The connections between the modules are:

  • grounds connected together
  • D2 = FSync
  • D3 = Clk
  • D4 = Data
  • D6 = Vcc of AD9833

The AD9833 is powered from data pin D6 of the Arduino — the Arduino can supply sufficient current. I’ve added a 100n decoupling capacitor because I thought I «ought» to but I couldn’t see any difference — there is already a decoupling capacitor on the AD9833 module board.

If you were being fancy, you might worry about «analogue ground» vs «digital ground» but if you were being fancy, you’d be spending more than £4.

The simplest Signal Generator is controlled and powered over a USB lead from a PC. The USB emulates a serial port running at 115200bps (8-bits, no parity). The commands are:

  • ‘0’..’9′: shift digit into «min» frequency array
  • ‘S’: set AD9833 frequency and produce sine wave
  • ‘T’: set frequency and produce triangle wave
  • ‘Q’: set frequency and produce square wave
  • ‘R’: reset the AD9833
  • ‘M’: copy «min» frequency array into «max» array
  • ‘G’: sweep from «min» to «max» over 1 second
  • ‘H’: sweep from «min» to «max» over 5 seconds
  • ‘I’: sweep from «min» to «max» over 20 seconds

The Arduino program contains two 6-character arrays «min» and «max. If you transmit a digit then it is shifted into the «min» array. If you send an ‘S’ then the «min» array characters are converted into a longint frequency and sent to the AD9833. So sending the string

will set the AD9833 output to a 2500Hz sine wave. You must always send all 6 digits. The minimum frequency is 000001 and the maximum frequency is 999999.

If you send an ‘M’ then the «min» array is copied into the «max» array. If you send an ‘H’ then the AD9833 repeatedly outputs a gradually increasing frequency over 5 seconds. It starts at «min» frequency and 5 seconds later is at «max» frequency. So

sweeps from 100Hz to 20kHz. The frequency change is logarithmic so after 1 second the frequency will be 288Hz, after 2 seconds 833Hz then 2402, 6931 and 20000. The frequency is changed every milliSecond.

The loop stops when the Arduino receives another character so be careful not to send the command followed by carriage-return or line-feed. That extra character would terminate the loop. If you’re using the Serial Monitor, there’s a box at the bottom right that might say for instance «Both NL & CR» which (I think) sends characters after your command. Set it to «No line ending».

You can download the Windows EXE program below which will send the required commands or you could write your own. The Arduino INO file is also here.

Attachments

Step 2: Add an OLED

If you add an OLED and two buttons, the signal generator can work alone without a PC.

Those of you who have read my oscilloscope Instructable will recognise the similarity. The AD9833 module can be added to my oscilloscope to produce an «Oscilloscope and Signal Generator in a Matchbox».

The display is a 1.3″ OLED running at 3.3V which is controlled by an SH1106 chip via an I2C bus.

Search eBay for 1.3″ OLED. I don’t want to recommend a particular seller as links quickly go out of date. Choose one that looks like that photo, says «I2C» or «IIC» and has four pins labelled VDD GND SCL SDA. (Some displays seem to have the pins in a different order. Check them. The proper name for the clock of I2C is «SCL» but on eBay the boards can be labelled «SCK» like my one in the photo.)

A fuller description of the OLED library is in my oscilloscope Instructable in Step 8. You should download and install the driver library SimpleSH1106.zip which is in Step 8. (I don’t want to upload another copy here and have to maintain two copies.)

The INO file can be downloaded below. The pin numbers used for the OLED are declared around line 70. If you have built my «Oscilloscope and Signal Generator in a Matchbox» and want to test this INO file with it, alternative pin numbers are enabled via a #define.

I’ve shown a stripboard layout for the circuit. There are two stripboards — one for the Nano and the AD9833 and one for the display. They should form a sandwich. The boards are shown from the component side. Fine flexible wires join the two boards. Attach the boards together with soldered stand-offs. In my diagram, the copper of the stripboard is shown in cyan. Red lines are wire links on the stripboard or flexible wires joining the boards together. I haven’t shown the power and «signal» leads.

The AD9833 module is soldered on the copper side of the stripboard — on the opposite side from the Nano. Solder pins onto the copper strips then fit the AD9833 onto them and solder it on.

The display shows either a single frequency or the «min» and «max» frequencies.

There are two pushbuttons: a «Horizontal» button to select a digit of the frequencies and a «Vertical» button to change that digit.

I power the signal generator from the circuit I’m developing — I always have 5V available at my workstation.

Attachments

Step 3: Using a Two-Line LCD

mausi_mick has redesigned the circuit to use a 2-line LCD and a rotary encoder instead of the OLED and pushbuttons. This Step describes his design. You can see a video of it here.

He has used a LCD1602 with an I2C interface piggyback board (approx £5 total). They are a simple way of connecting a LCD1602 to an Arduino and require only three of the Arduino’s pins.

Alternatively, you could use a plain LCD1602 (£2.50) which requires 6 Arduino pins. Here’s an Instructable.

He uses a rotary encoder which makes setting the menus much quicker. Turning or clicking the encoder triggers a «Pin-Change-Interrupt».

The menu has two new functions:

  • Changing frequency ( Low and High) from 0 . 12 MHz
  • Changing delay (from 100µs,200µs,500µs,1ms. 1s) (sweep-mode).

The signal gererator currently is powered from a USB-supply but he intends to change that to a Li-ion battery with a boost convertor to give 5V (using a MT3608 SMPS). USB supplies have a lot of noise so the battery will improve the quality of the signal. Of course, a boost convertor might also create noise. Personally, I’d use 4 AA cells or two Li cells and no booster.

The sketch can be downloaded below. A KiCAD PCB layout is available of his GitHub page.

Attachments

Step 4: Future Developments

Could it be battery powered? Yes, just add a 9V PP3 connected to the RAW pin of the Nano. It typically uses 20mA.

Could it be powered by a single lithium cell? I don’t see why not. You should connect the OLED Vdd and its pull-up resistor to the 3.7V battery (I doubt if the 3.3V output of the Arduino would work properly).

A sweep generator is more useful when testing the frequency response of a filter if you can graph amplitude vs frequency. Measuring the amplitude of a signal is tricky — you have to trade off the decay of your envelope detector vs ripple for low frequencies and response time for high frequencies. Having built your amplitude detector, you could feed its output into the ADC of the Arduino of the «Simplest Signal Generator» then send the result, along with the current frequency to the PC.

This page is a useful starting point or search Google for «envelope detector» or «peak detector». In the suggested circuit above, you would set the signal frequency, wait for it to stabilise, set the Arduino A0 pin to output digital low, wait to discharge C, set A0 to input, wait, then measure with the ADC. Let me know how you get on.

3 People Made This Project!

Did you make this project? Share it with us!

Recommendations

Fandom Contest

Crayons Challenge

Halloween Contest

52 Comments

Question 4 weeks ago on Introduction

SH1106.h
header file where can i get

Answer 4 weeks ago

«A fuller description of the OLED library is in my oscilloscope
Instructable in Step 8. You should download and install the driver
library SimpleSH1106.zip which is in Step 8. (I don’t want to upload
another copy here and have to maintain two copies.)»

Hi Peter: Nice post! thanks for sharing this work. I have been working on a similar project, but I need to do FSK as well, which means going between FREQ1 and FREQ0—best practice according to AD, there are two freq registers available. This should be be a simple! 0x2800 for control (use Freq1, no reset), then 0x8000 twice for freq 1. however, for 2 of the little blue BOBs, I cannot make Freq1 work no matter what. 2 different BOBs, same. I have slammed away at this for over a day and a half! Freq0 (which you use in your code) works great, exactly as you’d expect. I have tried various libraries on the internet, as well as trying all sorts of code variations I wrote myself in C. Tried Arduino Uno and Pico as dev boards—same thing, Does anyone have advice how to make Freq1 work? How to do FSK short of just loading different F0s over and over? If so, Can you plesae send me a series of uint16_ts I can use? Thanks in advance!

Reply 2 months ago

The AD9833 data sheet makes FSK look easy.

I didn’t try FREQ1. It was 4 years ago and I’ve rather forgotten what I did.

How fast are you wanting to switch between the two frequencies? What if you just altered the value in the FREQ0 register. Does it change fast enough for you? Does changing FREQ0 reset the Phase Accumulator register or does it just carry on counting?

This person seems to have got it working:

With FSK, what you’re wanting is a smooth transition of the output as it switches between the two frequencies. The ‘scope trace they show looks very smooth indeed.

Reply 2 months ago

Thanks for the reply! Turns out FSK is super easy w 9833 if you don/t make stoopid mistakes : ) I was using the wrong SPI mode (bug in my homemade C library, doh!) and apparently some of the registers work OK in SPI mode 0 and some don’t, so yes you need SPI 2 as the datasheet says, for real.

To make FSK go, set F0 and F1 registers, then write FSELECT 1 and 0 bits to control reg to switch between the two F’s. No reset, nolthing else needed as far as I could tell. I was switching at pretty high freq and it looked and worked perfectly no glitches or hiccups. Impressive for a affordable FG breakout board.

Hi Peter, again a very nice project !
Inspired from your project I made some modification:
on the hardware:
— LCD1602 instead of the small OLED.
— rotary encoder with push-button

on the software:
— Pin-Change-Interrupt for the Encoder and the Push-Button
— instead of Serial.Read() I use the push-button an the encoder
for work off the Commands.
— I have expand the menu with two functions:
— Changing frequency ( Low and High) from 0 . 12 MHz
— Changing delay (from 100µs,200µs,500µs,1ms. 1s) (sweep-mode).

Because of the quick response of the input from encoder and push-button it’s easy to change
the input values.

Now the function-generator is very flexible and I hope useful.
.

If You have interest, I can send the code and perhaps a small video video on YouTube.

Источник

Генератор (AD9833) + частотомер (Arduino)

Ранее на сайте рассматривались примеры создания генератора на модуле AD9833 и частотомера, но это были отдельные проекты, на этой странице будет рассмотрен пример создания генератора и частотомера в одном проекте.

AD9833 — генератор сигналов с низким энергопотреблением. Позволяет генерировать сигналы с частотой до 12.5 МГц синусоидальной, треугольной и прямоугольной формы. Управление осуществляется с использованием трехпроводного интерфейса SPI.

Основные характеристики микросхемы:

  • Цифровое программирование частоты и фазы.
  • Потребляемая мощность 12.65 мВт при напряжении 3 В.
  • Диапазон выходных частот от 0 МГц до 12.5 МГц.
  • Разрешение 28 бит (0.1 Гц при частоте опорного сигнала 25 МГц).
  • Синусоидальные, треугольные и прямоугольные выходные колебания.
  • Напряжение питания от 2.3 В до 5.5 В.
  • Трехпроводной интерфейс SPI.
  • Расширенный температурный диапазон: от –40°C до +105°C.
  • Опция пониженного энергопотребления.

При генерации синусоидальных и треугольных импульсов амплитуда изменяется в диапазоне 38мВ…0,65В. При генерации импульсов прямоугольной формы на выходе присутствует сигнал уровня TTL.

Работа генератора контролируется при помощи 2-х кнопок и энкодера, при нажатии кнопки энкодера можно перебирать разряды и поворотом ручки энкодера можно установить число от 0 до 9 в каждом разряде. При изменении частоты генератора выход генератора отключается, после установки нужно частоты необходимо нажать кнопку «Генератор On/Off«, для изменения формы сигнала необходимо нажать кнопку «Форма сигн.». Так же при изменении формы сигнала выход генератора отключается.

Частотомер работает независимо от генератора и в управлении не нуждается.

Генератор в данном проекте ограничен максимальной частотой в 10 МГц, диапазон измерения частотомера от 0 до 6,5 МГц.

  1. Показания частотомера
  2. Показания генератора
  3. Индикатор выходного сигнала генератора
  4. Форма сигнала

Обновлено: 01.08.2022 в 20:09 | Просмотров: 846

TDA7313 + DS3231 + IR + LCD2004 (Arduino)
Ранее в http://rcl-radio.ru/?p=58563 описывался пример использования аудиопроцессора TDA7313 под управлением Arduino Nano с дисплеем LCD1602, на этой странице будет рассмотрен аналогичный пример но с использованием дисплея LCD2004 c I2C модулем на базе микросхем PCF8574, что позволяет подключать символьный дисплей LCD2004 к плате Arduino всего по двум проводам SDA и SCL (А4 и А5). Микросхема TDA7313 имеет три стерео входа, регуляторы тембра НЧ и ВЧ, тонкомпенсация и четыре выхода.

R2A15908SP — стерео аудиопроцессор (Arduino)
R2A15908SP — простой но высококачественный аудиопроцессор с микроконтроллерным управлением (I2C). Основные характеристики аудиопроцессора R2A15908SP: Регулировка громкости от -87 до 0 дБ (шаг 1 дБ) 5-и канальный коммутатор входов Режим MUTE Независимый для каждого входа предусилитель с диапазоном регулировки от 0 до 20 дБ (шаг 2 дБ) Регуляторы тембра ВЧ и НЧ с диапазоном регулировки от -14 до +14 дБ (шаг 2 дБ) Режимы: Surround Low / High Напряжение питания от 4,75 до.

Внешний ЦАП WM8805 + PCM1753 (Arduino)
ЦАП — цифро-аналоговый преобразователь — это устройство, которое преобразует информацию из цифрового вида в аналоговые сигналы, при этом максимально точно и без искажений. Собрать внешний ЦАП на компонентах предложных в статье не сложно, он содержит несколько недорогих компонентов и в настройке практически не нуждается. Входной цифровой сигнал имеет формат S/PDIF (цифровой аудио интерфейс разработанный фирмами SONY/PHILIPS, предназначен для передачи цифрового сигнала между аудио.

Электронный регулятор громкости CS3310 (Arduino)
CS3310 — электронный, стерео регулятор громкости с микроконтроллерным управлением. Основные характеристики регулятора громкости на CS3310: два независимых канала шаг регулировки 0,5 дБ диапазон регулировки от -95,5 дБ до +31,5 дБ (127 дБ) КНИ не более 0.001% динамический диапазон 116 дБ перекрестные помехи между каналами не более -110 дБ напряжение питания ±5 В MUTE На базе Arduino можно организовать управление CS3310. Вся информация будет выводится на.

Регулятор громкости и тембра на LC75341 + 0.96′ I2C 128X64 OLED (Arduino)
Ранее в статье рассматривался пример создания на основе аудиопроцессора LC75341 регулятора громкости и тембра с использованием дисплея LCD1602 + I2C, в этой статье аналогичный пример, но с использованием дисплея 0.96′ I2C 128X64 OLED. В OLED дисплее отсутствует дополнительный слой подсветки всей поверхности экрана. Каждый пиксел, формирующий изображение, испускает самостоятельное свечение. При этом картинка получается яркой и контрастной. Управление OLED дисплеем в данном.

Источник

Adblock
detector