+ Post New Thread
Results 1 to 18 of 18
  1. #1
    Member level 5
    Points: 1,473, Level: 8

    Join Date
    Oct 2012
    Posts
    92
    Helped
    0 / 0
    Points
    1,473
    Level
    8

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

    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

  2. #2
    Super Moderator
    Points: 248,140, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    43,156
    Helped
    13131 / 13131
    Points
    248,140
    Level
    100

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

    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.



  3. #3
    Advanced Member level 5
    Points: 21,824, Level: 35
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    4,191
    Helped
    921 / 921
    Points
    21,824
    Level
    35

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

    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.



  4. #4
    Super Moderator
    Points: 66,089, Level: 62
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,444
    Helped
    3101 / 3101
    Points
    66,089
    Level
    62

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

    Hi,

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

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisment

        
       

  5. #5
    Member level 5
    Points: 1,473, Level: 8

    Join Date
    Oct 2012
    Posts
    92
    Helped
    0 / 0
    Points
    1,473
    Level
    8

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

    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



  6. #6
    Super Moderator
    Points: 66,089, Level: 62
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,444
    Helped
    3101 / 3101
    Points
    66,089
    Level
    62

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

    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
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  7. #7
    Advanced Member level 4
    Points: 7,698, Level: 20
    Achievements:
    7 years registered Created Blog entry
    dpaul's Avatar
    Join Date
    Jan 2008
    Location
    Germay
    Posts
    1,141
    Helped
    248 / 248
    Points
    7,698
    Level
    20
    Blog Entries
    1

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

    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.
    .....yes, I do this for fun!



  8. #8
    Member level 5
    Points: 1,473, Level: 8

    Join Date
    Oct 2012
    Posts
    92
    Helped
    0 / 0
    Points
    1,473
    Level
    8

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

    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.



    •   AltAdvertisment

        
       

  9. #9
    Super Moderator
    Points: 66,089, Level: 62
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,444
    Helped
    3101 / 3101
    Points
    66,089
    Level
    62

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

    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
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  10. #10
    Member level 5
    Points: 1,473, Level: 8

    Join Date
    Oct 2012
    Posts
    92
    Helped
    0 / 0
    Points
    1,473
    Level
    8

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

    Quote Originally Posted by KlausST View Post

    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



  11. #11
    Super Moderator
    Points: 66,089, Level: 62
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,444
    Helped
    3101 / 3101
    Points
    66,089
    Level
    62

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

    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
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  12. #12
    Member level 5
    Points: 1,473, Level: 8

    Join Date
    Oct 2012
    Posts
    92
    Helped
    0 / 0
    Points
    1,473
    Level
    8

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

    Quote Originally Posted by KlausST View Post

    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.



  13. #13
    Super Moderator
    Points: 66,089, Level: 62
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,444
    Helped
    3101 / 3101
    Points
    66,089
    Level
    62

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

    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
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



  14. #14
    Member level 5
    Points: 1,473, Level: 8

    Join Date
    Oct 2012
    Posts
    92
    Helped
    0 / 0
    Points
    1,473
    Level
    8

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

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

    Regards,
    Arvind Gupta



  15. #15
    Advanced Member level 5
    Points: 21,824, Level: 35
    barry's Avatar
    Join Date
    Mar 2005
    Location
    California, USA
    Posts
    4,191
    Helped
    921 / 921
    Points
    21,824
    Level
    35

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

    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.,


    1 members found this post helpful.

    •   AltAdvertisment

        
       

  16. #16
    Super Moderator
    Points: 66,089, Level: 62
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,444
    Helped
    3101 / 3101
    Points
    66,089
    Level
    62

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

    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
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

  17. #17
    Member level 5
    Points: 1,473, Level: 8

    Join Date
    Oct 2012
    Posts
    92
    Helped
    0 / 0
    Points
    1,473
    Level
    8

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

    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



  18. #18
    Super Moderator
    Points: 66,089, Level: 62
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    13,444
    Helped
    3101 / 3101
    Points
    66,089
    Level
    62

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

    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
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



--[[ ]]--