Author Topic: Interfacing a temperature sensor with PLD without implementing SPI/I2C bus  (Read 2224 times)

0 Members and 1 Guest are viewing this topic.

Offline garvind25Topic starter

  • Regular Contributor
  • *
  • Posts: 59
  • Country: in
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
 

Offline joshtyler

  • Contributor
  • Posts: 36
  • Country: gb
I'm not aware of any temperature sensors which simply have a parallel interface output, but I could be wrong.

If the PLD has a built in ADC, you could use that with an analogue temperature sensor. Alternatively you could even use an analogue temperature sensor and parallel output ADC.

As another option you could use a microcontroller to talk to the temp sensor over I2C/SPI and present the data as a parallel bus to the PLD.

To be honest though, writing a state machine to read the temperature sensor directly using I2C/SPI inside the PLD probably isn't that as hard as you think, and is likely simpler than adding lots of extra circuitry. Examples of SPI/I2C masters in Verilog and VHDL are readily available on the internet.
 

Offline langwadt

  • Super Contributor
  • ***
  • Posts: 4427
  • Country: dk
there's quite few temperature sensors with pwm output
 
The following users thanked this post: NiHaoMike, JPortici

Offline garvind25Topic starter

  • Regular Contributor
  • *
  • Posts: 59
  • Country: in
Thanks for your response. I have apparently changed my mind. I will go with SPI output temp sensors. Though I have understood the basic of SPI communication, I am unable to write a VHDL code to communicate a sensor with a PLD. Can anyone point me to a basic code of SPI master which I can implement to communicate with a single slave device?

Regards,
Arvind Gupta
 

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Thanks for your response. I have apparently changed my mind. I will go with SPI output temp sensors. Though I have understood the basic of SPI communication, I am unable to write a VHDL code to communicate a sensor with a PLD. Can anyone point me to a basic code of SPI master which I can implement to communicate with a single slave device?

An SPI master is simply a pair of shift registers. Implementation is trivial. Examples abound.

The non-trivial part is what you shift out (to the temperature sensor) and what you shift in (the conversion result).

 

Offline garvind25Topic starter

  • Regular Contributor
  • *
  • Posts: 59
  • Country: in
Indeed it would be trivial for you. But it in present a big task for me. hence re-requesting you to point me towards any working code of master of SPI. I found several of them; each a few pages long.

Thanks,
Arvind Gupta
 

Offline JustMeHere

  • Frequent Contributor
  • **
  • Posts: 744
  • Country: us
Look for Adafruit MAX31855 driver.  It has a bit bang SPI example.
 

Offline garvind25Topic starter

  • Regular Contributor
  • *
  • Posts: 59
  • Country: in
Thanks for the replies. I forgot o mention that I was looking for a SPI interface in VHDL.

Regards,
Arvind Gupta
 
 


Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9018
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
An SPI master is simply a pair of shift registers. Implementation is trivial. Examples abound.

The non-trivial part is what you shift out (to the temperature sensor) and what you shift in (the conversion result).
The part that trips up a lot of beginners is understanding how to make a state machine to configure SPI devices.

It does seem like PWM might be a good option. Measuring duty cycle with a FPGA is very easy (just a gated counter) and it lends itself well to multiplexing.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9890
  • Country: us
There will almost certainly be examples of SPI on opencores.org

You can practically write the VHDL state machine from the timing diagrams given in the device datasheet.  Generally, you will need to slow down the clock.  Again, check the datasheet.

I have attached a .zip file with code to read a MCP23S17 port expander.  It is specific to my project and probably not coded in the way I would do it today.  It was from a project 12 years ago when I first started playing with FPGAs.  OTOH, it has been working for 12 years...

ETA:  I divided down the 50 MHz system clock by a factor of 8 to get 6.25 MHz for the SPI connection.  Plenty slow enough for the 11 MHz maximum clock rate of the chip.

I'm just reading some console entry switches, speed isn't an issue.
« Last Edit: June 09, 2018, 11:22:22 pm by rstofer »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf