Rapid prototyping is critical in reducing time to market for new products. Peripheral boards featuring sensors are abundant, from the likes of Digilent® and MIKROE®. However, connecting to these peripheral boards can be challenging. Xilinx® programmable logic devices provide ultimate flexibility in sensor fusion, enabling engineers to connect to virtually any sensor.
Digilent offers over 150 PMods, Peripheral Modules, along with a Xilinx IP library that makes rapid prototyping incredibly easy. In fact in most cases, you don’t need to write any RTL or C code to quickly evaluate and collect data from a sensor.
MIKROE offers the most impressive selection of rapid prototyping modules over 750 Click Boards! However connecting Xilinx devices to this ecosystem is not quite as easy as with Digilent.
The goal of this project is to build Xilinx mikroBUS IP to easily connect with MIRKOE Click Boards and provide an example design interfacing to a sensor and display module. The board used in this project is the super flexible and low-cost Digilent Arty-7S-50 board.
The purpose of this document navigates a flow through the course of the project. The goal was attaching external components and program with Xilinx tools such as Vivado™ and Xilinx SDK. A shield board from MIKROE, Arduino Uno Click Shield, provides a physical interface from the Arty board Arduino header to two Click Boards.
Design FlowFor this demo, I thought it would be fun to build a breathalyzer using a MIKROE Alcohol Sensor, Alcohol 2 Click, to measure ethanol in a person’s breath and a display the relative level on a LED bar graph, Bargraph 2 Click.
MIKROE defines an interface standard called mikroBUS that contains many common protocols such as IIC, SPI, UART, PWM and Analog.
For this design, the alcohol sensor uses an IIC interface while the BarGraph display uses a SPI interface.
The first task was to start mapping the pins from the Xilinx FPGA through the Arty Board’s Arduino header to the Click Uno Shield Board. This was crucial in order for the connections to be accurate. Following the pin mapping, a Vivado design was implemented. This allowed for the hardware and software to talk correctly.
The second task was to create IP inside Xilinx’s Vivado tool to interface to the mikroBUS interface. The mikroBUS is a custom IP block made from the existing Xilinx IP:
- UARTLite
- I2C
- Quad SPI
- PWM
- GPIO
- Analog
The mikroBUS is still a protype and can be integrated into the IP library. Or alternatively, using this design as a basis to interface to other Click boards.
Vivado Design:
Xilinx design tool, Vivado, is a powerful tool for customizing logic for your design. A referenced design for the Arty board already existed, however due to the project, decided to work from the bottom up to highlight some of the flow.
Click IP Integrator and open Block Diagram in Vivado, it includes a drag and drop option from the IP catalog. This provides UART capabilities, I2C, Timers, memory, choose one to your liking. Below will provide a better visual:
The arrow provides a list of IP to choose from, for the selected project that had to include the following:
- Memory
- Interrupts
- MicroBlaze
- Processor System Reset
- AXI interconnect
- Timer
- UARTLite
- ADC
- GPIO
- Quad SPI
These essential components allowed the system to operate functionally and independently of other IP in the design. For example, I later discovered the IP block needed its own set of peripherals. A UART IP is needed to be included for the arty to communicate with local host however another UART IP had to be included in the mikroBUS IP for the communication link between click board and arty board.
Xilinx MicroBlaze™ 32-bit RISC soft-processor is built into the programmable logic of the FPGA and enables software control of the peripherals. And adding this IP in Vivado’s IP Integrator tool means no RTL experience was required in building or interacting with this design!
Xilinx FPGAs have local memory available and can be used for processor memory, FIFOs and many more applications. So attaching local memory to MicroBlaze means we do not need external memory, like DDR SDRAM, for code storage. That said, a problem with memory occurred where the default setting for local MicroBlaze memory is set to 8K. I had to increase this for the system to not corrupt or overwrite memory. To fix this look at figure below to choose the necessary amount of memory needed:
MicroBlaze also allows for interrupts. When playing with interrupts there was an error to the actual component where it’s has an output linking nowhere. To avoid this problem, drag the pencil cursor from the output to a concat IP block that you find in the IP catalog. If you don’t attach the interrupt pin to concat then there will have interrupt problems in the software. Attach the output pin for the cat to interrupt block:
Once the design as completed, the IP block diagram must be saved first and then validated. This is crucial for successful Block Design to proceed to next step. Synthesis and implementation follow to generate valid bitstreams. Careful with errors and critical warnings. Mapping pins is important to look at schematics and datasheets to locate any logical errors. Some important notes are mentioned below in regard to Vivado.
By clicking through the left tab of Vivado tool, navigate to the synthesis tab and run simulation. This will synthesize the design and locate the pins and ports necessary to the FPGA. I/O Planning is a tool for debugging and visualizing the pins on board.
Once the IO planning has executed navigate to the subsection to find the TCL Console, Messages, Logs and Reports tab. Click on I/O Ports and find the allocated pins to the assigned FPGA.
To manually manipulate the constraints with specific pins and voltages, find sources and click the newly made constraints .XDC file: mikroBUS_Arty-S7-50.xdc(target). When receiving synthesis error, by changing the xdx.
Critical Error [17-55] is a common error that occurs in most design and is was displayed with this project. To overcome the error, find the TCL console and input:
- get_ports {{Name of peripheral”}
- get_ports {Analog_In_0}
This will allow you to see if the port exist based on your outputs from the block diagram.
HardwareThe Arty schematic is useful for identifying available peripherals and mapping Xilinx I/O to connectors on the board. The highlighted targets are the CHipKit Arduino. The hardware displays numerous pins. The primary objective currently is looking for the pins from Click boards --> Shield --> FPGA Arduino Pins to the FPGA net names
In order for the design to match up with the external peripheral’s pin, have to connect the FPGA outputs to the mikroBUS. Below represents the flow of events to visually conceptualize the project:
Arty-S7 Board Layout:
Here are the pin layouts for the ChipKit Arduino for the Arty-S7. The highlighted elements show the active pins. As the FPGA has the possibility of using the Arduino pins, associating the highlighted with appropriate pins is crucial for the operation to execute correctly. The schematic above gives a visual representation what pins to configure in order for the shield to connect to the external peripheral. The connectors, J1, J3, J5, and J8, are the location for the Arduino shield header of the Arty-S7.
The following tables are for the integration of the MIKROE Click boards. The project focused on a fundamental IP block to integrate an adaptive state no matter which sensor is connected. For proof of concept I used the LED BarGraph and an Alcohol Sensor Click modules.
Click 1 SunLED SensorBelow describes the product description and its ability.
Starting with the LED BarGraph, it appears it requires two protocols; PWM and SPI. Below shows the pin mapping for the LED BarGraph
Examining this Click module closer, there several SN74HC595 bit shift registers that drive the LEDs. These shift registers are daisy-chained together with the output of the first driving the input of the second, and so on. The reason there are three is because there are 3 different colors; Green, Yellow and Red. Below shows the process of how the SPI communicates to the one register and by proxy and enable the other 2. I chose to drive the LEDs at 25MHz. Xilinx IP easily allows you to set the output frequency for the SPI interface.
There are a few dependencies for the sensor to operate. You have to have the PWM pin set to high ideally 100% for full brightness. This is done in Vivado with the same pin, however you make a constant value with assigned pin R16 for XDC file as PWM_Constant[0:0] IP. Here is a picture to demonstrate what this looks like.
SPI is being used on this design. There is a pattern that has to be emulated in order for the signal to create any LED to turn on. Here is the pattern for LEDs to operate.
What does this mean? It shows the SDK clock working periodically. There is a SER value (the latch) that has to be enabled and disable for transmission. There is a data pin that send the data to bit shift register and there has to be a reset, set high for transmission. The hardware describes this best.
This is an example of a daisy chain. You send the data via spi however there is a latch that is labeled as RCLK that you have to set to high for the full transaction to occur = LED ON. If you do not enable the latch = LED OFF.
The LED Values are crucial in understanding the colors. The first 10 bits are green, then the second red. Lighting up both green and red bits produces the color yellow. Here is the data sheet to confirm which bits to light up for the LED sensor.
The Demo for the project will allow you to insert keyboard commands into Teraterm (console) and control the LED blinking either all green, yellow or red and selected LED to light up.
The LEDs glow like below
Below describes the product description and its ability.
The protocol used in this sensor uses I2C, Analog and GPIO.Examining the Alcohol to Click Sensor shows the ethanol sensor, a TI analog front end (AFE) IC, LMP91000, and 12-bit ADC. The AFE conditions and amplifies the signal for the ADC. These IC’s communicate via IIC as shown below. Additionally there is an analog output from the Alcohol 2 Click board used for temperature compensation. That was not used in this design.
The datasheet for the LMP91000 has information regarding IC registers which can communicate write functions and read functions to the peripheral (E.g. alcohol sensor). Primarily interfaces with analog front end (AFE). It provides a complete signal path. Supply Current (Average Over Time) <10 µA solution between a sensor and a microcontroller that generates an output voltage proportional to the cell to 10 mA current. This supports gas sensitivities over a range of 0.5 nA/ppm - 9500 nA/ppm. The pattern below is the process of how the system operates with I2C.
Here are the specific registers to talk to in order to communicate with the sensor.
The schematic below describes which IC chip will be interfacing with the Alcohol 2 Click module The protocol using I2C, SDA & SCL, communicate with the LMP91000and write writes commands for the set address for AFE and ADC. By talking to the LMP91000you do not have to actively select the analog pin, there is choice in how to read the alcohol sensor. MikroElectronika says:
"The Click board™ has two additional ICs onboard. The first one is the MCP3221, a 12-bit successive approximation register A/D converter, from Microchip. The second IC is the OPA344, a single supply, rail to rail operational amplifier, from Texas Instruments. It is possible to use the onboard switch, labeled as AN SEL, to select the IC to which the VOUT pin from the LMP91000 AFE is routed. If the switch is in the ADC position, the VOUT pin will be routed to the input of the MCP3221 ADC."
Out of proof of concept in this design, communication with LMP91000 was ideal.
Note to user, there is an internal problem with the ARTY S7 board and the Arduino Uno Click Shield. The pins used by Click Shield’s IIC interface are connected to the analog inputs of the FPGA. The Arty S7-50 Digilent board has a voltage divider to reduce analog signals to under 1V, which is required by the Xilinx FPGA. Due to the mapping of these pins, there is a confliction for the requirement of the click board. It’s IIC interface must operate at 3.3 Volts to allow the IIC to work. This problem was resolved by removing some components on the board to allow the transaction to occur. Below shows the user how to change the HW.
After a soldering job the board should look like the picture below. Objective is to remove and short the resistors and capacitors to form this picture.
The waveform result after the board has been retouched looks like the data is transmitting
The Demo for the project will allow view the alcohol values ranging from 0 to 3500. The range was tested many times to show adequate results. Lol
Combing the click boards was fairly simple. The hardware had to include all the pin mappings for each component. Making sure the routing to the correct pin was good.
The software was the easiest. Since each demo was executed in a separate project, use them as blocks. The order does matter however, have the SunLED bargraph execute the proper simulation from before and then add IIC. Test the LEDs on click board and then combine the two together.
Making a suitable range was difficult. The gas sensor has not been calibrated, from the independent tests, an accurate model can be created. The system follows the block diagram below as the input is the alcohol sensor and the output is the SunLED.
Note if you want to receive Alcohol values faster change the the frequency for LED by adjusting the Master Reset (MR) delay time.
RANGE determining Status of User
DEMO
2 Clicks Operating Together
Final mikroBUS Block with external connections to Alcohol Sensor and LED BarGraph:
Click 1, SunLED Bar Graph:
Click 2, Alcohol Sensor:
Final Vivado IP Integrator Design:
Final Vivado IP Integrator Design:
The end goal was achieved! This project illustrates an example design featuring a custom MikroBus IP that can connect to nearly any MIKROE Click Module, enabling this massive ecosystem to work on Xilinx FPGAs and SoCs.. There are definitely many more adjustments to be made for the future of the project, but this IP serves a great starting point for integrating MIKROE’s expansive collection of sensors and prototyping modules enabling the most flexible rapid prototyping environment available.
I look forward to working more with the Vivado flow and produce a final product with the sensors given. There is a lot to learn and knowing the beginning stages from top to bottom will make designs faster in the future.
And this has proven to be a fun party gadget! And maybe kept a few drunk people from driving! 😊
Acknowledgements
Jayson Bethurem
Kelby Penney
Brandon Day
Mikroelectronika Team
Comments