Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing a temperature sensor with PLD without implementing SPI/I2C bus

Status
Not open for further replies.

garvind25

Full Member level 3
Joined
Oct 28, 2012
Messages
176
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,298
Activity points
3,066
Hi,

Are there any temperature sensors which can be interfaced with PLDs without having to implement a SPI/I2C bus at the PLD end. I am looking for something which can be interfaced without having to be involved in the complications of code the receiver part of some protocol.

Thanks and Regards,
Arvind Gupta
 

I2C surely involves some overhead, but I wonder what can be simpler than a SPI interface. Just a counter for CS timing and a shift register.
 

Strange request.

What would you propose? A parallel interface? That, too, would require some code. SPI and I2C are not that complicated to interface; there's plenty of stuff available on the web if you can't be bothered coding it yourself.
 

Hi,

Even a 1-wire-interface needs some code.
Maybe just a comparator is what you need.

Klaus
 

Thanks for your replies. So as I understood SPI is the simplest of the types of digital interfaces available for temperature sensors. Can anyone point me to a simple SPI code (in VHDL) which I can go through and implement to see SPI interface working for a temperature sensor. Also, it would be nice of anyone to suggest me a simple SPI based temperature sensor.

I searched the internet to find the following code (here) related to SPI temperature sensor interfacing. Does anyone know of anything simpler that this pls.

Hope you people have understood that I know nothing about this SPI stuff. :-|

Thanks again,
Arvind Gupta
 

Hi,

I wonder how you use a PLD if a shift register (SPI) is too difficult.

I'd say there are more than ten thousands of SPI VHDL documents in the internet. With code, with temperature sensor examples.
Just pick one and try to use it. Test it, if there is a problem, then come back and we will help you to solve the problem.

Klaus
 

Hope you people have understood that I know nothing about this SPI stuff.

Read the SPI docu (it is really simple) before downloading the code from somewhere.
 

OK. I went through the SPI bus theory. I had the following queries pls:

** The master receives data serially from the slave through MISO pin and stores it in a register. Is it mandatory to transmit data serially to the slave via MOSI pin? I only want to read the temp. sensor’s output. If not, then what to do for the MOSI pin?

**After what duration should the master re-read the sensor for the next temperature reading. Can I do so after 10-20 clock cycles of finishing the previous read operation?

** Pls. suggest a common SPI temp sensor (common = cheap; easily available and workable).

Thanks,
Arvind Gupta.
 

Hi,

Is it mandatory to transmit data serially to the slave via MOSI pin?
Only the sensor´s datasheet can tell what data you have to send to the sensor.

Generally:
MOSI has to be driven by the master.
SCK has to be driven by the master.
On every rising (or falling) SCK clock edge the data is shifted in the slave.
So either the MOSI contains valid data for communcation with the slave, or it is HIGH when idel (maybe you could use LOW, also). But there is never "nothing" or "floating" or "undefined".

For many microcontrollers there is only one SPI transfer function: it is a write and read at the same time, and often it is initated by writing to the SPI_OUT register.
In this case: Yes: you need to write data to the slave. As said above: either valid communication data or "0xFF".

After what duration should the master re-read the sensor for the next temperature reading
This depends:
* on your application --> how often you you want the temperature to be read?
* on the sensor --> read the datasheet

Can I do so after 10-20 clock cycles of finishing the previous read operation?
* only the datasheet can tell.

Pls. suggest a common SPI temp sensor (common = cheap; easily available
--> Do this on your own. We don´t know the specifications for your tempersature sensor., We don´t know where you live, We don´t know your budget.
Simply go to the distributor of your choice and use the selection guide.

and workable).
Funny. Do you know about any electronic sensor that is known to be "not workable"?

Klaus
 

This depends:
* on your application --> how often you you want the temperature to be read?
* on the sensor --> read the datasheet

* only the datasheet can tell.

Klaus

OK. Thanks for your response. Suppose I want the temperature to be updated every 10 sec. Does that mean I will have to count the positive clock edges till 10 secs? That will make a very big counter for MHz. clock oscillators. Is there no other way (to save the PLD resources) ?

By workable, I meant something easily workable for beginners. Sorry for incomplete information.

Regards,
Arvind Gupta
 

Hi,

10MHz (just an assumption, because you didn´t say) down to 1Hz needs a 24 bit counter = 24 macrocells.

For sure you are free to use a second clock source. Like from an external RC with a clock frequency of just 1 Hz.
Or an external clock divider...or...

Klaus
 

For sure you are free to use a second clock source. Like from an external RC with a clock frequency of just 1 Hz.

Klaus

Pls. enumerate how can one do that pls? I am under the presumption that one can use a crystal oscillator for clock source only.

Thanks and Regards,
Arvind Gupta.
 

Hi,

in this case - because the second clock is much lower in frequency - you can wire the second clock to any GPIO.
Inside the FPGA syncronize it with the high speed clock. If you want a very clean solution do the usual double D-FF buffering to avoid metastable states.

Klaus
 

I did not understand any of it. How does this generate a 1 Hz clock ?

Regards,
Arvind Gupta
 

You could use a 555 timer, an opamp oscillator, a transformer connected to your AC and then a comparator to generate 50/60 Hz, etc., etc.,
 
Hi,

I did not understand any of it. How does this generate a 1 Hz clock ?
I wrote:
For sure you are free to use a second clock source. Like from an external RC with a clock frequency of just 1 Hz.
Or an external clock divider...or...
This second clock can't be generated internally. You need to generate it externally. It's not important how.
You may use an external divider, a PLL, an RC oscillator built with NE555 or a comparator or any other oscillator IC.....
Generate it like you want.

Klaus
 
OK. Can anyone refer me a SPI based temperature sensor which has an 8 bit temperature storing register. I could find several with 10/12 bits but not 8 bits.

Thanks,

Arvind Gupta
 

Hi,

SPI,

if you manage to use a 3 bit counter to count 8 pulses (one byte, 8 bit temperature), what´s the problem to use a 4 bit counter and count 16 pulses?
It seems you make your life more difficult than it needs to.

Some sensors may give the temperature in left aligned format... then just read the first 8 bits and you are done.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top