shrestha

Members
  • Content Count

    15
  • Joined

  • Last visited

  1. thanks Jcolvin, cristain.. I will give a shot.
  2. thats link does not work anymore. Do you have other reference?
  3. does anybody know how to code PID controller? help will be appreciated?
  4. shrestha

    Basys �

    Hey guys, is there any way you can control motor in both ways just with signal. I have done motor control both direction using switches form nexys 3 board. But I need to control motor automatic. we are making a ball balancing system using motor. help will be appreciated. suggestion on C - language , we are using SDK?
  5. shrestha

    Nexys 3/ PWM

    Thank you for your help. i don't understand verilog. we are using SDK. The program i posted above is in C. We are using two timers to control PWM. We are getting analog data from IR sensor.
  6. shrestha

    Nexys 3/ PWM

    #define Port0_DATA *(volatile int*) (XPAR_XPS_GPIO_0_BASEADDR) #define Port0_DIRECTION *(volatile int*) (XPAR_XPS_GPIO_0_BASEADDR+0x04) #define Port1_DATA *(volatile int*)(XPAR_XPS_GPIO_1_BASEADDR) #define Port1_DIRECTION *(volatile int*)(XPAR_XPS_GPIO_1_BASEADDR+4) #define Port2_DATA *(volatile int*) (XPAR_XPS_GPIO_2_BASEADDR) #define Port2_DIRECTION *(volatile int*) (XPAR_XPS_GPIO_2_BASEADDR+0x04) #define Port2_GIER *(volatile int*) (XPAR_XPS_GPIO_2_BASEADDR+0x11C) #define Port2_IPIER *(volatile int*) (XPAR_XPS_GPIO_2_BASEADDR+0x128) #define Port2_IPISR *(volatile int*) (XPAR_XPS_GPIO_2_BASEADDR+0x120) #define SEVEN_SEG_DATA *(volatile int*)(XPAR_DIGILENT_SEVSEG_DISP_BASEADDR) #define LEDS_DATA *(volatile int*)(XPAR_LEDS_8BITS_BASEADDR) #define LED_DIRECTION *(volatile int*)(XPAR_LEDS_8BITS_BASEADDR+4) #define SWITCH_DATA *(volatile int*)(XPAR_DIP_SWITCHES_8BITS_BASEADDR) #define SWITCH_DIRECTION *(volatile int*)(XPAR_DIP_SWITCHES_8BITS_BASEADDR+4) #define INT_ISR *(volatile int*)(XPAR_INTC_0_BASEADDR) #define INT_IPR *(volatile int*)(XPAR_INTC_0_BASEADDR+0x4) #define INT_IER *(volatile int*)(XPAR_INTC_0_BASEADDR+0x8) #define INT_IAR *(volatile int*)(XPAR_INTC_0_BASEADDR+0xC) #define INT_MER *(volatile int*)(XPAR_INTC_0_BASEADDR+0x1C) #define XPS_UART_RX_FIFO *(volatile*)(XPAR_XPS_UARTLITE_0_BASEADDR) #define XPS_UART_TX_FIFO *(volatile*)(XPAR_XPS_UARTLITE_0_BASEADDR+0x04) #define XPS_UART_STATUS *(volatile*)(XPAR_XPS_UARTLITE_0_BASEADDR+0x08) #define TIMER00_CSR *(volatile int*)(XPAR_XPS_TIMER_0_BASEADDR) #define TIMER00_LOAD *(volatile int*)(XPAR_XPS_TIMER_0_BASEADDR+0x04) #define TIMER01_CSR *(volatile int*)(XPAR_XPS_TIMER_0_BASEADDR+0x10) #define TIMER01_LOAD *(volatile int*)(XPAR_XPS_TIMER_0_BASEADDR+0x14) #define TIMER10_CSR *(volatile int*)(XPAR_XPS_TIMER_1_BASEADDR) #define TIMER10_LOAD *(volatile int*)(XPAR_XPS_TIMER_1_BASEADDR+0x04) #define TIMER11_CSR *(volatile int*)(XPAR_XPS_TIMER_1_BASEADDR+0x10) #define TIMER11_LOAD *(volatile int*)(XPAR_XPS_TIMER_1_BASEADDR+0x14) #define INT_ISR *(volatile int*)(XPAR_INTC_0_BASEADDR) #define INT_IPR *(volatile int*)(XPAR_INTC_0_BASEADDR+0x4) #define INT_IER *(volatile int*)(XPAR_INTC_0_BASEADDR+0x8) #define INT_IAR *(volatile int*)(XPAR_INTC_0_BASEADDR+0xC) #define INT_MER *(volatile int*)(XPAR_INTC_0_BASEADDR+0x1C) #define ATOD_TRIGGER *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR) #define ATOD_DONE *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR+0x04) #define ATOD_DATA0 *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR+0x08) #define ATOD_DATA1 *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR+0x0C) #define count 10 //input how many increments to count //define variables int sum =0; int array[count]; //define array[count] int counter =0; unsigned int average; unsigned short data0; unsigned short counter0; unsigned short counter1; unsigned short counterLED; unsigned short timerflag; unsigned short direction; void print (char*str); unsigned short data0; char Get_Character(void); void Put_Character(char ch); void Put_String(char *string); void delay_ms(unsigned short delay_time); void delay_us(unsigned short delay_time); int counter3; void microblaze_0_Interrupt(void)__attribute__((interrupt_handler)); void microblaze_0_Interrupt(void){ int tmp; tmp=INT_IPR; if(tmp&XPAR_XPS_GPIO_2_IP2INTC_IRPT_MASK){//interrupt for port2 if(direction==1){//if clockwise counter++;}//increment counter else{//if counterclockwise counter--;}//decrement counter Port2_IPISR=Port2_IPISR; //clear port 2 interrupt } if(tmp&XPAR_XPS_TIMER_1_INTERRUPT_MASK){//interrupt for timer00 timerflag=1;//set timerflag to 1 counterLED++; if (counterLED==500){ counter3++; } TIMER10_CSR=TIMER10_CSR; //clear timer 1 interrupt } INT_IAR=tmp; } int main() { init_platform(); counter=0; //initialize counter counter3=0; timerflag=0;//initialize timer0flag direction = 0; //initialize direction Port2_GIER = 0x80000000; Port2_IPIER = 0x01; ATOD_TRIGGER = 0x01; TIMER00_LOAD=2900; //timer00 PWM values TIMER01_LOAD=400; //timer01 PWN values TIMER00_CSR = 0x696;//pwm mode TIMER01_CSR = 0x696;//pwm mode TIMER10_LOAD=75000000/50; //changes the frequency(500Hz) TIMER10_CSR = 0x4F6;//set time10 TIMER10_CSR = 0x4D6; init_platform(); while(1){ if (counter<count){ ATOD_TRIGGER = 0x01; while(ATOD_DONE!=0x01){ } data0=ATOD_DATA0; //read data0 and save it array[counter] = data0; //save data0 as an array sum=sum+array[counter]; //sum is itself plus data0 counter++; //increment counter TIMER01_LOAD=ATOD_DATA0; //Print Data0 to Serial Monitor xil_printf("1st data = %d r", data0); ATOD_TRIGGER=0x00; //reset A/D converter } if (counter==count){ counter=0; average = sum/count; //average //Print Data0 and Average to Serial Monitor xil_printf("1st data = %d 2nd data = %d r", data0, average); sum=0; //reset sum average=0; //reset average } } return 0; } void delay_us(unsigned short delay_time){ short i; for(;delay_time>0;delay_time--){ for(i=0;i<5;i++){ } } } char Get_Character(){ #define RX_FIFO_VALID_DATA 0x01 unsigned int status; unsigned char ch; status = 0x00; status = XPS_UART_STATUS & RX_FIFO_VALID_DATA; while(status != RX_FIFO_VALID_DATA){ status = XPS_UART_STATUS & RX_FIFO_VALID_DATA; } ch=XPS_UART_RX_FIFO; return ch; } void Put_Character(char ch){ #define TX_FIFO_FULL 0x08 int status; status = 0x00; status = XPS_UART_STATUS & TX_FIFO_FULL; while(status == TX_FIFO_FULL){ status = XPS_UART_STATUS & TX_FIFO_FULL; } XPS_UART_TX_FIFO = ch; return; } void Put_String(char*string){ char ch; while(1){ ch = *string; if (ch == 0x00){ return; }else{ Put_Character(ch); string++; } } } ​here is some code i tried. we are getting analog value form IR sensor which was in range of 400-2900.
  7. shrestha

    Nexys 3/ PWM

    i don't have any resource available to me other than online. I don't have o'scope but if required i can ask to my professor.i have multimeter. And yes we are using SDK . I don't understand VHDL.
  8. shrestha

    Nexys 3/ PWM

    Hey JColvin, i have done the motor and it works but servos works different than motor. I don't really know how to implement it? what i understood is servo has pulse width of 1 ms to 2ms, 1ms far left , 1.5 ms middle and 2ms far right. Its pulse occur after every 20ms.so can i implement this?
  9. shrestha

    Nexys 3/ PWM

    hello all, I am doing small class project. I would really appreciate if any one can help me with this. we are using SDK and we are trying to control servo which require PWM signal. I don't know how to generate PWM signal to control servo. I know it require two timers to do it. Thanks!!!
  10. Hi , we got the data coming in form sensor and we able to filter it out. we want to moves servos and code PID. How can we control servos. reference of code would be helpful.
  11. Thank you!!! we are using Helloworld, SDK to program. Here is one I have so far . Does this work? Can you suggest me if i have to change anything. #include <stdio.h> #include "platform.h" #include "xparameters.h" #include <stdio.h> #define Trigger *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR) #define Done *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR+0x04) #define Data0 *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR+0x08) #define Data1 *(volatile int*)(XPAR_PMOD_AD1_0_BASEADDR+0x0c) #include <stdio.h> #include "platform.h" #include "xparameters.h" void print(char *str); unsigned short data0 ; unsigned short data1 ; int main() { #define input 0x01 init_platform(); // Enable caches while(1){ Trigger=0x01; unsigned short status; status=0x00; status= Done&input; while(status!=input){ status= Done&input; } data0=Data0; data1=Data1; xil_printf("data0=%d,data1=%dr",data0,data1) ; Trigger=0x00; } cleanup_platform(); return 0; }
  12. Hey how are you? we changed our idea to sensor. we will be using proximity sensors which will give us analog voltage. we wanted to convert that using PMOD AD1 on Nexys 3 board. we wanted to balance ball on beam using this sensors, nexys 3 and will be building PID controller later. do you think we need to sensors on both sides? how an we convert that analog using PMOD AD1 to nexys? thanks!!!!
  13. I have two PmodAD1. The problem now is actually on reading voltage from touch screen, code it and send it to Pmods. The x and y coordinates of a touch on a 4-wire touch screen can be read in two steps. First, Y+ is driven high, Y– is driven to ground, and the voltage at X+ is measured. The ratio of this measured voltage to the drive voltage applied is equal to the ratio of the y coordinate to the height of the touch screen. The y coordinate can be calculated. The x coordinate can be similarly obtained by driving X+ high, driving X– to ground, and measuring the voltage at Y+. The ratio of this measured voltage to the drive voltage applied is equal to the ratio of the x coordinate to the width of the touch screen. This is how 4 wire touch screen works. The problem we have now is if we wanted to read voltage on Y+ while at same time we will have to driven Y+ by source too. same thing for x. is there any way this can be done.
  14. we are using FTAS00-57AS4 touch screen manufactured by NKK. It is analog so we wanted to convert to digital using PmodAD1 and we read digital data on nexys3. Thats how we trying to do it. is there any easier way to do this or how actually we do by this way? thank you?
  15. hi, we are trying to read data from 4 wire resistive touch screen. can any one help us figuring this out? We have the voltage reading from touch screen, we don't know exactly how we code that reading to Pmode and implement it to nexys3. help will be appreciate!!!