Interfacing a temperature sensor with PLD without implementing SPI/I2C bus - Page 1
Forum section: electronics / general

author: garvind25
author_rank: Regular Contributor
timestamp: May 03, 2018, 05:23:23 pm
content: 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

author: joshtyler
author_rank: Contributor
timestamp: May 03, 2018, 06:23:15 pm
content: 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.

author: langwadt
author_rank: Super Contributor
timestamp: May 03, 2018, 08:16:56 pm
content: there's quite few temperature sensors with pwm output

author: garvind25
author_rank: Regular Contributor
timestamp: May 08, 2018, 04:18:39 pm
content: 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

author: Bassman59
author_rank: Super Contributor
timestamp: May 08, 2018, 09:49:49 pm
content: Quote from: garvind25 on May 08, 2018, 04:18:39 pmAn 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).

author: garvind25
author_rank: Regular Contributor
timestamp: May 09, 2018, 04:39:43 am
content: 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

author: JustMeHere
author_rank: Frequent Contributor
timestamp: May 12, 2018, 06:02:49 am
content: Look for Adafruit MAX31855 driver. It has a bit bang SPI example.

author: garvind25
author_rank: Regular Contributor
timestamp: June 09, 2018, 05:00:34 pm
content: Thanks for the replies. I forgot o mention that I was looking for a SPI interface in VHDL.Regards,Arvind Gupta

author: NiHaoMike
author_rank: Super Contributor
timestamp: June 09, 2018, 06:31:06 pm
content: Quote from: Bassman59 on May 08, 2018, 09:49:49 pmThe 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.

author: rstofer
author_rank: Super Contributor
timestamp: June 09, 2018, 09:29:47 pm
content: There will almost certainly be examples of SPI on opencores.orgYou 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.