• 0
Sign in to follow this  
shrestha

Pmodad1/resistive Touch Screen/nexys3

Question

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!!!

Edited by Josh
Added Tags

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0

I managed to get hold of a PMOD_AD1 and have been playing around with it.

 

Here is a VHDL module that reads both channels, and presents the data values. It is based on using a 100MHz clock, and presents a sample every 66*2 = 132 cycles (or 1.32us), or 757kHz, You can adjust the length of the shift registers if you need to sample at a given rate - e.g. make them 100 bits long and samples will be taken at 500kHz.

 

Although the output ports are 16 bits wide, only the lower 12 should contain data from the ADC (in decimal 0-4095) - the upper four bits should be zero.

 

PS. Oh, and sorry if it looks a little bit crufty - it was just the path of least resistance to make it work

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
 
entity pmod_ad1 is
    Port ( clk100     : in  STD_LOGIC;
           pmod_cs    : out STD_LOGIC;
           pmod_clk   : out STD_LOGIC;
           pmod_data1 : in  STD_LOGIC;
           pmod_data2 : in  STD_LOGIC;
           data_ch1   : out STD_LOGIC_VECTOR(15 downto 0);
           data_ch2   : out STD_LOGIC_VECTOR(15 downto 0);
           data_new   : out STD_LOGIC
       );
end pmod_ad1;
 
architecture Behavioral of pmod_ad1 is
    signal cs_sr       : STD_LOGIC_VECTOR(65 downto 0) :=  "100000000000000000000000000000000000000000000000000000000000000001";
    signal clk_sr      : STD_LOGIC_VECTOR(65 downto 0) :=  "110011001100110011001100110011001100110011001100110011001100110011";
    signal data1_sr    : STD_LOGIC_VECTOR(15 downto 0) := (others => '0');
    signal data2_sr    : STD_LOGIC_VECTOR(15 downto 0) := (others => '0');
    signal every_other : STD_LOGIC := '0';
begin
 
process(clk100) 
    begin
        if rising_edge(clk100) then
            if every_other = '1' then
                if cs_sr(cs_sr'high) = '1' and cs_sr(0) = '0' then
                    data_ch1 <= data1_sr;
                    data_ch2 <= data2_sr;
                    data_new <= '1';
                else
                    data_new <= '0';
                end if; 
                
                if clk_sr(clk_sr'high) = '1' and clk_sr(1 downto 0) = "01" then
                    data1_sr <= data1_sr(data1_sr'high-1 downto 0) & pmod_data1;
                    data2_sr <= data2_sr(data2_sr'high-1 downto 0) & pmod_data2;
                end if;
                pmod_cs  <= cs_sr(cs_sr'high);
                pmod_clk <= clk_sr(clk_sr'high);
                cs_sr    <= cs_sr (cs_sr'high-1  downto 0) & cs_sr (cs_sr'high);
                clk_sr   <= clk_sr(clk_sr'high-1 downto 0) & clk_sr(clk_sr'high);
            end if;
            every_other <= not every_other;        
        end if;
    end process;
end Behavioral;

Share this post


Link to post
Share on other sites
  • 0

Hi shrestha,

 

Which 4-wire resistive touch screen are you using? Is it Digilent's VmodTFT? If it is the VmodTFT, is it a requirement that you have the touch screen information passing through a Pmod before being processed by the FPGA?

 

Thanks,

 

JColvin

Share this post


Link to post
Share on other sites
  • 0

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?

Share this post


Link to post
Share on other sites
  • 0

Hi shrestha,

 

I have personally have not used the FTAS00-57AS4 before, but yes you would be able to convert the outcoming signals from the touch screen to digital signals through the PmodAD1. The only potential issue that I see with using the PmodAD1 is that this particular Pmod only has two analog inputs, so you would need to use two PmodAD1s in order to collect all four analog data lines from the the touch screen.

 

What might be easier (in my opinion) would be to use a different module that is capable of collecting four different analog inputs by itself such as the PmodAD2 or the PmodAD5. The potential drawback with using these modules though is that each of the four analog inputs would be converted to a set of digital signals one at a time as opposed to all of them being converted simultaneously. This will inevitably introduce a small time delay between each of the data samples taken so that there is a chance that your finger or whatever is touching the screen has moved since the last acquisition of data.

 

However, this time delay would be at the largest extreme would be less than 1 millisecond from the first to the last data chunk out of the four sets and most likely far less time, so it would depend on your application for how concerned you are about this time difference between reading your four analog wires. Two PmodAD1's on the other hand could collect and convert all four analog signals simultaneously.

 

In terms of interfacing the Pmod with the Nexys3, you would need to provide the Chip Select line and the Serial Clock signal to the Pmod so that each of the 12 data bits are correctly clocked out of the with the first 4 bits acting as leading zeroes and the remaining 12 bits as the 12 bits of digital data, as per the AD7476A by Analog Devices that is present on the PmodAD1.

 

The last bit, which I do not know the answer to, is that you would need to have a way to convert the bits of digital data coming into the Nexys3 into the x and y coordinates representing the screen is being touched.

 

Let me know if you have any more questions.

 

Thanks,

JColvin

Share this post


Link to post
Share on other sites
  • 0

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.

 

Share this post


Link to post
Share on other sites
  • 0

If two of the wires need to be driven high or low in order to measure a coordinate direction, then no, there is not a way that you could measure the Y+ voltage and the X+ voltage simultaneously from your 4-wire display.

 

The Pmods themselves do not need to receive any special coding; all they need is the analog voltage signal coming from one of the four wires and could theoretically be able to collect the Y+ voltage and the X+ voltage within 1 us of each other.

 

The only potential issue that I can see (I don't know if you have addressed it already) is having the FPGA set an input reading your Y+ line, but a different FPGA line as an output powering the Y+ line when you are reading the X+, potentially creating a short circuit. I am not an FPGA expert, but there may be a way to set FPGA inputs to a high impedance state to help avoid any problems.

 

Let me know if you have any more questions.

 

Thanks,

JColvin

Share this post


Link to post
Share on other sites
  • 0

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!!!!

Share this post


Link to post
Share on other sites
  • 0

Hi shrestha,

 

I'm doing well. From what I remember of creating a PID controller it will certainly be easier with just one sensor, but presuming you are balancing a ball on a some sort of platform where you can rotate the board on two different axis' (e.g. the x and y directions), then I would recommend using two sensors with one lined up along one axis and the other lined up along the other axis.

 

As for interfacing the PmodAD1 with the Nexys 3, I am personally not very familiar with VHDL or Verilog, but there are examples at the bottom of the Nexys 3 product page that demonstrate how you might implement SPI (in Verilog or VHDL) onto the Nexys 3 with the PmodACL and PmodJSTK demos.  There is also another forum post that explains how you might implement SPI onto an FPGA in VHDL

 

Let me know if you have any more questions.

 

Thanks,

JColvin

Share this post


Link to post
Share on other sites
  • 0

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;

}

 

 

 

Share this post


Link to post
Share on other sites
  • 0

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.

Share this post


Link to post
Share on other sites
  • 0

Hi shrestha,

 

Most servo motors (at least hobby servo motors) don't have any sort of feedback mechanism, so unless you implemented external feedback that lets you know how far the servo motor has rotated, you would not really be able to implement any PID control (at least from my understanding).

 

Servo motors themselves utilize PWM pulses that typically last between 1 ms and 2 ms to rotate the motor between fully left and fully right with 1.5 ms acting as the middle rotation angle. These pulses (of positive voltage) tend to be sent out 30 - 60 times a second (every ~33 to ~16 milliseconds, respectively) in order to keep the servo motor in that location. More information on this is available in the reference manual of the PmodCON3 on our wiki page, as well as at the bottom of the product page for the PmodCON3

 

I am personally not familiar with FPGAs and have not used the Helloworld, SDK, so I am unfortunately not going to be able to help you in that regard.

 

Let me know if you have any more questions.

 

Thanks,

JColvin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this