FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-18-2005, 07:59 AM
rgebru
Guest
 
Posts: n/a
Default Spartan 3 to tempsensor interface

Hi,

I'm thinkin go of designing a heating/cooling system with VHDL an
need to interface my Spartan 3 board to a real temp sensor. Doe
anyone have an idea of how I can do this?

Thanks!

Reply With Quote
  #2 (permalink)  
Old 03-18-2005, 10:07 AM
Jens Baumann
Guest
 
Posts: n/a
Default Re: Spartan 3 to tempsensor interface

rgebru wrote:

> Hi,
>
> I'm thinkin go of designing a heating/cooling system with VHDL and
> need to interface my Spartan 3 board to a real temp sensor. Does
> anyone have an idea of how I can do this?
>
> Thanks!!


There are several temperature sensors with i2c interface. They should easily
be connected to your board.

http://www.google.de/search?hl=en&q=...erature+sensor

Jens
Reply With Quote
  #3 (permalink)  
Old 03-19-2005, 01:17 AM
Rajeev
Guest
 
Posts: n/a
Default Re: Spartan 3 to tempsensor interface


Jens Baumann wrote:
> rgebru wrote:
>
> > Hi,
> >
> > I'm thinkin go of designing a heating/cooling system with VHDL and
> > need to interface my Spartan 3 board to a real temp sensor. Does
> > anyone have an idea of how I can do this?
> >
> > Thanks!!

>
> There are several temperature sensors with i2c interface. They should

easily
> be connected to your board.
>
> http://www.google.de/search?hl=en&q=...erature+sensor
>
> Jens


My personal preference is SPI device, eg Analog Devices AD7814.

Regards,
-rajeev-

Reply With Quote
  #4 (permalink)  
Old 03-19-2005, 04:06 PM
info_
Guest
 
Posts: n/a
Default Re: Spartan 3 to tempsensor interface

Hi,

There is an LM70 (uWire / SPI) Temperature Sensor on our Tornado
board, and the VHDL code for the digital thermometer is free !

http://www.alse-fr.com/Tornado/Torn_Educ_us.pdf

We have also a reference design for the MaxII board with a different
temperature sensor (external transistor as sensor) : Max6627

This kind of interface is about 60 lines of (easy) code...
really simple.

I also wrote behavioral models for the Temperature sensors
so the design can be verified by simulation.

Best regards,

Bert

rgebru wrote:

> Hi,
>
> I'm thinkin go of designing a heating/cooling system with VHDL and
> need to interface my Spartan 3 board to a real temp sensor. Does
> anyone have an idea of how I can do this?
>
> Thanks!!
>


Reply With Quote
  #5 (permalink)  
Old 03-23-2005, 08:06 AM
rgebru
Guest
 
Posts: n/a
Default Re: Spartan 3 to tempsensor interface

H

thanks so much for the replies..both the Analog devices and the i2
interface seem promising... will let you guys know of my progress :
I haven't started working on it yet.

To use the temp sensor on the ornado board though wouldn't I have t
use that board? I have to use the Spartan 3 board..

Rut

Reply With Quote
  #6 (permalink)  
Old 04-19-2005, 01:17 AM
rgebru
Guest
 
Posts: n/a
Default re:Spartan 3 to tempsensor interface

I started using the Analog devices AD7814 and I'm having troubl
understanding how to interface it to the Spartan 3 board. Doe
anyone have any suggestions to get me started? I could REALLY use th
help!! Thanks!

Reply With Quote
  #7 (permalink)  
Old 04-19-2005, 02:15 PM
Gabor
Guest
 
Posts: n/a
Default Re: re:Spartan 3 to tempsensor interface

rgebru wrote:
> I started using the Analog devices AD7814 and I'm having trouble
> understanding how to interface it to the Spartan 3 board. Does
> anyone have any suggestions to get me started? I could REALLY use the
> help!! Thanks!!


I'm not sure if you mean the electrical interface, the programming,
or both. Anyway here's my thoughts:

If you don't need to power down the sensor, you can ground the DIN
pin as shown in figure 4 of the datasheet. For a power supply use
the same voltage as the VCCo of the FPGA I/O to avoid interface
problems with Vih. It looks like 3.3V and LVTTL or LVCMOS should
work.

For the programming, you need a state machine that generates the
SCLK and CS timing just as shown in figure 2. The best approach
is to leave CS high between reads to ensure the AD7814 bits match
up with the bit positions shown in the timing diagram. Then all
you need is a shift register to pick up the bits at the falling edge
of SCLK (to avoid hold time issues). Depending on how you use the
temperature, you may also need another parallel register loaded
from the shift register when you return CS high. This register
would then only change at the end of the reading period and always
contain the most recently read temperature.

Good luck,
Gabor

Reply With Quote
  #8 (permalink)  
Old 04-24-2005, 01:16 AM
rgebru
Guest
 
Posts: n/a
Default re:Spartan 3 to tempsensor interface

Hi Gabor

Thanks for the reply. I'm actually having problems with th
programming part. Especially displaying the 10bit 2's complemen
temperature readings on my 4 seven segment display. I'm trying t
convert them into binary but for some reason it's not working ver
well. Do you have a suggestion of how I should read them in? I'm no
using the negative temperature readings and I'm only interested i
temperatures up to 90deg so I can displaly the actual temp on tw
displays and the temperature you want to set on the other 2 displays
thanks so much for your suggestions!

Rut

Reply With Quote
  #9 (permalink)  
Old 04-25-2005, 03:00 PM
Gabor
Guest
 
Posts: n/a
Default Re: re:Spartan 3 to tempsensor interface

rgebru wrote:
> Hi Gabor,
>
>
> Thanks for the reply. I'm actually having problems with the
> programming part. Especially displaying the 10bit 2's complement
> temperature readings on my 4 seven segment display. I'm trying to
> convert them into binary but for some reason it's not working very
> well. Do you have a suggestion of how I should read them in? I'm not
> using the negative temperature readings and I'm only interested in
> temperatures up to 90deg so I can displaly the actual temp on two
> displays and the temperature you want to set on the other 2 displays.
> thanks so much for your suggestions!
>
> Ruth


First of all, you want to convert from binary to BCD (2's complement
is straight binary when the numbers are positive). Then from BCD
to seven-segment. There are several ways to convert binary to BCD.
If you had to do it really fast (1 clock cycle) you could use the brute
force method using block RAM (1024 x 13) as a look-up table. Since
your data is coming in serially at a relatively low clock rate, I
assume you don't need to do this. If you have an internal clock
running
at least 1024 times your sampling rate, the simplest serial method
is to load a binary counter with the binary value, then count it down
to zero while counting up on a BCD counter (3 divide-by-ten counters
in a carry chain). The conversion time would depend on the temperature
but the algorithm is simple. An intermediate method takes fewer clock
cycles but is a little more tricky. It involves shifting the binary
input one bit at a time into a shift register and then performing a
"decimal adjust after add" which involves adding a 6 to any digits
that either carry out (in the shift register this means 1 in the low
bit of the next digit up) or end up with a value greater than 9 after
the shift. If you don't pipeline the two operations you'd use 2
clock cycles per input bit for this method or 20 cycles in your case.
The shifter / adder would need to be 13 bits long to hold the BCD
number.
Other methods include serial subtraction of decimal powers (i.e.
subtract 1,000 and if there's no borrow, add one to the most
significant
digit, after a borrow add back 1,000 and then do the same with 100 and
the next digit down) or a series of division / remainder operations
(i.e. divide by 1,000 and put the result in the high digit, divide the
remainder by 100 and put the result in the next digit, divide the
second remainder by 10...).

Finally converting BCD to 7-segment is a simple look-up table. There
should be lots of examples of this around.

Reply With Quote
  #10 (permalink)  
Old 04-25-2005, 11:05 PM
info_
Guest
 
Posts: n/a
Default Re: Spartan 3 to tempsensor interface

rgebru wrote:
> I started using the Analog devices AD7814 and I'm having trouble
> understanding how to interface it to the Spartan 3 board. Does
> anyone have any suggestions to get me started? I could REALLY use the
> help!! Thanks!!
>


Less talk, more action !
Check that your temp sensor works like this one (Max6627) but it
shouldn't be a difficult task to adapt the code if it doesn't :-)

Bert Cuzeau

-- ------------------------------------------
-- MicroWire Temp Sensor (c) Bert Cuzeau --
-- ------------------------------------------
-- do not use without prior written consent
-- from the author.
-- Check with info at alse-fr dot com
-- ------------------------------------------
-- With on-the-fly Bin -> BCD conversion.
-- Has been tested on the new Altera MaxII board. Worked 1st try.
--
-- Note : Bin -> BCD conversion is simplified, okay up to +/- 99 included.
-- Note that we handle the negative values !
-- TEMP_CSN : out std_logic;-- Temp Sensor SPI Select
-- TEMP_SCK : out std_logic;-- Temp Sensor SPI Clock
-- TEMP_SDO : inout std_logic;-- Temp Sensor SPI Data

SPI_i: block
begin

-- DO NOT DO THIS below : you won't get a pullup and the input will disappear !
--TEMP_SDO <= 'H'; -- we don't drive it

-- This is okay :
TEMP_SDO <= 'Z'; -- we don't drive it
-- don't forget the pullup in the pin assignment ! (or on your board)

process (Clk, Rst)
variable BitCnt : integer range 0 to 16;
begin
if Rst='1' then
WrTemp <= '0';
TEMP_CSN <= '1';
TEMP_SCK <= '0';
Sign <= '0';
stSPI <= spiBoot;
BitCnt := 0;
FPGA_uW_SIOr<= '0';
TempH <= (others=>'0');
TempL <= (others=>'0');

elsif rising_edge (Clk) then

WrTemp <= '0';

FPGA_uW_SIOr <= TEMP_SDO or TEMP_SDO;

case stSPI is

when spiBoot =>
if Tick4us='1' then
stSPI <= spiIdle;
end if;

when spiIdle =>
TEMP_CSN <= '1';
TEMP_SCK <= '0';
if Cnt05s(Cnt05s'high) = '1' then -- read temperature ~ 2 times / s
TEMP_CSN <= '0';
TempH <= (others=>'0');
TempL <= (others=>'0');
BitCnt := SPi_Nbits;
stSPI <= spiRead1;
end if;

when spiRead1 =>
if Tick4us='1' then
TEMP_SCK <= '1'; -- rising edge
stSPI <= spiRead2;
if BitCnt = SPi_Nbits then
Sign <= FPGA_uW_SIOr; -- Shift the sign in...
else
if TempL < 5 then
TempH <= TempH(2 downto 0) & '0'; -- no carry
TempL <= TempL(2 downto 0) & (FPGA_uW_SIOr xor Sign);
else
TempL <= "-"(TempL,5) (2 downto 0) & (FPGA_uW_SIOr xor Sign);
TempH <= TempH(2 downto 0) & '1'; -- carry
end if;
end if;
BitCnt := BitCnt-1;
end if;

when spiRead2 =>
if Tick4us ='1' then
TEMP_SCK <= '0';
if BitCnt /= 0 then
stSPI <= spiRead1;
else -- No more bit
TEMP_CSN <= '1';
if Cnt05s(Cnt05s'high) = '0' then
WrTemp <= '1'; -- signal we want to display the temp
stSPI <= spiIdle;
end if;
end if;
end if;

end case;

end if;

end process;

end block;



Reply With Quote
  #11 (permalink)  
Old 04-26-2005, 01:17 AM
rgebru
Guest
 
Posts: n/a
Default re:Spartan 3 to tempsensor interface

hey,

thanks..I think the displaly problem got solved..although now I'
nervous since I didn't use a complicated algorithm and since I'
using the bits 9 downto 2 (positive numbers only and are straigh
binary) then I have a process that converts them to bcd..then to th
7 segment display. Now I'm working on simulating the ad7814..whic
seemed pretty easy. but for the life of me I can't get it t
work..I'm just using a simple process (which you had mentione
earlier also) to generate the timing diagram..this is what I'm doin
( obviously it's wrong ) before I interface it to the fpga. I ahv
to have the chip with FPGA working by wed Talk abou
procrastinating..it seemed simple before I started working on it!
:
entity model7814 i
port
CS: in std_logic:='Z'
SCLK: in std_logic :='0'
Dout: out std_logi
)
end model7814

architecture Behavioral of model7814 i

CONSTANT N: integer :=16
begi

process (CS,SCLK
begi

if SCLK' event and SCLK= '0' the
if CS<='0' the
FOR K IN 0 to N loo
if K=0 the
Dout <= '0';
els
Dout<='1'
end if
end loop
else
Dout<='Z'
end if
end if
end process

Reply With Quote
  #12 (permalink)  
Old 04-26-2005, 06:52 AM
info_
Guest
 
Posts: n/a
Default Re: Spartan 3 to tempsensor interface

rgebru wrote:
> I started using the Analog devices AD7814 and I'm having trouble
> understanding how to interface it to the Spartan 3 board. Does
> anyone have any suggestions to get me started? I could REALLY use the
> help!! Thanks!!
>


1. Why don't you try and understand the code I sent ?
It does (I think) all you want to do plus a little extra.
It does respect the design rules (it's fully synchronous)
It does employ good coding techniques.

2. Read and re-read (and adopt) :
http://www.alse-fr.com/archive/VHDL_Coding_eng.pdf

Your "simple" process is a collection of things "no to do".
Wrong domain, wrong sensitivity list, wrong tristate inference (
via clocked process !)....

If you do not start with the basics, you'll find hardware design
disgustingly frustrating and a total loss of time.
My opinion.

Bert Cuzeau
Reply With Quote
  #13 (permalink)  
Old 04-26-2005, 05:16 PM
rgebru
Guest
 
Posts: n/a
Default re:Spartan 3 to tempsensor interface

hi

You might want to give me a chance to look at it before you decide
don't want to learn it!! Great, so I'm doing everything wrong. Wel
I have something that kinda models the chip(Not what I had poste
earlier) will look at yours too obviously. But I don't have much tim
to get it working. Everything else except the chip interfacing work
so far. thanks

Reply With Quote
  #14 (permalink)  
Old 05-05-2005, 01:17 AM
rgebru
Guest
 
Posts: n/a
Default re:Spartan 3 to tempsensor interface

Thanks everyone for your suggestions, I finally got it to work..

Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner question: How to interface ram an Memec Spartan IIE - Board Michael Pieber FPGA 0 02-09-2005 02:02 PM
Newbie looking for multiported-RAM to interface to a Spartan-III savingsandloan FPGA 1 12-31-2004 04:48 PM
How can i interface Spartan-3 with PC/104. senthil FPGA 3 09-20-2004 07:08 AM
Spartan II and 100MHz SBSRAM Interface Peter Rauschert FPGA 0 02-04-2004 09:20 AM


All times are GMT +1. The time now is 12:01 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved