As Halloween is coming up quickly I thought it would be a great idea to create a simple project which uses a Zynq to provide a little LED lighting in my pumpkin.
Using a NEO Pixel strip we are able to create some great Lighting effects in the pumpkin and what's more it makes for a safer solution than using candles.
To get started with this I am going to use the Cora Z7 board as it is small and compact while providing a simple interface to the programmable logic.
Hardware DesignTo get started we need to create a design in Vivado which includes the Zynq PS configured for the Cora Z7 system.
We do this by creating a new project and adding in the Zynq PS and then running the block automation.
Once this has completed you will see several new added IO to the Zynq PS block diagram.
To be able to communicate with the NEO Pixels we are going to need the driver previously created and available on my GitHub at the link below
https://github.com/ATaylorCEngFIET/neo_pixel_ip
To be able to use this IP we need to clone or download and extract the compressed file.
Once the file is available we need to add it into the project, we do this using the add sources option.
In the dialog which appears, select the file and ensure copy sources into project is checked.
With the sources added back in the block diagram, add in a AXI BRAM controller.
Once the BRAM controller is added in, double click on it and change the number of BRAM interfaces to one.
Once that is complete, in Vivado run the connection automation to connect the AXI BRAM controller into the Zynq AXI Network and the create a appropriately sized BRAM.
Once this is completed the block diagram should be as shown below.
Now we need to add in the Neo Pixel Driver into the block diagram and connect it up. Select the imported RTL file, right click on it and select Add Module to Block Design
This will add in the NeoPixel driver to the block diagram.
The next step is to change the clock driving the AXI network and the NeoPixel driver. To do this we double click on the Zynq and change its frequency to 20MHz.
Finally we can connect the BRAM to the NeoPixel driver and make the output signal from the NeoPixel driver external.
To create the design the next step is to create a wrapper for the Block Design, allow Vivado to manage this.
Once the wrapper is completed we can build the bit stream and export the XSA so we can create a Vitis project.
ff
Once the XSA has been exported, the next step is to open Vitis from Vivado using the tool menu.
When Vitis opens select a workspace directory - normally I create the workspace in the Vivado project directory to keep all SW located together.
Once Vitis opens the next step is to create a new application project.
Select the XSA just exported from Vivado as the platform hardware.
Then enter a project name mine is Halloween
Select the standalone domain
Finally select the hello world template, we can easily modify this.
This will create a new project to which we can add our software.
Our software application is going to do the following stages,
- Initialize the BRAM
- Generate the pattern for the neo Pixels
- Update the Neo Pixels
To do this I have create functions which load the BRAM and which rotate the pixels in the neo pixel array.
void move()
{
u32 tempData;
int x;
for( x = 0; x< (max_x-1); x++){
tempData = present[max_x-1];
if (tempData != 0) {
present[0] = tempData;
present[max_x-1] = 0x0;
}
present[x+1] = present[x];
present[x] = 0x00000000;
load_ram();
usleep(500000);
printf("iteration %d\n\r",x);
}
}
void rotate()
{
u32 tempData;
int x;
for( x = max_x-1; x> 0; x--){
if (x == max_x-1) {
tempData = present[max_x-1];
//present[max_x-1] = 0x0;
}
present[x] = present[x-1];
present[0] = tempData;
//present[x] = 0x00000000;
load_ram();
printf("iteration %d\n\r",x);
}
usleep(100000);
}
void load_ram()
{
int ram_addr = 0x4;
ram_addr = 0x4;
for (int m = 0; m < max_x; m++)
{
ram_addr = (m*4)+4;
XBram_WriteReg(XPAR_AXI_BRAM_CTRL_0_S_AXI_BASEADDR, ram_addr, present[m]);//present[l][m]);
}
//enable the data
XBram_WriteReg(XPAR_AXI_BRAM_CTRL_0_S_AXI_BASEADDR, 0, (u32)numb_pixels);
}
We can then have preset patterns in the software which these functions allow us to move through.
With the software created the next thing to do was to test the hardware which goes in the pumpkin.
CommissioningWhen I connected the NeoPixels to the CoraBoard and the power supply I was expecting it to go well. However, I had an odd situation where the although I was only driving one Neo Pixel the one next to it would come on as well in a random color.
I happened to have a new Tektronix scope to take a examine as it is based on a Zynq 7000S device the TBS1052C. It seemed a perfect opportunity to examine the scopes capabilities and to grab a few screen shots using the capture mode for this project.
Looking at the signal when probed using the scope the I could see the signal had a lot of noise on it and was very jittery.
I wondered if I was driving the output to fast from the PL of the Cora and causing the ringing on the rising edge. Opening Vivado I was able to re run the design with the output slew rate set at its minimum setting to hopefully provide a cleaner signal.
With the reimplemented design completed the and tested on the hardware the signal quality was much better and most importantly the Neo Pixel bahaved themselves.
I must admit I liked using the scope and the ease with which I could take measurements and save plots to the USB. as I understand it most of this functionality is implemented in a Zynq which just shows how capable they are.
All that remained then was to test all of the LEDs in the patterns I wanted.
The penultimate step is of course cutting the pumpkin, now as European I am not too accustomed to the artistic pumpkin carving requirements so I called in an expert. Dan who is three years old and insisted that pumpkins definitely have a smiley face.
First off we marked out the face on the pumpkin
Then we cut into the pumpkin and made the holes required
Once the pumpkin was completed, and most importantly we both still had out fingers attached we were ready to try it out.
Final ThingThe final stage of the pumpkin development was to insert the lights and power the Cora board and the NeoPixels.
As it is raining outside for our test we did it in my office.
Although you cannot see the LED changing patterns the pumpkin was quite bright and cycles around randomly in the NeoPixel color range.
We are now ready for Halloween - We just best stock up on sweeties (candy) first.
Comments
Please log in or sign up to comment.