SETTING UP THE HARDWARE DESIGN
1. Select Create new project in Vivado
2. Select ZedBoard Zynq Evaluation and Development Kit from the Boards tab
3. Select Create block design from the left panel
4. Add IP (ZYNQ7 Processing System)
5.1 Run Block Automation
6.2 Add IP (AXI GPIO)
7. Run Connection Automation
8. Add IP (GPIO)
9. Right Click on the right side of the GPIO and make external.
10. Run Connection Automation
11. Double click on the GPIO and customize. Do not select either box that says all inputs or all outputs. Set the GPIO width by changing 32 to 8.
12. Save block design
13. Validate design
14. Run Synthesis
15. Open Contraints Wizard and under the sources tab, select Leaf Cells. (CAn also input through I/0 ports in the window menu.) Here you should see your 8 pmod connections. Using the following table (which was created using page 3 and 9 of the following link : http://zedboard.org/sites/default/files/documentations/ZedBoard_RevD.2_Schematic_130516.pdf), change the sites to the correct location and make sure I/O Standard is LVMOS33.
PIN Site Bit #
JA1 Y11 0
JA2 AA11 1
JA3 Y10 2
JA4 AA9 3
JA7 AB11 4
JA8 AB10 5
JA9 AB9 6
JA10 AA8 7
This makes the proper connections in the Zedboard for the pins of PMOD JA.
16.Run Synthesis
17. Create HDL Wrapper (from sources tab)
18. Generate bitstream
19. Export Hardware (include bitstream)
20. Launch SDK (change workspace)
21. Open new application project
22. Expand project and import src
23. Click General > File System
24. Browse to find directory
25. Xilinx Tools > Program FPGA
26. Under Project Explorer right click to run-as project
27. Launch on Hardware
This image shows the pins of the PMOD and which pins are ground, Vcc, and signals. |
SOFTWARE/CODING IN SDK
- The following code allows us to read voltages from different pmod pins when different buttons on the zedboard are pushed:
#include "xparameters.h"
#include "xgpio.h"
#include "xscugic.h"
#include "xil_exception.h"
#include "xil_printf.h"
// Parameter definitions
#define INTC_DEVICE_ID XPAR_PS7_SCUGIC_0_DEVICE_ID
#define BTNS_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID
#define LEDS_DEVICE_ID XPAR_AXI_GPIO_1_DEVICE_ID
#define PMOD_JA1_DEVICE_ID XPAR_AXI_GPIO_2_DEVICE_ID
#define INTC_GPIO_INTERRUPT_ID XPAR_FABRIC_AXI_GPIO_0_IP2INTC_IRPT_INTR
#define BTN_INT XGPIO_IR_CH1_MASK
XGpio LEDInst, BTNInst, PMODJA1Inst;
XScuGic INTCInst;
static int led_data;
static int btn_value;
//----------------------------------------------------
// PROTOTYPE FUNCTIONS
//----------------------------------------------------
static void BTN_Intr_Handler(void *baseaddr_p);
static int InterruptSystemSetup(XScuGic *XScuGicInstancePtr);
static int IntcInitFunction(u16 DeviceId, XGpio *GpioInstancePtr);
//----------------------------------------------------
// INTERRUPT HANDLER FUNCTIONS
// - called by the timer, button interrupt, performs
// - LED flashing
//----------------------------------------------------
void BTN_Intr_Handler(void *InstancePtr)
{
// Disable GPIO interrupts
XGpio_InterruptDisable(&BTNInst, BTN_INT);
// Ignore additional button presses
if ((XGpio_InterruptGetStatus(&BTNInst) & BTN_INT) !=
BTN_INT) {
return;
}
btn_value = XGpio_DiscreteRead(&BTNInst, 1);
// Increment counter based on button value
// Reset if centre button pressed
if(btn_value != 1) led_data = led_data + btn_value;
else led_data = 0;
XGpio_DiscreteWrite(&LEDInst, 1, led_data);
XGpio_DiscreteWrite(&PMODJA1Inst, 1, led_data);
(void)XGpio_InterruptClear(&BTNInst, BTN_INT);
// Enable GPIO interrupts
XGpio_InterruptEnable(&BTNInst, BTN_INT);
}
//----------------------------------------------------
// MAIN FUNCTION
//----------------------------------------------------
int main (void)
{
int status;
//----------------------------------------------------
// INITIALIZE THE PERIPHERALS & SET DIRECTIONS OF GPIO
//----------------------------------------------------
// Initialize PMOD JA1
status = XGpio_Initialize(&PMODJA1Inst, PMOD_JA1_DEVICE_ID);
if(status != XST_SUCCESS) return XST_FAILURE;
// Initialise LEDs
status = XGpio_Initialize(&LEDInst, LEDS_DEVICE_ID);
if(status != XST_SUCCESS) return XST_FAILURE;
// Initialise Push Buttons
status = XGpio_Initialize(&BTNInst, BTNS_DEVICE_ID);
if(status != XST_SUCCESS) return XST_FAILURE;
// Set PMODJA1 direction to for location 76543210 Pin 3 is an input, pin4 is an output
XGpio_SetDataDirection(&PMODJA1Inst, 1, 0b00001000);
// Set LEDs direction to outputs
XGpio_SetDataDirection(&LEDInst, 1, 0x00);
// Set all buttons direction to inputs
XGpio_SetDataDirection(&BTNInst, 1, 0xFF);
// Initialize interrupt controller
status = IntcInitFunction(INTC_DEVICE_ID, &BTNInst);
if(status != XST_SUCCESS) return XST_FAILURE;
while(1);
return 0;
}
//----------------------------------------------------
// INITIAL SETUP FUNCTIONS
//----------------------------------------------------
int InterruptSystemSetup(XScuGic *XScuGicInstancePtr)
{
// Enable interrupt
XGpio_InterruptEnable(&BTNInst, BTN_INT);
XGpio_InterruptGlobalEnable(&BTNInst);
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler)XScuGic_InterruptHandler,
XScuGicInstancePtr);
Xil_ExceptionEnable();
return XST_SUCCESS;
}
int IntcInitFunction(u16 DeviceId, XGpio *GpioInstancePtr)
{
XScuGic_Config *IntcConfig;
int status;
// Interrupt controller initialisation
IntcConfig = XScuGic_LookupConfig(DeviceId);
status = XScuGic_CfgInitialize(&INTCInst, IntcConfig, IntcConfig->CpuBaseAddress);
if(status != XST_SUCCESS) return XST_FAILURE;
// Call to interrupt setup
status = InterruptSystemSetup(&INTCInst);
if(status != XST_SUCCESS) return XST_FAILURE;
// Connect GPIO interrupt to handler
status = XScuGic_Connect(&INTCInst,
INTC_GPIO_INTERRUPT_ID,
(Xil_ExceptionHandler)BTN_Intr_Handler,
(void *)GpioInstancePtr);
if(status != XST_SUCCESS) return XST_FAILURE;
// Enable GPIO interrupts interrupt
XGpio_InterruptEnable(GpioInstancePtr, 1);
XGpio_InterruptGlobalEnable(GpioInstancePtr);
// Enable GPIO and timer interrupts in the controller
XScuGic_Enable(&INTCInst, INTC_GPIO_INTERRUPT_ID);
return XST_SUCCESS;
}
- The following code blinks the LEDs and turns the voltages from the pmod on and off.
/* LED_test.c
*
* Created on: 13 June 2013
* Author: Ross Elliot
* Version: 1.1
*/
/********************************************************************************************
* VERSION HISTORY
********************************************************************************************
* v1.1 - 27 January 2014
* GPIO_DEVICE_ID definition updated to reflect new naming conventions in Vivado 2013.3
* onwards.
*
* v1.0 - 13 June 2013
* First version created.
*******************************************************************************************/
/********************************************************************************************
* This file contains an example of using the GPIO driver to provide communication between
* the Zynq Processing System (PS) and the AXI GPIO block implemented in the Zynq Programmable
* Logic (PL). The AXI GPIO is connected to the LEDs on the ZedBoard.
*
* The provided code demonstrates how to use the GPIO driver to write to the memory mapped AXI
* GPIO block, which in turn controls the LEDs.
********************************************************************************************/
/* Include Files */
#include "xparameters.h"
#include "xgpio.h"
#include "xstatus.h"
#include "xil_printf.h"
/* Definitions */
#define GPIO_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID /* GPIO device that LEDs are connected to */
#define LED 0xC3 /* Initial LED value - XX0000XX */
#define PMOD 0xC3 /* Initial LED value - XX0000XX */
#define LED_DELAY 10000000 /* Software delay length */
#define LED_CHANNEL 1 /* GPIO port for LEDs */
#define PMOD_CHANNEL 1 /* GPIO port for PMODs */
#define printf xil_printf /* smaller, optimised printf */
#define PMOD_JA1_DEVICE_ID XPAR_AXI_GPIO_1_DEVICE_ID
XGpio Gpio, GpioP; /* GPIO Device driver instance */
int LEDOutputExample(void)
{
volatile int Delay;
int Status;
int led = LED; /* Hold current LED value. Initialise to LED definition */
int pmod = PMOD;
/* GPIO driver initialisation */
Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
Status = XGpio_Initialize(&GpioP, PMOD_JA1_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
/*Set the direction for the LEDs to output. */
XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);
/*Set the direction for the LEDs to output. */
XGpio_SetDataDirection(&GpioP, PMOD_CHANNEL, 0x00);
/* Loop forever blinking the LED. */
while (1) {
/* Write output to the LEDs. */
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, led);
/* Flip LEDs. */
led = ~led;
/* Write output to the LEDs. */
XGpio_DiscreteWrite(&GpioP, PMOD_CHANNEL, pmod);
/* Flip LEDs. */
pmod = ~pmod;
/* Wait a small amount of time so that the LED blinking is visible. */
for (Delay = 0; Delay < LED_DELAY; Delay++);
}
return XST_SUCCESS; /* Should be unreachable */
}
/* Main function. */
int main(void){
int Status;
/* Execute the LED output. */
Status = LEDOutputExample();
if (Status != XST_SUCCESS) {
xil_printf("GPIO output to the LEDs failed!\r\n");
}
return 0;
}
- The following code allows us to push a button from the circuit which makes pin 3 read high and the terminal displays the value 4 (00000100).
/*Pin 3 is connected to a pull-down resistor and a button. When the button is pressed, the pin reads high and outputs the value 4 to the terminal (gtkterm). It also turns on an LED. */
/* Include Files */
#include "xparameters.h"
#include "xgpio.h"
#include "xstatus.h"
#include "xil_printf.h"
#include "time.h"
/* Definitions */
#define GPIO_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID /* GPIO device that LEDs are connected to */
#define LED 0xFC /* Initial LED value - XX0000XX */
#define PMOD 0xFC /* Initial LED value - XX0000XX */
#define LED_DELAY 100000000 /* Software delay length */
#define LED_CHANNEL 1 /* GPIO port for LEDs */
#define PMOD_CHANNEL 1 /* GPIO port for PMODs */
#define printf xil_printf /* smaller, optimised printf */
#define PMOD_JA1_DEVICE_ID XPAR_AXI_GPIO_1_DEVICE_ID
#define ABOUT_ONE_SECOND 74067512 //!< approx 1 second delay when used as argument with function delay(numberCyclesToDelay)
// Update this if uBlaze/Zynq CPU core frequency is changed, or if the external memory timing changes.
// Although emprirically tested to 1.0000003 seconds, it is not meant to be used for precise timing purposes
/* Definitions */
#define CLOCK_on 0x08 //high for the clock
#define DATAREADY_high 0x04 //high for data ready pin 3
XGpio Gpio, GpioP; /* GPIO Device driver instance */
int LEDOutputExample(void)
{
volatile int Delay;
int Status;
int led = LED; /* Hold current LED value. Initialise to LED definition */
int pmod = PMOD;
int WritetoLEDs;
int i;
u32 x;
/* GPIO driver initialisation */
Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
Status = XGpio_Initialize(&GpioP, PMOD_JA1_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
delay(ABOUT_ONE_SECOND*5);
/*Set the direction for the LEDs to output. */
XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);
/*Set the direction for the LEDs to output. */
XGpio_SetDataDirection(&GpioP, PMOD_CHANNEL, 0x04);
WritetoLEDs =0x01;
for(i =1;i<8;i++){
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, WritetoLEDs);
delay(ABOUT_ONE_SECOND/2);
WritetoLEDs=(int)(1<<i);
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, WritetoLEDs);
delay(ABOUT_ONE_SECOND/2);
}
printf("Ready to receive.\n \r");
delay(10);
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0x00);
while (1) {
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0x00);
delay(10);
XGpio_DiscreteWrite(&GpioP, PMOD_CHANNEL, 0x00);
x = XGpio_DiscreteRead(&GpioP,PMOD_CHANNEL);
delay(10);
printf("The voltage on pin 3 is %d \n \r",x);
delay(10);
while(x==0x04){
XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0x01);
delay(10);
XGpio_DiscreteWrite(&GpioP, PMOD_CHANNEL, 0x08);
delay(10);
x = XGpio_DiscreteRead(&GpioP,PMOD_CHANNEL);
}
/* Wait a small amount of time so that the LED blinking is visible. */
for (Delay = 0; Delay < LED_DELAY; Delay++);
}
return XST_SUCCESS; /* Should be unreachable */
}
void delay(int nStopValue)
/**
* \brief Loop for nStopValue iterations to provide a delay.
* \par Details
* It is commonly used with the constant 'ABOUT_ONE_SECOND' defined in maximPMOD.h for
* setting approximate delays
*
* \param[in] nStopValue - number of iterations to loop
*
* \retval None
*/
{
int i=0;
int a=0;
for(i=0;i<nStopValue;i++)
{
a=i;
}
}
/* Main function. */
int main(void){
int Status;
/* Execute the LED output. */
Status = LEDOutputExample();
if (Status != XST_SUCCESS) {
xil_printf("GPIO output to the LEDs failed!\r\n");
}
return 0;
}
- The following code that allows us to read in a signal from the function generator. (Using the Max11205)
The process of storage is shown using the LEDs. Each bit is shifted to the left. This is a program to
understand the bit-bang process and how the Maxim Integrated 11205 ADC works.*/
/* Include Files */
#include "xparameters.h"
#include "xgpio.h"
#include "xstatus.h"
#include "xil_printf.h"
#include "time.h"
/* Definitions */
#define GPIO_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID /* GPIO device that LEDs are connected to */
#define LED 0xFC /* Initial LED value - XX0000XX */
#define PMOD 0xFC /* Initial LED value - XX0000XX */
#define LED_DELAY 100000000 /* Software delay length */
#define LED_CHANNEL 1 /* GPIO port for LEDs */
#define PMOD_CHANNEL 1 /* GPIO port for PMODs */
#define printf xil_printf /* smaller, optimised printf */
#define PMOD_JA1_DEVICE_ID XPAR_AXI_GPIO_1_DEVICE_ID
#define ABOUT_ONE_SECOND 74067512 //!< approx 1 second delay when used as argument with function delay(numberCyclesToDelay)
// Update this if uBlaze/Zynq CPU core frequency is changed, or if the external memory timing changes.
// Although emprirically tested to 1.0000003 seconds, it is not meant to be used for precise timing purposes
/* Definitions */
#define CLOCK_on 0x08 //high for the clock
#define DATAREADY_high 0x04 //high for data ready pin 3
XGpio Gpio, GpioP; /* GPIO Device driver instance */
u32 LEDOutputExample(void)
{
volatile int Delay;
int Status;
int led = LED; /* Hold current LED value. Initialise to LED definition */
int pmod = PMOD;
int WritetoLEDs;
int i;
u32 x;
u8 uchPortWriteData=0;
u8 uchPortReadData=0;
u32 adcValue=0;
int nClockCount;
int uchUseCalibrationMode=0;
/* GPIO driver initialisation */
Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
Status = XGpio_Initialize(&GpioP, PMOD_JA1_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
/*Set the direction for the LEDs to output. */
XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);
/*Set the direction for the PMod - pin 3 is an input, rest are outputs. */
XGpio_SetDataDirection(&GpioP, PMOD_CHANNEL, 0x04);
//WritetoLEDs =0x01;
//for(i =1;i<8;i++){
//XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, WritetoLEDs);
// delay(ABOUT_ONE_SECOND/3);
// WritetoLEDs=(int)(1<<i);
// }
// printf("Ready to receive.\n \r");
//delay(10);
//XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0xFF);
// XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0x00);
// First, set the clock and data lines low, and the SS# line high
// GPIO[3:0] = {SCK, CLR#, MOSI, SS#} // default 'off' is 4'b0101 = 0x05
//delay(10);
uchPortWriteData = 0;
XGpio_DiscreteWrite(&GpioP, 1, uchPortWriteData); // The (1) means write to the only port (#1) on the uBlaze GPIO port
//delay(10);
// Wait until RDY# goes high
//uchPortReadData = XGpio_DiscreteRead(&GpioP,1);
uchPortReadData=0;
while((uchPortReadData & DATAREADY_high)==0x00) // keep looping while low
{
uchPortReadData = XGpio_DiscreteRead(&GpioP,1);
}
// Now, wait until RDY# goes low
uchPortReadData = XGpio_DiscreteRead(&GpioP,1);
while((uchPortReadData & DATAREADY_high)==DATAREADY_high)
{
uchPortReadData = XGpio_DiscreteRead(&GpioP,1);
}
for(i=15;i>=0;i--)
{
// Send clock high
uchPortWriteData |= CLOCK_on;
XGpio_DiscreteWrite(&GpioP, 1, uchPortWriteData);
// delay(10); // small delay, then read
uchPortReadData = XGpio_DiscreteRead(&GpioP,1);
//delay(10);
// Shift the GPIO read data to the lowest bit, mask off all the other bits, then shift i (15:0)
// number of bits to set the appropriate bit in the
if(((uchPortReadData >> 2) & 0x01)==0x01) // the serial bit is a one, set the bit
{
if(i==15)
adcValue = 0x8000; // extend the sign of the 2s complement number to bits 31..16, and set bit 15 = 1
else
adcValue |= (int)(1 << i); // bit shift
}
uchPortWriteData &= ~CLOCK_on;// Clock in data via negative edge
XGpio_DiscreteWrite(&GpioP, 1, uchPortWriteData);
// delay(10);
// XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, adcValue);
//printf("The Value %d \n \r", adcValue);
//storedValues[i]= adcValue;
}
// The 11205 device requires 25 clocks total to complete a read.
// We have already sent (16) clocks, so send 9 more clocks.
// (If self-calibration mode set then we send 10 more clocks.)
if(uchUseCalibrationMode==1)
nClockCount = 9;
else
nClockCount=9;
for(i=nClockCount;i>=0;i--)
{
// Send clock high
uchPortWriteData |= CLOCK_on;
XGpio_DiscreteWrite(&GpioP, 1, uchPortWriteData);
//delay(10); // small delay, then read
uchPortWriteData &= ~CLOCK_on;// Clock in data via negative edge
XGpio_DiscreteWrite(&GpioP, 1, uchPortWriteData);
//delay(10);
}
//printf("The ADC Value %d \n \r", adcValue);
//XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0x01);
// sleep(1);
// XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, 0x00);
//sleep(1);
return adcValue; /* Should be unreachable */
}
void delay(int nStopValue)
/**
* \brief Loop for nStopValue iterations to provide a delay.
* \par Details
* It is commonly used with the constant 'ABOUT_ONE_SECOND' defined in maximPMOD.h for
* setting approximate delays
*
* \param[in] nStopValue - number of iterations to loop
*
* \retval None
*/
{
int i=0;
int a=0;
for(i=0;i<nStopValue;i++)
{
a=i;
}
}
/* Main function. */
int main(void){
u32 storedValues[1000]={};
int Status;
int j=0;
while(j<1000){
/* Execute the LED output. */
storedValues[j] = LEDOutputExample();
//printf("The J Value %d \n \r", j );
// printf("The STORED Values %d \n \r", storedValues[j]);
j++;
}
int k;
printf("The ARRAY Values \n");
for(k=0; k<1000; k++)
{
printf("%d \n \r", storedValues[k]);
}
return 0;
}
(The computer crashed and the final code that we used was not completely saved so some changes may have to be made to this code.)
- The following MATLAB code is the code that we used to plot the data versus time and the FFT plot
close all
x = importdata('/home/zynquser/Documents/PMODTESTADC4')
%Even number of values in data file
t=linspace(0,228.5,1000);
X=[t' x];
figure(1)
xdft = fft(X(:,2));
% sampling interval -- assuming equal sampling
DT = X(2,1)-X(1,1);
% sampling frequency
Fs = 1/DT;
DF = Fs/size(X,1);
freq = 0:DF:Fs/2;
xdft = xdft(1:length(xdft)/2+1);
plot(freq,abs(xdft))
figure(2)
plot(t,x,'.')
axis([0 230 0 27000])
%Odd number of values in data file
% xdft = fft(X(:,2));
% % sampling interval -- assuming equal sampling
% DT = X(2,1)-X(1,1);
% % sampling frequency
% Fs = 1/DT;
% DF = Fs/size(X,1);
% freq = 0:DF:Fs/2;
% xdft = xdft(1:round(length(x)/2));
% plot(freq,abs(xdft),'.')
USING THE MAXIM11205 CHIP
The datasheets and user guide for this chip are below.
http://pdfserv.maximintegrated.com/en/an/UG5483.pdf (user guide)
http://datasheets.maximintegrated.com/en/ds/MAX11205.pdf
http://datasheets.maximintegrated.com/en/ds/MAX11205PMB1.pdf
The second page of the second datasheet that is listed has the chart listed below which tells that we will only use pins 3 and 4 when we connect to the Zedboard.
PIN SIGNAL DESCRIPTION
1 N.C. Not connected
2 N.C. Not connected
3 MISO
Data-ready output/serial-data output.
This output serves a dual function.
In addition to the serial-data output
function, the MISO pin also indicates
that the data is ready when it is pulled
logic-low by the IC. Output data
changes on the falling edge of SCLK.
4 SCK
2-wire serial clock. The host must apply
an external clock signal to shift data
out from the IC.
5 GND Ground
6 VCC Power supply
We made the following circuit that will allow us to offset the sine wave so that the wave will go from 0V to 2.8V.
The connecting this circuit to the max11205 chip and plugging the chip into the pmod on the Zedboard we were able to run the final code listed for SDK.
READING FROM THE TERMINAL - GTKTERM
The following link gives a three step process on how to install gtkterm.
http://pkgs.org/centos-6/epel-i386/gtkterm-0.99.5-11.el6.i686.rpm.html
In the first step, this link is provided:
http://dl.fedoraproject.org/pub/epel/6/i386/
Open the previous link and look for:
epel-release-6-8.noarch.rpm
Click on this link and it will download. Then in the downloads folder,
or at the bottom of your web browser, click the file to install it.
Then go to the terminal and type the following:
sudo yum install gtkterm
http://svenand.blogdrive.com/archive/173.html#.VWh9l9jbJ9A
At the beginning of the blog, it talks about permissions. Following these steps can help with that:
To check for the permissions, open a terminal and type:
cd ..
cd .. (to move all the way out)
cd dev (must be in this directory)
ls -l ttyAMC0 (checks the permission)
If the permission is not crw-rw-rw, then type:
sudo chmod 666 ttyACM0
Then we are able to follow the steps in Sven's blog.
After reading values in the terminal, we were able to save the data by doing file>save and then import that file into Matlab. Using the code listed above, we were able to plot the FFT.
SUCCESS!
NOTE: The following information and graphs are from Joe and we still have to test these ideas.
Change your plot from linear to semilog (and use points instead) :
semilogy(freq,abs(xdft),'.');
This results in a plot that looks like this:
Sometimes, the plot is a loglog plot and would result in this type of plot:
In signal processing, the plot is usually done in dB (where dB is 10 log10 P1/P2 for power and 20 log10 V1/V2 for voltage)
This plot has the Y axis as dB (YdB = 10*log10(abs(xdft)/max(abs( xdft(2:end)))); plot(freq(2:end),YdB(2:end),' .')):
Notice a couple of things in this plot:
1) There is a second peak at around -30dB that is not a harmonic (integer multiple) of the first peak.
2)
The noise floor is around -60dB volts (60dB is 10^3 = 1000 which means
that the effective resolution of the system is about 2^10 or a 10 bit
system)
No comments:
Post a Comment