Skip to Content
Learning FPGAs
book

Learning FPGAs

by Justin Rajewski
August 2017
Beginner
230 pages
5h 39m
English
O'Reilly Media, Inc.
Content preview from Learning FPGAs

Chapter 8. Analog Inputs

There are eight analog inputs on the Mojo, accessible though the 10-pin connector. However, FPGAs don’t usually have any analog circuitry built in. Because of this, these analog inputs are from the microcontroller on the Mojo. After the microcontroller does its job of programming the FPGA, it becomes a USB-to-serial converter as well as an analog-to-digital converter (ADC).

In this tutorial, we are going to read the analog inputs and use their values to vary the brightness of the eight LEDs on the Mojo.

The AVR Interface

We’ve used the AVR Interface component before, in Chapter 6. However, this time we are going to use the ADC portion of it instead of the serial portion. The ADC on the AVR takes a voltage input in the range of 0–3.3 V and converts it to a number from 0–1,023 (a 10-bit value). As before, we will start by creating a new project based on the AVR Interface example project.

If you take a look at the avr_interface module, there are four signals we care about when trying to read the analog inputs:

    // ADC Interface Signals
    input channel[4],          // ADC channel to read from, use hF to disable ADC
    output new_sample,         // new ADC sample flag
    output sample[10],         // ADC sample data
    output sample_channel[4],  // channel of the new sample

You’ll probably notice that only one of these is an input. That means the value we have to worry about providing is channel, which is the number of the input we want to read. If you look at your Mojo, there are eight analog ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Getting Started with FPGAs

Getting Started with FPGAs

David Romano
Learning Algorithms

Learning Algorithms

George Heineman

Publisher Resources

ISBN: 9781491965481Errata Page