Home    Bloggers    Messages    Webinars    Resources   
Tw  |  Fb  |  In  |  Rss
Duane Benson

Discovering FPGAs: Playing With LEDs & Switches

Duane Benson
Page 1 / 2 Next >
Brian
Brian
7/23/2012 5:21:28 PM
User Rank
Guru
Excellent post!
 

Hi Duane,

Excellent post (as usual)!

Re: "because non-descriptive names kind of drive me nuts"

I am 100% with you on that statement!

Re: "(you see -- now I can just say "LEDs," instead of spelling out the acronym, and not get confused)"

In the sentence above, I think you meant to say can't just say...

Re: "but is this all starting to make sense?"

Yuuup!  I am still following you perfectly and I don't even have the Spartan-6 LX9 development board.  :-)  Your photos and screen shots make it very easy to follow.

Can't wait until the next installment...

 

50%
50%
Max Maxfield
Max Maxfield
7/23/2012 5:30:58 PM
User Rank
Blogger
Re: Excellent post!
@Brian: Actually, I think Duane meant what he said ... now he can just say "LEDs" when he wants to use that in a sentence without it being confused with "LEDS" as a signal name ... but I may be wrong :-)

50%
50%
Brian
Brian
7/23/2012 5:34:57 PM
User Rank
Guru
Re: Excellent post!
 

@Max: I doubt it because it would still be a 'non-descriptive name'.

If so, then I sit corrected :-)

 

50%
50%
Max Maxfield
Max Maxfield
7/23/2012 5:38:46 PM
User Rank
Blogger
Re: Excellent post!
@Brian: I think we will have to ask Duane to elucidate :-)

50%
50%
Duane Benson
Duane Benson
7/23/2012 5:44:56 PM
User Rank
Blogger
Re: Excellent post!
Thanks! I'm glad you like the post.

I think the confusion surrounding my wording in the sentence: "now I can just say 'LEDs,' instead of spelling out the acronym" pretty much makes my point about the confusion. I suppose I should have said something more like: "now rather than spelling out the word 'light emitting diode', I can use the acronym 'LED' to refer to the physical component."

50%
50%
Brian
Brian
7/23/2012 5:40:59 PM
User Rank
Guru
Re: Excellent post!
 

@Max, Duane: Oops, I do sit corrected.

I am sorry - I just re-read the context and he probably did mean what he said. 

(I was thinking he meant - see, I can't just say LEDs now because it is used in multiple places, so it needs a more descriptive name.)

Again, sorry.

 

50%
50%
Max Maxfield
Max Maxfield
7/24/2012 9:34:48 AM
User Rank
Blogger
Re: Excellent post!
@Brian: "I just re-read the context and he probably did mean what he said."

Go figure -- what are the odds? (grin)

Actually, when I think of the hundreds of typos you've found in all my postings, I think this is the first one you got wrong (he he he)

50%
50%
Bill White
Bill White
7/23/2012 10:24:38 PM
User Rank
Expert
Re: Excellent post!
@Duane Benson, your posts are really helping me along with FPGA basics.

2 questions (wishes, perhaps):

1) Is there a way to magnify the text graphics so text is more easily readable?

2) Actually addressing this to Xilinx, is there anyway to lower the cost of a Spartan 6 LX-9 for members so as to actually be able to replicate Duane's blogs at hand?

@Brian, as you say, this is understandable without the board and for that I am grateful.  Having a board to work with, though, greatly increases my comprehension and retained memory.  Guess it is just the way I learn.

Keep up the great work Duane!

50%
50%
Brian
Brian
7/24/2012 12:09:26 AM
User Rank
Guru
Re: Excellent post!
 

@Bill: Re: "2) Actually addressing this to Xilinx"

I think your question might need to be addressed to Avnet.  According to the website, the Xilinx Spartan-6 FPGA LX9 MicroBoard is designed by Avnet.  And, it is also sold by Avnet.



 

50%
50%
Bill White
Bill White
7/24/2012 12:38:35 AM
User Rank
Expert
Re: Excellent post!
@Brian, thank you kindly; you are correct--the Avnet route is the way to pursue this.  I can no way represent speaking for APP, but it is worth it to put in a request.  Thanks for the info!

50%
50%
Brian
Brian
7/24/2012 12:45:30 AM
User Rank
Guru
Re: Excellent post!
 

@Bill: welcome.  I bet Max either knows someone at Avnet or knows someone who knows someone at Avnet :-)  We'll have to wait for Max's response to your request...

 

50%
50%
Bill White
Bill White
7/24/2012 12:48:32 AM
User Rank
Expert
Re: Excellent post!
Spot on with that idea--I'll wait for Max's thoughts.  Thanks for corresponding!

50%
50%
Max Maxfield
Max Maxfield
7/24/2012 9:43:03 AM
User Rank
Blogger
Re: Excellent post!
@Bill: Re the text on the graphics -- that's my bad -- Duane gave me full-size images and I shrank them to fit in the space provided -- and to save time I didn't bother uploading the full-size versions to my server and linking to them (obviously I ended up not saving myself any time at all -- grin).

It's too late to go back to change the article, but here are links to the full-size versions of the two images:

http://bit.ly/OWmqsz

http://bit.ly/PEdq04

 

50%
50%
Max Maxfield
Max Maxfield
7/24/2012 9:45:10 AM
User Rank
Blogger
Re: Excellent post!
@Bill: I agree that having the board really does help the leading process -- I think these boards are $89 -- I have no idea if we can get a special deal for members of All Programmable Planet, but I can certainly ask :-)

50%
50%
Paul Clarke
Paul Clarke
7/24/2012 8:49:56 AM
User Rank
Blogger
UCF file
Great post!

I have a question about the UCF file however. So far I've only used it to map pin locations in ISE. Comming from 'other' tools I've set clock speeds etc via the GUI as part of the project.

I'd be intrested to see one of Max's spin off posts telling us more about the 'stuff' in a UCF file. Like setting the clock speeds, types of IO, pull ups or pull downs etc.

I had a look following your post at the Xilinx UCF documention and its quite heavy, would be nice to see a 'All you need to know' summary for people comming into FPGAs.

Ta - Paul :o)

50%
50%
Duane Benson
Duane Benson
7/24/2012 1:45:14 PM
User Rank
Blogger
Re: UCF file
Paul - That's a good idea. I'm pretty much through my run through getting the basics going so now might be a very good time to go back, fill in a few blanks and get a better understanding of some of the things I just glossed over. I'll try and incorporate this into one or more future blogs.

I recently bought and started playing with the Papilio FPGA board that Max wrote about. I've gotten my simple Spartan 6 examples to work on it (It uses a Spartan 3E). I think some of the differences between the two boards will help me to gain a better undestanding of some of the things you're asking for more information on.

50%
50%
Duane Benson
Duane Benson
7/24/2012 4:29:52 PM
User Rank
Blogger
Re: UCF file
And Paul, if there are some specific items you'd like more clarification on, pass those along and one way or another, we'll get them clarified.

50%
50%
Adam Taylor
Adam Taylor
7/24/2012 3:20:57 PM
User Rank
Blogger
Re: UCF file
Paul, I second this a blog on the details of the UCF file coule be very useful for people new to FPGA's 

100%
0%
SimonC
SimonC
7/25/2012 6:27:23 AM
User Rank
Beginner
fpga to 16-character x2-line LCD (vhdl)
hello,

I am new to FPGA programming and have succesfully completed the programming with the switches and the LEDS, but now I want to try something more difficult. I have a xilinx virtex 5 ml507 education platform and there is a 16-character x2-line LCD on the board. I have found some information about these LCD's on: http://www.xilinx.com/support/documentation/boards_and_kits/ug230.pdf and I have written my vhdl code (see below). There are no errors in the code itself but when I program it into the fpga, it does not display my message, the LCD screen only tells what it always tells: "choose demo <-+-> 1. slideshow. " Somehow the code doesn't seem to work, could someone give me a little help with this?

many thanks in advance,

Simon

This is the code I wrote:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


entity circuit1 is
    Port ( clk : in  STD_LOGIC; -- 33 MHz clock input
           e : out  STD_LOGIC;
           rs : out  STD_LOGIC;
           rw : out  STD_LOGIC;
           a : out  STD_LOGIC;
     b : out  STD_LOGIC;
     c : out  STD_LOGIC;
     d : out  STD_LOGIC);
end circuit1;

architecture Behavioral of circuit1 is
signal code : STD_LOGIC_VECTOR(5 downto 0);

signal co : STD_LOGIC;

begin

process(clk)
variable initial : STD_LOGIC := '0';
variable counter : integer range 0 to 21 := 0;
begin
 if (clk'EVENT) and (clk = '1') then
  counter := counter + 1 ;
 end if;
   
 


case counter is

-- power on
when 0 =>
--e <= '1';
code <= "000011";
when 1 =>
--e <= '1';
code <= "000011";
when 2 =>
--e <= '1';
code <= "000011";
when 3 =>
--e <= '1';
code <= "000010";

-- set
when 4 =>
--e <= '1';
code <= "000010";
when 5 =>
--e <= '1';
code <= "001000";
-- entry mode
when 6 =>
--e <= '1';
code <= "000000";
when 7 =>
--e <= '1';
code <= "000110";

-- display on/off
when 8 =>
--e <= '1';
code <= "000000";
when 9 =>
--e <= '1';
code <= "001100";

-- clear display
when 10 =>
--e <= '1';
code <= "000000";
when 11 =>
--e <= '1';
code <= "000001";

-- character input
when 12 =>         -- h
code <= "100100";
--e <= '1';
when 13 =>
code <= "101000";
--e <= '1';
when 14 =>         -- e
code <= "100110";
--e <= '1';
when 15 =>
code <= "100101";
--e <= '1';
when 16 =>         -- l
code <= "100110";
--e <= '1';
when 17 =>
code <= "101100";
--e <= '1';
when 18 =>         -- l
code <= "100110";
--e <= '1';
when 19 =>
code <= "101100";
--e <= '1';
when 20 =>         -- 0
code <= "100110";
--e <= '1';
when 21 =>        
code <= "101111";

end case;
end process;

 


lol: process(clk) -- dit process concurrent met vorige
variable prescaler: integer range 0 to 55999999 := 0; -- with 33 MHz to create 2 s switch  from co = '0' to '1' and from '1' to '0'
begin
 if rising_edge(clk) then
  if prescaler < 55999999 then
   prescaler := prescaler +1;
 else
  prescaler := 0;
  co <= not(co);
 end if;
end if; 
end process;

--output, concurrent with the other processes
e <= co;
rs <= code(0);
rw <= code(1);
a <= code(2);
b <= code(3);
c <= code(4);
d <= code(5);

end Behavioral;

50%
50%
Adam Taylor
Adam Taylor
7/25/2012 8:53:51 AM
User Rank
Blogger
Re: fpga to 16-character x2-line LCD (vhdl)
@SimonC did you simulate this code ? There are numerous errors which will ensure it does not function quite as you expected.

50%
50%
SimonC
SimonC
7/25/2012 9:00:58 AM
User Rank
Beginner
Re: fpga to 16-character x2-line LCD (vhdl)
Yeah, I did.

This confirms i'm quite new to FPGA programming and totally new to programming with this LCD ;-)

I did not simulate the code yet, I still have to write a testbench. I have already found now that some of the processes need precise timing. I will try to add this timing to the code and will reply the updated code then.

grtz,

Simon

50%
50%
Adam Taylor
Adam Taylor
7/25/2012 9:13:54 AM
User Rank
Blogger
Re: fpga to 16-character x2-line LCD (vhdl)
Having just run a quick simulation you need to look at the follwoing

first process, counter, its range is declared as 0 to 21, however you never detect when it reaches 21 and reset it back to 0. This will fail in simulation (in modelsim it does, in reality it willl be implmented as a five bit counter (0 to 31) which just loops around.

As you say you need to have a look at the commands and timing to ensure they are correct for the LCD you are driving.

Simulation is key prior to synthesis and trying it in the target as you can debug it easier

 

50%
50%
SimonC
SimonC
7/25/2012 9:20:06 AM
User Rank
Beginner
Re: fpga to 16-character x2-line LCD (vhdl)
Thanks, I will try that ;)

50%
50%
Adam Taylor
Adam Taylor
7/25/2012 9:38:01 AM
User Rank
Blogger
Re: fpga to 16-character x2-line LCD (vhdl)
Please let me know if you need any pointers or help

50%
50%
SimonC
SimonC
7/25/2012 9:45:10 AM
User Rank
Beginner
Re: fpga to 16-character x2-line LCD (vhdl)
All right ;-)

I was wondering, when you have a clock frequency of 50 MHz, and you let a counter run for 2000 loops (i use the following code for this:  if clock'EVENT and clock = '1' then counter := counter +1;), then it will take 2000 * 1/50 000 000 = 40 microseconds before the counter has done running.

Is this correct?

thanks in advance

50%
50%
thrakkor
thrakkor
7/25/2012 11:30:55 AM
User Rank
Blogger
Re: fpga to 16-character x2-line LCD (vhdl)
yes, clk period * clk ticks = elapsed time.

50%
50%
SimonC
SimonC
7/25/2012 11:44:23 AM
User Rank
Beginner
Re: fpga to 16-character x2-line LCD (vhdl)
All right, thanks mate!

50%
50%
Adam Taylor
Adam Taylor
7/25/2012 1:56:11 PM
User Rank
Blogger
Re: fpga to 16-character x2-line LCD (vhdl)
Sorry I got caught up at work 

Yes this is correct however you normally need to do something when a terminal count is reached for example 

if count = target valeu then 

count = 0 

op = 1

else 

count = count +1

end 

You shoud be using if rising_edge really as opposed to the older clk'event and clk = '1' 

Also the counter does not run for 2000 loops but it counts to 2000 a slight difference. 

hope this makes sense I will be doing a Ask Adam column soon on counters and sizing them correctly. i.e. how to just define the clock speed and the delay required but we have a few more basic topics to cover to get to that point 

 

50%
50%
thrakkor
thrakkor
7/25/2012 11:09:39 AM
User Rank
Blogger
variables
I would also recommend NOT using variables in VHDL except for simulation only constructs such as File I/O or in synthesizable constructs ONLY for readability, such as if the right side of an assignment is extremely long due to multiple functions/casts/vector slices/long signal names etc.

 

example:

 

cross_sum_loop : for j in 0 to 3 loop
  f_inph_sum_arr(j) <= resize(f_ac_arr(j), f_inph_sum_arr(j)'length) - resize(f_bd_arr(j), f_inph_sum_arr(j)'length);
  f_quad_sum_arr(j) <= resize(f_bc_arr(j), f_quad_sum_arr(j)'length) + resize(f_ad_arr(j), f_quad_sum_arr(j)'length);
end loop cross_sum_loop;

 

in some editors the above would wrap around to the next line and make reading a PITA.

you could use variable like thus:

cross_sum_loop : for j in 0 to 3 loop

  v_ac := resize(f_ac_arr(j), f_inph_sum_arr(j)'length);

  v_bd := resize(f_bd_arr(j), f_inph_sum_arr(j)'length);

  f_inph_sum_arr(j) <= v_ac - v_bd;

  v_bc := resize(f_bc_arr(j), f_quad_sum_arr(j)'length);

  v_ad := resize(f_ad_arr(j), f_quad_sum_arr(j)'length);

  f_quad_sum_arr(j) <= v_bc + v_ad;
end loop cross_sum_loop;

50%
50%
Adam Taylor
Adam Taylor
7/25/2012 1:59:17 PM
User Rank
Blogger
Re: variables
Variables are always an interestinf area, if they are used correctly they cause no issues however you can easily get into a mess with them with differences betwenn simulation and reality. 

Most of the safety critical / high reliability work I have done has not allowed variables in RTL only signals 

If you are going to use variables remember there scope is local only (process which it is currently in) also a good rule of thumb is if you want a register then read / use the variable prior to storing anything in it. if you want a peice of wire then set it before you read it. 

50%
50%
JezmoSSL
JezmoSSL
7/26/2012 4:56:16 PM
User Rank
Blogger
Re: variables
variables are very useful and I use them all the time, you just have to understand how they behave.

50%
50%
Duane Benson
Duane Benson
7/25/2012 2:01:08 PM
User Rank
Blogger
Simulation
This is one of many areas where my MCU background may be doing me a disservice in my process of learning to use FPGAs. MCUs certainly use debugger, but I'm gathering that using a debugger isn't the same thing as simulation. I think one of my next few blogs will have to cover my exploration of simulation.

50%
50%
thrakkor
thrakkor
7/25/2012 2:09:29 PM
User Rank
Blogger
Re: Simulation
well some simulators allow breakpoints, similar to SW debugging, but in general a simulator waveform shows you all of the signals you have logged for the duration of the simulation run time.  or you can dump to VCD and view later.

 

you can also use assert statements in your source code (well VHDL anyway) that can print things to the simulator shell/terminal/etc a la printf.

50%
50%
Duane Benson
Duane Benson
7/25/2012 2:12:29 PM
User Rank
Blogger
Re: Simulation
Thrakkor - I've been using Verilog so far. It does have an assert statement as well, but I'm not totally sure if has the same functionality as the statement in VHDL.

50%
50%
SimonC
SimonC
7/27/2012 9:38:25 AM
User Rank
Beginner
RS 232 and LEDS
Hi again ;)

I'm trying to make a serial rs232 interfase from my computer to my virtex 5 ml507 FPGA. I'm trying to light some LEDs depending on the character I type in HYPERTERMINAL on the computer. I think there is nothing wrong with the serial connection, because when I switch the non-configured FPGA on, the words of the display appear in hyperterminal.

So the problem should be in the code (see below), I think. The problem could be in the baud speed, I calculated this as 3437 because I have  9600 bits/s (done by the configuration of the hyperterminal) and use a 33 MHz clock signal. What would be my mistake?

Thanks in advance,

Simon

LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;

--SIMONS RS232 project
ENTITY RS232 IS
PORT(  
  CLK  : IN STD_LOGIC;
  RS232_IN  : IN STD_LOGIC;
  LED_DISPLAY : OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
end RS232;


ARCHITECTURE behavior of RS232 IS

--Numbers
CONSTANT zero   : STD_LOGIC_VECTOR := "0000001";
CONSTANT one   : STD_LOGIC_VECTOR := "0111101";
CONSTANT two   : STD_LOGIC_VECTOR := "0010010";
CONSTANT three  : STD_LOGIC_VECTOR := "0011000";
CONSTANT four   : STD_LOGIC_VECTOR := "0101100";
CONSTANT five   : STD_LOGIC_VECTOR := "1001000";
CONSTANT six   : STD_LOGIC_VECTOR := "1000000";
CONSTANT seven  : STD_LOGIC_VECTOR := "0011101";
CONSTANT eight  : STD_LOGIC_VECTOR := "0000000";
CONSTANT nine   : STD_LOGIC_VECTOR := "0001000";

--Letters
CONSTANT letter_a : STD_LOGIC_VECTOR := "0000100";
CONSTANT letter_b : STD_LOGIC_VECTOR := "1100000";
CONSTANT letter_c : STD_LOGIC_VECTOR := "1000011";
CONSTANT letter_d : STD_LOGIC_VECTOR := "0110000";
CONSTANT letter_e : STD_LOGIC_VECTOR := "1000010";
CONSTANT letter_f : STD_LOGIC_VECTOR := "1000110";
CONSTANT letter_g : STD_LOGIC_VECTOR := "1000000";
CONSTANT letter_h : STD_LOGIC_VECTOR := "0100100";
CONSTANT letter_i : STD_LOGIC_VECTOR := "0111101";
CONSTANT letter_j : STD_LOGIC_VECTOR := "0110001";
CONSTANT letter_l : STD_LOGIC_VECTOR := "1100011";
CONSTANT letter_n : STD_LOGIC_VECTOR := "0000101";
CONSTANT letter_o : STD_LOGIC_VECTOR := "0000001";
CONSTANT letter_p : STD_LOGIC_VECTOR := "0000110";
CONSTANT letter_s : STD_LOGIC_VECTOR := "1001000";
CONSTANT letter_u : STD_LOGIC_VECTOR := "0100001";
CONSTANT letter_y : STD_LOGIC_VECTOR := "0001000";
CONSTANT letter_z : STD_LOGIC_VECTOR := "0010010";

--BAUD Rate Counter
CONSTANT BAUD  : INTEGER := 3157;

--Shift Register
SIGNAL SHIFT_REG  : STD_LOGIC_VECTOR(7 DOWNTO 0);

--Control Signal
SIGNAL START_STOP : STD_LOGIC := '0';

BEGIN

PROCESS
variable timer_cnt: integer range 0 to 100000;
variable char_cnt: integer range 0 to 10;
BEGIN

WAIT UNTIL(clk'EVENT) AND (clk = '1');

--IDLE State
IF(RS232_IN = '0' AND START_STOP = '0')THEN
 --Reset Counters
 char_cnt := 0;
 timer_cnt := 0;
 --Start RS232 Capture Process
 START_STOP <= '1';
ELSIF(RS232_IN = '1' AND START_STOP = '0')THEN

CASE SHIFT_REG is
   --ASCII -> Number, Decoding
  WHEN x"30" => LED_DISPLAY <= zero;
  WHEN x"31" => LED_DISPLAY <= one;
  WHEN x"32" => LED_DISPLAY <= two;
  WHEN x"33" => LED_DISPLAY <= three;
  WHEN x"34" => LED_DISPLAY <= four;
  WHEN x"35" => LED_DISPLAY <= five;
  WHEN x"36" => LED_DISPLAY <= six;
  WHEN x"37" => LED_DISPLAY <= seven;
  WHEN x"38" => LED_DISPLAY <= eight;
  WHEN x"39" => LED_DISPLAY <= nine;
   --ASCII -> Letter, Decoding
  WHEN x"61" => LED_DISPLAY <= letter_a;
  WHEN x"62" => LED_DISPLAY <= letter_b;
  WHEN x"63" => LED_DISPLAY <= letter_c;
  WHEN x"64" => LED_DISPLAY <= letter_d;
  WHEN x"65" => LED_DISPLAY <= letter_e;
  WHEN x"66" => LED_DISPLAY <= letter_f;
  WHEN x"67" => LED_DISPLAY <= letter_g;
  WHEN x"68" => LED_DISPLAY <= letter_h;
  WHEN x"69" => LED_DISPLAY <= letter_i;
  WHEN x"6A" => LED_DISPLAY <= letter_j;
  WHEN x"6C" => LED_DISPLAY <= letter_l;
  WHEN x"6E" => LED_DISPLAY <= letter_n;
  WHEN x"6F" => LED_DISPLAY <= letter_o;
  WHEN x"70" => LED_DISPLAY <= letter_p;
  WHEN x"73" => LED_DISPLAY <= letter_s;
  WHEN x"75" => LED_DISPLAY <= letter_u;
  WHEN x"79" => LED_DISPLAY <= letter_y;
  WHEN x"7A" => LED_DISPLAY <= letter_z;
   --Clear 7 Seg When Others Pressed
  WHEN OTHERS => LED_DISPLAY <= "1111111";
END CASE;

END IF;

--Start Getting Serial Data
IF(START_STOP = '1')THEN
  IF(timer_cnt = BAUD) THEN
    --Update Counter
   timer_cnt := 0;
   
    --Update Shift Register   
   SHIFT_REG <= RS232_IN & SHIFT_REG(7 DOWNTO 1);
   
    --Is 8th Bit?
    IF(char_cnt = 7)THEN    
     START_STOP <= '0';
    ELSE
     char_cnt := char_cnt + 1;
    END IF;
  ELSE
   timer_cnt := timer_cnt + 1;     
  END IF;
END IF;

END PROCESS;

END behavior;

 

50%
50%
Adam Taylor
Adam Taylor
7/27/2012 10:05:02 AM
User Rank
Blogger
Re: RS 232 and LEDS
Simon, when receiveing RS232 you need to sample the line and detect the falling edge of the start bit. you then have a reference point to determine when to sample the next bits. For a simple and easy method you can count half a bit period following the falling edge of the start bit to place you approaximately in the center of the start bit. You can then count for a bit period again which will result in you being in the middle of the 1st data bit which you can shift into your register. count another bit period and you are in the middle (ish) of the next bit repeat until the end. This is a very simple method of capturing over rs232. you do not want to sample near the nominal positions due to tolerances which is why the centre of the bit is best.

I hope this helps

 

Adam

50%
50%
KenwickVS
KenwickVS
7/27/2012 10:05:22 AM
User Rank
Blogger
Re: RS 232 and LEDS
Simon, The serial bit stream coming will need to by captured by a clock much higher than the transmitter baud clock - typically 16x.  You'll need to sync to the edge of the start bit and then count 8 clock cycles, then capture the first bit.  Then each 16 cycles will capture each consecutive bit.

50%
50%
SimonC
SimonC
7/27/2012 10:22:18 AM
User Rank
Beginner
Re: RS 232 and LEDS
Thanks for the fast reply's,

if I understand this good, I have to multiply my BAUD constant in my code with 16, then wait until the startbitedge comes, in the middle of the startbit (8 BAUD clock cycles further) capture the startbit then 16 cycles further capture the first databit, etc.?

Is my calculation OK for the BAUD constant? I did 33 000 000/9600 to get to that constant.

Sorry for all the beginners-mistakes by the way ;-)

thanks in advance,

Simon

50%
50%
Adam Taylor
Adam Taylor
7/27/2012 10:34:10 AM
User Rank
Blogger
Re: RS 232 and LEDS
Simon what is your email address and I will send you an example 

50%
50%
Max Maxfield
Max Maxfield
7/27/2012 10:56:23 AM
User Rank
Blogger
Re: RS 232 and LEDS
@Adam: If you send the example to me, I can forward it to Simon -- cheers -- Max

50%
50%
Adam Taylor
Adam Taylor
7/27/2012 11:00:38 AM
User Rank
Blogger
Re: RS 232 and LEDS
with you now mate 

50%
50%
SimonC
SimonC
7/27/2012 11:04:42 AM
User Rank
Beginner
Re: RS 232 and LEDS
Hi, sorry, was afk for a while

here it is: simonvandenberge@hotmail.be

 

thanks a lot ;)

50%
50%
Max Maxfield
Max Maxfield
7/27/2012 11:16:32 AM
User Rank
Blogger
Re: RS 232 and LEDS
@Adam: I've forwarded it to Simon -- cheers -- Max

50%
50%
SimonC
SimonC
7/27/2012 11:19:54 AM
User Rank
Beginner
Re: RS 232 and LEDS
Thanks Adam and Max. I hope it's not too complicated ;)

50%
50%
SimonC
SimonC
7/27/2012 11:19:56 AM
User Rank
Beginner
Re: RS 232 and LEDS
Thanks Adam and Max. I hope it's not too complicated ;)

50%
50%
Adam Taylor
Adam Taylor
7/27/2012 11:24:57 AM
User Rank
Blogger
Re: RS 232 and LEDS
Just sent you the test bench as well 

50%
50%
SimonC
SimonC
7/28/2012 5:40:30 AM
User Rank
Beginner
Re: RS 232 and LEDS
Thanks,

I have a little question about the code, Adam.

If I understand the code right, the bit_period variable is the number of clockcounts in a bit of 'rx', right? What would you suggest for a 33 MHz clock input in a 9600 bits per second 'rx' input? I would take 3437 counts/bit.

50%
50%
Adam Taylor
Adam Taylor
7/28/2012 5:54:58 AM
User Rank
Blogger
Re: RS 232 and LEDS
Simon

If you have a 33MHz clock the period of it is 30.3 ns. At a baud rate of 9600 the bit period is 104 us. 

Thus the number of clocks within a bit period is 104 us / 30.3 ns = 3432 clocks 

if you have any other questions you have my email address so feel free to use it

Hope this helps

Adam

50%
50%
SimonC
SimonC
7/28/2012 6:28:13 AM
User Rank
Beginner
Re: RS 232 and LEDS
Thanks mate

50%
50%
SimonC
SimonC
7/30/2012 9:00:11 AM
User Rank
Beginner
Re: RS 232 and LEDS
Very interesting code. Just assigned some LEDs as output and tested it. Works very good ;)

I'll keep in mind that a testbench is indeed a powerfull tool to check your design. I didn't use it that much untill now.

Would I be able to use the same principles to light some LEDs with a keyboard on my FPGA?

grtz,

Simon

50%
50%
Adam Taylor
Adam Taylor
7/30/2012 3:01:30 PM
User Rank
Blogger
Re: RS 232 and LEDS
Glad it works ;) I will be blogging about it soon as part of vga controller I have been working on.

 

50%
50%
SimonC
SimonC
7/31/2012 5:22:37 AM
User Rank
Beginner
Re: RS 232 and LEDS
I'll certainly follow up that one ;)

Made some code today for interfacing the PS/2 keyboard to some LEDs, tested it out and it works.  Yeah!! ;)

There is one strange thing though, I have noticed that a few LEDs that are 'low', blink up for a very short time in between two characters I type with the keyboard.

50%
50%
Duane Benson
Duane Benson
7/30/2012 2:04:38 PM
User Rank
Blogger
Communications
This has been a very interesting discussion around RS232. I expect that conceptially it will help with the implementation of a few other protocols that I'll need to figure out at some point.

50%
50%
SimonC
SimonC
7/31/2012 5:11:37 AM
User Rank
Beginner
Re: Communications
Totally agreed ;)

50%
50%
SimonC
SimonC
8/6/2012 11:32:46 AM
User Rank
Beginner
VGA and LEDs
Hi,

I 'm trying another home-made  exercice ;) . I have connected a VGA input (another PC)  to my FPGA and i'm trying to light some LEDs depending on the color of a pixel somewhere in the middle of a frame. I am using 800 X 600 @ 72 Hz resolution.  I have read about VGA and I know I think I need 1040 pixels on a row and 666 pixelrows on a frame. (The pixelfrequency is 50 MHz. )

The VGA input on my FPGA delivers  8 bit for blue, 8 bit for  red and 8 bit for green. a horizontal and vertical synchronisation signal.  However when I make a colored frame (for example in 'paint' opening a black screen) , input this to VGA and assign for example the blue 8 bit vector on a specific pixel of the frame  to the 8 LEDs, I get always '0' on my LEDs,  even when I input a white or a blue frame.

I use the following principle: the first data that enters is a vertical blanc signal, followed by a horizontal blanc signal, followed by a row of screen-pixels, followed by a horizontal blanc signal, followed by a horizontal synchronisation signal (end of row 1). Then again a horizontal blanc signal, a row of screen pixels, a horizontal blanc signal and a horizontal sync (end of row 2),... etc. Every frame is concluded by a vertical  blanc signal and a vertical synchronisation.

The specific timings for the signals, I found on this website: http://tinyvga.com/vga-timing/800x600@72Hz

Is this the correct way to do it? Or should you start with a synchronisation signal? Or start with the row of screen-pixels?

Thanks in advance,

Simon

 

100%
0%
Adam Taylor
Adam Taylor
8/6/2012 3:14:47 PM
User Rank
Blogger
Re: VGA and LEDs
it is not quite as simple as that please check out my post on VGA timing as not every V_Sync and H_sync has data associated with it. See Here

http://www.programmableplanet.com/author.asp?section_id=2142&doc_id=246139&

and this

http://www.programmableplanet.com/author.asp?section_id=2142&doc_id=246139&

if you are using the ML507 virtex board still then I would recommend reading the AD9980 datasheet to see what the timing on your FPGA interface will be

100%
0%
SimonC
SimonC
8/6/2012 5:31:09 PM
User Rank
Beginner
Re: VGA and LEDs
Thanks, I'll keep on trying ;)

50%
50%
Adam Taylor
Adam Taylor
8/6/2012 5:46:52 PM
User Rank
Blogger
Re: VGA and LEDs
if you get stuck send me a email with your code etc

100%
0%
SimonC
SimonC
8/7/2012 12:44:34 PM
User Rank
Beginner
Re: VGA and LEDs
I think I still have a problem with the exact timing. I have send you the code and the testbench.

50%
50%
SimonC
SimonC
8/8/2012 10:17:40 AM
User Rank
Beginner
Re: VGA and LEDs
I think there is a problem with the AD9980 (see http://www.analog.com/static/imported-files/data_sheets/AD9980.pdf) because when I switch the resolution of a computer on 800 x 600 or on 1680 x 1050 , both at 60 Hz and feed this in the AD9980, the AD9980 keeps on outputting a dataclock with a period of 20 ns to the FPGA. While this period should be 6.79 ns for the 1680 x 1050 @ 60 Hz and 25 ns at 800 X 600 @ 60 Hz.

Is this normal?

 

50%
50%
SimonC
SimonC
8/9/2012 9:55:28 AM
User Rank
Beginner
Re: VGA and LEDs
I'm trying to configure the registers of the AD9980 using the I2C bus and my FPGA. I'm writing on the SDA and the SCL pins with a SCL-frequency of 100 kHz. However it doesn't seem to work. I'm trying but I don't think I wrote in the registers.

Anyone has some experience with this?

Any help would be greatly appreciated,

Simon

 

50%
50%
More Blogs from Duane Benson
Duane has decided that the time is ripe to get his ZedBoard bolted onto his robot with a Linux distribution up and running. That was the ultimate plan anyway, so why wait?
Now it's time to delve deeper into the state machine I'm using to control my I2C interface.
The three states associated with bi-directional "inout" pins can cause confusion for the unwary.
It's time to jump into unexplored territory -- the state machine that will control Duane Benson's I2C interface.
We're now ready for the I2C master to transmit a command set to a remote device.
flash poll
follow us on twitter
follow Xilinx on twitter
like us on facebook
like Xilinx on facebook
All Programmable Planet     About Us     Contact Us     Help     Register     Twitter     Facebook     RSS