I have an IR pyroelectic flame sensor which detects flames within the 8-10hz of flame flicker. I am new to the ADC world so any help is very appreciated.
I have the py0573 which has a bandpass filter for CO2 spectrum. According to the company’s algorithm recommendation, I basically need to plot/detect FFT (Fast Fourier transform) bins from the 5-15hz frequency to determine a “flame” exists on the FOV of the sensor.
In order for me to read the signal from the half-rail, I installed a MCP3008 to my RPi model 4 and set the signal to CH0 of the ADC. I also included a .1uf decoupling capacitor.
Using the below code, I am able to get some readings from the sensor, but I am unsure if this sampling rate is setup correctly or not.
- How do I setup the read from the ADC within the 8-10hz range?
- Is there a way to plot this with FFT? Do I need FFT or can I determine the total sum values from ADC to indicate a “flame”?
- Is the frequency setup basically the loop speed of Python or the spi.max_speed_hz option?
- Am I converting the raw ADC values correctly using numpy interp?
- If the sensor has a max 10hz frequency then I need to double that for my sample rate?
- Should I be using Adafruit’s adafruit-circuitpython-mcp3xxx package instead?
With the below code, I am able to see the values change when I light a flicker match but its a bit inconsistent and only changes when the flame is flickering and not when its still.
import spidev from numpy import interp import time import datetime from datetime import timedelta # Start SPI connection spi = spidev.SpiDev() # Created an object spi.open(0,0) # Read MCP3008 data def analogInput(channel, hz): spi.max_speed_hz = hz adc = spi.xfer2([1,(8+channel)<<4,0]) data = ((adc&3) << 8) + adc return data data_list=list() init_time = datetime.datetime.now() while True: output1 = analogInput(0, 1000000) output1 = interp(output1, [0, 1023], [0, 100]) data_list.append(output1) if init_time < datetime.datetime.now() - timedelta(seconds=2): print("min" + str(min(data_list))) print("max" + str(max(data_list))) print("avg" + str(sum(data_list)/len(data_list))) data_list=list() init_time = datetime.datetime.now() time.sleep(.001)
- (1) Question “How do I setup the read from the ADC within the 8-10hz range?” – Answer, you just do conversions at a rate you want, up 200k samples per second. So eg if you want to have 10 conversions per second, you just read ADC conversion results 10 times per second, or repeat every 100mS. In other words, you just do one “single shot” conversion any time you want, within the limit of 200k conversion per second. – tlfong01 4 hours ago
- 1So whats is the SPI frequency setting doing exactly? Is that just the speed the RPI can read from the ADC or should I limit the frequency to 10hz for the flicker of the frame? – GeorgetheCat 4 hours ago
- 1For FFT, I can store each conversion from the loop in a list, but how can I plot FFT per frequency range from 8-10hz? – GeorgetheCat 4 hours ago
- 1Ok I updated the code to 100kHz and updated to sample every .001s to dump into a list. The basic statistics give print every 2 seconds, and so far the avg hovers around 50value and when i flicker a flame, the min drops to around 40 while the simultaneously the max jumps to around 60 or more. Is it odd for the sensor to drop and also increase in values at the same time? – GeorgetheCat 3 hours ago
- 1I am using the 3.3v not 5v. I though 5v would kill RPI using MCP3008. I do not have a scope. I do not have any other documentation other than what I shared. And company shared some FFT algorithm but its very vague. Do I need any resistor values? I also have a .1uf capacitor to decouple. Do I need an external amplifier even though it has an internal one? – GeorgetheCat 2 hours ago
How to use Rpi python MCP3008 ADC to help analyse flame flicker signals?
- A py0573 bandpass filter is used for CO2 spectrum
- To determine if a “flame” exists on the FOV of the sensor, the vendor recommends a plot/detect FFT bins from the 5-15hz frequency.
- Max. Voltage (+V) = 8.0 V
- Min. Voltage (+V) = 2.7 V
- Output voltage normalised around mid-rail
- Time Constant = ~12 ms
- Op-Amp with 10 GΩ feedback resistor
/ to continue , …
Appendix A – Pyroelectric Flame Sensor PY-ITV Datasheet Summary
The Pyreos thin film pyroelectric infrared flame detectors offer exceptionally high responsivity, a wide field of view of typically 100° (*subject to filter band pass specification) and class leading rapid recovery from thermal and electrical shocks (<1 second downtime). This current mode sensor has excellent signal to noise at the signature 8-10 Hz flicker range of a flame, and can provide accurate discrimination of flame sources in triple IR flame detection systems.
The sensor element is built into a low noise circuit that has an internal CMOS op amp with a 10GΩ feedback resistor outputting a voltage signal centred around half the supply rail.
Filter aperture = 5.2 mm x 4.2 mm
Element size = 1000 µm x 1000 µm
Package = TO39
Responsivity = 1 150,000 V/W
D* = 3.5 x 108 cm√Hz/ W
Noise = Mean 70 µV√Hz
Field of View = Typical 100°
Max. Voltage (+V) = 8.0 V
Min. Voltage (+V) = 2.7 V
Output voltage normalised around mid-rail
Time Constant = ~12 ms
Operating Temperature = -40 to +85 °C
Storage Temperature = -40 to +110 °C
Op-Amp with 10 GΩ feedback resistor
Filter As per Filters Available table
Appendix B – Package Info and Internal Schematic
/ to continue, …