EmbDev.net

Forum: FPGA, VHDL & Verilog GPS to FPGA to PC


von Yuniarto Wimbo N. (wimbo)


Rate this post
useful
not useful
Hello
i want send data NMEA from GPS to FPGA and from FPGA to PC, i'm using 
UART vhdl with 38400 baudrate.

i test uart with send n receive data, if i send data one alphabet 
example "a" or one number example "8" uart is work, but if i send data 
nmea from GPS like "$GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48" i cant 
receive it in my PC.

any help me please.
Thanks a lot.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Yuniarto Wimbo N. wrote:
> Hello i want send data NMEA from GPS to FPGA and from FPGA to PC, i'm
> using UART vhdl with 38400 baudrate.
Why the FPGA? I would connect the GPS directly to the PC...

> i test uart
Which one?

> i test uart with send n receive data, if i send data one alphabet
> example "a" or one number example "8" uart is work
How did you find that out?
And how did you test it?
Did you test this uart an a testbench in a simulator?

> but if i send data nmea from GPS like
> "$GPVTG,054.7,T,034.4,M,005.5,N,010.2,K*48" i cant receive it in my PC.
This somehow curios design seems to be extremely simple to me. In VHDL 
it will be somewhat like that:
1
  PCout  <= GPSin;
2
  GPSout <= PCin;

> any help me please.
Without knowing anything about your desgin, even not seeing one line of 
HDL, how should anyone be able to help?

von Achim S. (Guest)


Rate this post
useful
not useful
so a single character works, but a sequence of characters is not 
received? Does "not received" mean, that you get no data at all or do 
you receive scrambled data?

Maybe you send the individual characters of your NMEA-string too close 
to each other, so that there's not enough time for a stop-bit inbetween. 
Take a look to the bit-sequence with an oscilloscope and decode the 
first 2-3 characters manually, that may tell you what you have to fix.

von Yuniarto Wimbo N. (wimbo)


Rate this post
useful
not useful
>Why the FPGA? I would connect the GPS directly to the PC...
-because i want made autopilot system using FPGA

>How did you find that out?
>And how did you test it?
>Did you test this uart an a testbench in a simulator?
- i find result di my pc
- i test fpga to pc using

this is my uart
1
 TX Modul:
2
3
library ieee;
4
use ieee.std_logic_1164.all;
5
use ieee.std_logic_arith.all;
6
use ieee.std_logic_unsigned.all;
7
entity TX is
8
port(s_out:out std_logic;
9
    p_in:in std_logic_vector(7 downto 0);
10
    go:in std_logic;
11
    clk:in std_logic);
12
end TX;
13
14
architecture UARTtx of TX is
15
signal clk9600:std_logic:='0';
16
begin
17
  process(clk)
18
  variable count:integer range 0 to 1300:=0;
19
  begin
20
    if clk='1' and clk'event then 
21
      if count>=650 then count:=0;clk9600<=not clk9600;
22
      else count:=count+1;
23
      end if;
24
    end if;
25
  end process;
26
  process(clk9600,go,p_in)
27
  variable cnt:integer range -2 to 90:=0;
28
  variable buf:std_logic_vector(9 downto 0):="1010000010";
29
  variable stop:std_logic;
30
  begin
31
    if clk9600='1' and clk9600'event then 
32
      if go='1' then
33
        buf(8 downto 1):=p_in;
34
        if cnt=0 then s_out<='0';cnt:=1;
35
        elsif cnt=1 then s_out<=p_in(0);cnt:=2;
36
        elsif cnt=2 then s_out<=p_in(1);cnt:=3;
37
        elsif cnt=3 then s_out<=p_in(2);cnt:=4;
38
        elsif cnt=4 then s_out<=p_in(3);cnt:=5;
39
        elsif cnt=5 then s_out<=p_in(4);cnt:=6;
40
        elsif cnt=6 then s_out<=p_in(5);cnt:=7;
41
        elsif cnt=7 then s_out<=p_in(6);cnt:=8;
42
        elsif cnt=8 then s_out<=p_in(7);cnt:=9;
43
        elsif cnt=9 then s_out<='1';
44
        end if;
45
      else cnt:=0;
46
      end if;
47
    end if;
48
  end process;
49
end UARTtx;
50
51
52
RX Modul:
53
54
library ieee;
55
use ieee.std_logic_1164.all;
56
use ieee.std_logic_arith.all;
57
use ieee.std_logic_unsigned.all;
58
entity RX is
59
port(s_in:in std_logic;
60
    p_out:out std_logic_vector(7 downto 0):=X"00";
61
    clk:in std_logic);
62
end RX;
63
architecture UARTs of RX is
64
signal cnt:integer range 0 to 25:=0;
65
signal buff:std_logic_vector(7 downto 0):=X"00";
66
signal start:std_logic:='0';
67
signal clk9600:std_logic:='0';
68
begin
69
  process(clk)
70
  variable count:integer range 0 to 1300:=0;
71
  begin
72
    if clk='1' and clk'event then 
73
      if count>=650 then count:=0;clk9600<=not clk9600;
74
      else count:=count+1;
75
      end if;
76
    end if;
77
  end process;
78
  process(s_in,clk9600,cnt)  
79
  begin
80
    if clk9600='0' and clk9600'event then 
81
      if cnt>=9 and s_in='1' then cnt<=0;
82
      --if cnt>=9 and s_in='0' then cnt<=0;
83
      elsif start='1' and cnt<=20 then cnt<=cnt+1;
84
      end if;
85
    end if;
86
    
87
    if s_in='0' and cnt=0 then start<='1';
88
    elsif cnt>=9 and s_in='1' then start<='0';
89
    --elsif cnt>=9 and s_in='0' then start<='0';
90
    end if;  
91
  end process;
92
  process(s_in,cnt,clk9600)  
93
  begin
94
    if cnt>=1 and cnt<=8 and clk9600='1' then
95
      buff(cnt-1)<=s_in;
96
    end if;    
97
  end process;
98
  p_out<=buff when start='0';  
99
  --p_out<=X"F0";
100
end UARTs;

: Edited by Moderator
von Yuniarto Wimbo N. (wimbo)


Rate this post
useful
not useful
>so a single character works, but a sequence of characters is not
>received? Does "not received" mean, that you get no data at all or do
>you receive scrambled data?

>Maybe you send the individual characters of your NMEA-string too close
>to each other, so that there's not enough time for a stop-bit inbetween.
>Take a look to the bit-sequence with an oscilloscope and decode the
>first 2-3 characters manually, that may tell you what you have to fix.

yes you true, i have receive scramble data, and data not constants per 
second

: Edited by User
von Achim S. (Guest)


Rate this post
useful
not useful
ok, some problems to start with:

- you use a logic signal (clk9600) as a clock. Don't do that. Take the 
real clock clk instead to toggle your registers and use a Clock-Enable 
to define the baudrate.

- for your transmitter I see a shift-register, but I do not yet see a 
UART yet. E.g. your code will only give you a correct sequence when the 
signal "go" is 1 for exactly 10 bittimes. How is the signal "go" 
controlled? If if toggles back to 0 to early, the remaining bits are 
skipped. If it toggles to 0 to late, the transmission is restarted.

- in your receiver you use a latch to store incoming data. Don't do 
that: work with registers. Furthermore the moment, when you finally 
store the data to buff, is not fixed to the middle of the bit-time. The 
clk9600 of the receiver must somehow be synchronized to the begin of the 
startbit.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Attached files:

Rate this post
useful
not useful
Yuniarto Wimbo N. wrote:
> this is my uart
1. See the screenshot.
2. Read it and understand it.
2. Do it.


There are too much signals in the sensitivity list:
>   process(clk9600,go,p_in)
clk9600 would be enough.
But: clk9600 ist NOT a clock, is is just a simple clock enable...

> i have receive scramble data, and data not constants per second
As I saw that code my first thought was: Ouch!

You MUST implement a test bench an check your design on that test bench. 
Then you can see that whole bunch of tricky race conditions in your 
code. One is e.g. the sampling point of the incoming RS232 signal.

At the last link there you can find a test bench:
http://www.lothar-miller.de/s9y/archives/60-RS232-IO.html#extended
And also look there:
http://www.lothar-miller.de/s9y/categories/42-RS232
(Try Google translator, its German...)

: Edited by Moderator
von Yuniarto Wimbo N. (wimbo)


Rate this post
useful
not useful
>Achim S. (Guest)
(clk9600) is just name only not value baudrate. :D
thanks a lot for your guide, ok i want correct my programming again.
:D

von Yuniarto Wimbo N. (wimbo)


Rate this post
useful
not useful
> Lothar Miller
i'm sorry about my post :) please forgive me about it.

ok i'll implement uart vhdl programming in testbench.

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Yuniarto Wimbo N. wrote:
> (clk9600) is just name only
But you use it as a clock, because everything using a 'event or a 
rising_edge() or a falling_edge() is a clock...  :-o

Some simple rules for beginners:
- only 1 clock in the whole design (thats usually around 10..100MHz)
- external signals must be synced to that clock before using them
- no variables, or at the very least no memorizing variables
- no latches (read the synthesizers warnings!)

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.