Tumgik
#Analog to digital converter schematic
bclascl · 2 years
Text
Analog to digital converter schematic
Tumblr media
ANALOG TO DIGITAL CONVERTER SCHEMATIC CODE
Two AD654 voltage-to-frequency convertersįlash ADCs, also known as parallel ADCs, are one of the fastest ways to convert an analog signal to a digital signal.Solderless breadboard and jumper wire kit.Transfer function for an ideal ADC.Īny analog input in this range gives the same digital output code. These errors are reflected in a number of AC and DC performance specifications associated with ADCs. However, ADC operation in the real world is also affected by nonideal effects, which produce errors beyond those dictated by converter resolution and sample rate. So, for an N-bit ADC, there are 2 N codes and 1 LSB = FS/2 N, where FS is the full-scale analog input voltage.
ANALOG TO DIGITAL CONVERTER SCHEMATIC CODE
In an ideal ADC, the code transitions are exactly 1 least significant bit (LSB) apart. Sampling and quantization are important concepts because they establish the performance limits of an ideal ADC. A criterion for undersampling is that the ADC has sufficient input bandwidth and dynamic range to acquire the highest frequency signal of interest. This technique is known as undersampling. However, this aliasing process can be exploited in communications systems design to downconvert a high frequency signal to a lower frequency. Aliasing is a condition in which frequency signals outside the desired signal band will, through the sampling process, appear within the bandwidth of interest. This theory states that the signal frequency must be less than or equal to one-half the sampling frequency to prevent aliasing. This process determines the maximum bandwidth of the sampled signal in accordance with the Nyquist theorem. The sampling process represents a continuous-time domain signal with values measured at discrete and uniform time intervals. That error determines the maximum dynamic range of the converter. The analog input signal will fall between the quantization levels because the converter has finite resolution, which results in an inherent uncertainty or quantization error. The ADC produces 2 N digital values where N represents the number of binary output bits. The ADC represents an analog signal, which has infinite resolution, as a digital code that has finite resolution. Digital output code.Īn ADC carries out two processes: sampling and quantization. The resolution of the converter is set by the number of binary bits in the output code. The value is obtained by dividing the sampled analog input voltage by the reference voltage and then multiplying by the number of digital codes. The digital value appears on the converter’s output in a binary coded format. Analog-to-digital conversion.Īn ADC samples an analog waveform at uniform time intervals and assigns a digital value to each sample. This digital representation can then be processed, manipulated, computed, transmitted, or stored. BackgroundĪnalog-to-digital converters (ADCs) translate analog signals-real-world signals like temperature, pressure, voltage, current, distance, or light intensity-into a digital representation of that signal. The purpose of this lab activity is to explore the concepts of analog-to-digital conversion by building explanatory examples. The input impedance of this circuit is about 22 kilohms, and the time of conversion - less than 300 ns.ADALM2000 Activity: Analog-to-Digital ConversionĪndreea Pop, Antoniu Miclaus, Mark Thoren, and One of the possible approaches to construct this device is shown in Figure 2. If the required accuracy of analog to digital conversion does not exceed four bits, then as the basis for the ADC can be used quad CMOS logic elements "NAND" or "NOR". Most of the modern op amps is satisfied for these requirements, the inverting inputs of this op amps should be connected to the Vcc/2 (half of power supply voltage). In addition, the comparator must have a high input and low output impedance. Input voltage which can range from zero up to power supply voltage (Vcc) converts to parallel additional binary code at the outputs of the converter.įor normal operation of the ADC requires that the inverter-comparators A1-A4 should be able to switch when the voltage on their inputs equal to Vcc/2 and an error must be no more than Vcc/(2 n-2) (n - number of bits of binary code at output), and the output voltage of the comparator in on/off states should be close to zero and to the Vcc. The simplest Analog to Digital Converter (ADC) can be constructed as shown in Figure 1.
Tumblr media
1 note · View note
Text
Introduce To Analog Devices ADUM3474ARSZ
PWM Controller and Transformer Driver with Quad-Channel Isolators ADUM3474ARSZ
GENERAL DESCRIPTION The ADuM3470/ADuM3471/ADuM3472/ADuM3473/ ADuM3474 devices1 are quad-channel digital isolators with an integrated PWM controller and transformer driver for an isolated dc-to-dc converter. Based on the Analog Devices, Inc., iCoupler® technology, the dc-to-dc converter provides up to 2 W of regulated, isolated power at 3.3 V to 24 V from a 5.0 V input supply or from a 3.3 V supply. This eliminates the need for a separate, isolated dc-to-dc converter in 2 W isolated designs. The iCoupler chip scale transformer technology is used to isolate the logic signals, and the integrated transformer driver with isolated secondary side control provides higher efficiency for the isolated dc-to-dc converter. The result is a small form factor, total isolation solution. The ADuM347x isolators provide four independent isolation channels in a variety of channel configurations and data rates.
Tumblr media
FEATURES Isolated PWM controller Integrated transformer driver Regulated adjustable output: 3.3 V to 24 V 2 W output power 70% efficiency at guaranteed load of 400 mA at 5.0 V output Quad dc-to-25 Mbps (NRZ) signal isolation channels 20-lead SSOP package High temperature operation: 105°C maximum High common-mode transient immunity: >25 kV/µs 200 kHz to 1 MHz adjustable oscillator frequency Soft start function at power-up Pulse-by-pulse overcurrent protection Thermal shutdown
Safety and regulatory approvals UL recognition: 2500 V rms for 1 minute per UL 1577 CSA Component Acceptance Notice #5A VDE certificate of conformity DIN V VDE V 0884-10 (VDE V 0884-10):2006-12 VIORM = 560 V peak Qualified for automotive applications
APPLICATIONS RS-232/RS-422/RS-485 transceivers Industrial field bus isolation Power supply start-up bias and gate drives Isolated sensor interfaces Process controls Automotive
SPECIFICATIONS ELECTRICAL CHARACTERISTICS—5 V PRIMARY INPUT SUPPLY/5 V SECONDARY ISOLATED SUPPLY 4.5 V ≤ VDD1 = VDDA ≤ 5.5 V; VDD2 = VREG = VISO = 5.0 V; fSW = 500 kHz; all voltages are relative to their respective grounds (see the application schematic in Figure 38). All minimum/maximum specifications apply over the entire recommended operating range, unless otherwise noted. All typical specifications are at TA = 25°C, VDD1 = VDDA = 5.0 V, VDD2 = VREG = VISO = 5.0 V.
0 notes
ovaga-technologies · 2 months
Text
STM32F103C6T6 Datasheet, Pinout, and Specifications
The STM32F103C6T6 is a powerful microcontroller known for its versatility and performance. It belongs to the STM32F1 series produced by STMicroelectronics, offering a wide range of features and capabilities. This microcontroller is highly regarded in the world of embedded systems and microcontroller applications due to its robustness, cost-effectiveness, and ease of use. Its popularity stems from its ability to cater to a wide range of applications, from simple DIY projects to complex industrial automation systems. In this article, we'll provide an overview of theSTM32F103C6T6, exploring its specifications, schematic, pinout, programming, datasheet, and more details.
Tumblr media
Description of STM32F103C6T6
The STM32F103C6T6 performance line family integrates the high-performance ARM Cortex-M3 32-bit RISC core, operating at a frequency of 72 MHz. It features high-speed embedded memories (Flash memory up to 32 Kbytes and SRAM up to 6 Kbytes) and a wide range of enhanced I/Os and peripherals connected to two APB buses. All devices offer two 12-bit ADCs, three general-purpose 16-bit timers plus one PWM timer, as well as standard and advanced communication interfaces: up to two I2Cs and SPIs, three USARTs, a USB, and a CAN.
The STM32F103C6T6 low-density performance line family operates from a 2.0 to 3.6 V power supply. It is available in both the –40 to +85 °C temperature range and the –40 to +105 °C extended temperature range. A comprehensive set of power-saving modes allows for the design of low-power applications.
The STM32F103C6T6 low-density performance line family includes devices in four different package types, ranging from 36 pins to 64 pins. Depending on the chosen device, different sets of peripherals are included. The following description provides an overview of the complete range of peripherals proposed in this family.
These features make the STM32F103C6T6 low-density performance line microcontroller family suitable for a wide range of applications such as motor drives, application control, medical and handheld equipment, PC and gaming peripherals, GPS platforms, industrial applications, PLCs, inverters, printers, scanners, alarm systems, video intercoms, and HVACs.
Features of STM32F103C6T6
ARM 32-bit Cortex™-M3 CPU Core: The microcontroller is powered by an ARM Cortex™-M3 CPU core, capable of operating at a maximum frequency of 72 MHz. It delivers a performance of 1.25 DMIPS/MHz (Dhrystone 2.1) with 0 wait state memory access and supports single-cycle multiplication and hardware division.
Versatile Memories: The STM32F103C6T6 features 16 or 32 Kbytes of Flash memory for program storage and 6 or 10 Kbytes of SRAM for data storage.
Clock, Reset, and Supply Management: It supports 2.0 to 3.6 V application supply and I/Os. The microcontroller includes a Power-On Reset (POR), a Power-Down Reset (PDR), and a programmable voltage detector (PVD). It also features a 4-to-16 MHz crystal oscillator, an internal 8 MHz factory-trimmed RC oscillator, and an internal 40 kHz RC oscillator. Additionally, it provides a PLL for the CPU clock and a 32 kHz oscillator for the Real-Time Clock (RTC) with calibration.
Low Power: The STM32F103C6T6 offers Sleep, Stop, and Standby modes for power optimization. It includes VBAT supply for RTC and backup registers.
2 x 12-bit, 1 µs A/D Converters: The microcontroller is equipped with two 12-bit analog-to-digital converters (ADC) with up to 16 channels. It has a conversion range of 0 to 3.6 V and supports dual-sample and hold capability. Additionally, it features a temperature sensor.
Direct Memory Access (DMA): It includes a 7-channel DMA controller that supports peripherals such as timers, ADC, SPIs, I2Cs, and USARTs.
Up to 51 Fast I/O Ports: The STM32F103C6T6 offers 26/37/51 I/Os, all mappable on 16 external interrupt vectors. Almost all ports are 5 V-tolerant, providing flexibility in interfacing with various external devices.
STM32F103C6T6 Specifications
TypeParameterCoreARM Cortex M3
Core Size
 32-Bit Single-CoreProgram Memory Size32 kBData Bus Width32 bitADC Resolution12 bitMaximum Clock Frequency72 MHzRAM Size10K x 8Supply Voltage - Min1.8 V, 2 VSupply Voltage - Max3.6 VVoltage - Supply (Vcc/Vdd)2V ~ 3.6VConnectivityCANbus, I2C, IrDA, LINbus, SPI, UART/USART, USBPeripheralsDMA, Motor Control PWM, PDR, POR, PVD, PWM, Temp Sensor, WDTNumber of I/Os48 I/O
Operating Temperature
 -40°C ~ 85°C (TA)
Package / Case
48-LQFP
Absolute Maximum Ratings
SymbolRatingsValueVDD − VSSExternal main supply voltage (including VDDA and VDD)–0.3V ~ 4.0VVINInput voltage on five volt tolerant pinVSS − 0.3V ~ VDD + 4.0VInput voltage on any other pinVSS − 0.3V ~ 4.0V|VDDx|Variations between different VDD power pins50mV|VSSX −VSS|Variations between all the different ground pins50mVVESD(HBM)Electrostatic discharge voltage (human body model)2000VIVDDTotal current into VDD/VDDA power lines (source)150mAIVSSTotal current out of VSS ground lines (sink)150mAIIOOutput current sunk by any I/O and control pin 25mAOutput current source by any I/Os and control pin-25mAIINJ(PIN)Injected current on five volt tolerant pins-5/+0mAInjected current on any other pin± 5mAΣIINJ(PIN)Total injected current (sum of all I/O and control pins)± 25mATSTGStorage temperature range–65°C to +150°CTJMaximum junction temperature150°C
STM32F103C6T6 Pinout
Tumblr media
STM32F103C6T6 Application
Motor Drives
The STM32F103C6T6 is used in motor drive systems to control the speed and direction of motors in various applications, such as industrial machinery, robotics, and automotive systems.
Application Control
It is utilized for controlling the operation of various applications, including home automation systems, smart appliances, and industrial automation equipment.
Medical and Handheld Equipment
Due to its low power consumption and high processing capabilities, the microcontroller is employed in medical devices such as portable monitoring systems, infusion pumps, and handheld diagnostic tools.
PC and Gaming Peripherals
STM32F103C6T6 is used in peripherals for PCs and gaming consoles, such as keyboards, mice, and game controllers, to provide efficient and reliable control interfaces.
GPS Platforms
It is used in GPS tracking devices and navigation systems to process location data and provide accurate positioning information.
Industrial Applications
Due to its robustness and reliability, the microcontroller is widely used in various industrial applications, including factory automation, process control, and monitoring systems.
PLCs (Programmable Logic Controllers)
It is utilized in PLCs for controlling and monitoring industrial processes and machinery.
Inverters
STM32F103C6T6 is used in power inverters, which convert DC power to AC power in applications such as solar power systems and uninterruptible power supplies (UPS).
Printers and Scanners
It is used in printers and scanners for controlling printing and scanning functions, providing fast and efficient operations.
Alarm Systems
The microcontroller is used in alarm systems for detecting and signaling unauthorized entry or other security breaches.
Video Intercoms
It is used in video intercom systems for communication and remote access control in residential and commercial buildings.
HVAC (Heating, Ventilation, and Air Conditioning)
STM32F103C6T6 is used in HVAC systems for controlling temperature, humidity, and air quality, ensuring comfortable and energy-efficient indoor environments.
STM32F103C6T6 Programming
To program the STM32F103C6T6, developers can use a variety of development tools and integrated development environments (IDEs) such as Keil, STM32CubeIDE, and Arduino IDE. These tools provide a user-friendly interface for writing, compiling, and debugging code for the microcontroller.
IDEs for STM32F103C6T6
Several integrated Development Environments (IDEs) support STM32F103C6T6, including the STM32CubeIDE, Keil uVision, and CoIDE. Each offers a unique set of features, catering to different programming needs and preferences.
STM32CubeIDE
STM32CubeIDE is an official IDE from STMicroelectronics for STM32 development. It integrates the STM32Cube library, providing a comprehensive software infrastructure to streamline the programming process.
Keil uVision
Keil uVision is another popular choice. It offers robust debugging capabilities, making it easier for developers to identify and resolve errors in their code.
STM32CubeMX is a graphical tool that helps developers configure the microcontroller and generate initialization code quickly. It allows users to configure peripherals, pin assignments, and clock settings, among other parameters. Then, it generates the corresponding initialization code in C language, which can be easily integrated into the development environment.
Another essential aspect of programming the STM32F103C6T6 is understanding the HAL (Hardware Abstraction Layer) libraries provided by STMicroelectronics. HAL libraries abstract the low-level hardware details, providing a standardized interface for interacting with the microcontroller's peripherals. This abstraction simplifies the development process and makes the code more portable across different STM32 microcontrollers. Understanding how to use HAL libraries is essential for efficiently programming the STM32F103C6T6 and leveraging its full potential in embedded applications.
STM32F103C6T6 Equivalent/Alternative
STM32F103C8T6.
STM32F103C6T6 Package
Tumblr media
STM32F103C6T6 Manufacturer
STMicroelectronics, a global leader in semiconductor manufacturing, is the proud manufacturer of the STM32F103C6T6 microcontroller. With a strong focus on innovation and quality, STMicroelectronics has established itself as a trusted name in the electronics industry. The company's commitment to excellence is evident in the STM32F103C6T6, which boasts high performance, reliability, and versatility. STMicroelectronics' dedication to customer satisfaction and technological advancement makes it a preferred choice for engineers and designers worldwide.
STM32F103C6T6 Datasheet
Download STM32F103C6T6 Datasheet PDF.
Conclusion
In conclusion, the STM32F103C6T6 microcontroller stands out as a versatile and powerful solution for embedded systems design. Its advanced features, including a 32-bit ARM Cortex-M3 core, a wide range of peripherals, and low power consumption, make it ideal for a variety of applications. It provides developers with a powerful tool to create innovative and efficient solutions for a wide range of applications.
0 notes
veworfone · 2 years
Text
Analog to digital converter calculator
Tumblr media
#ANALOG TO DIGITAL CONVERTER CALCULATOR SERIES#
The schematic is accompanied by a brief description of the key aspects of the design, and in some cases, also links to another built-in utility that can be used to further refine the component selection. In Expert mode, the designer is presented with all 24 possible solutions in block diagram form, and simply clicks on the desired topology, which goes straight to the solution schematic.
#ANALOG TO DIGITAL CONVERTER CALCULATOR SERIES#
In Beginner mode, the designer answers a series of questions, and then is presented with a schematic of the solution, and in some cases, optional versions of the solution. Two modes are offered: Beginner mode and Expert mode. AC-coupled and DC-coupled designs are supported, as well as single supply and dual supply topologies. The available topologies cover differential, single-ended and transformer-coupled input designs. It offers 24 different op-amp based buffer circuits that can be used to drive an ADC input. ADC-INPUT-CALC is an online tool that provides support for designing the input buffer to an analog-to-digital converter (ADC).
Tumblr media
1 note · View note
medfetabdl · 2 years
Text
Tumblr media Tumblr media
Ecg Amplifer circuit 2.0
I noticed that my last ecg amplifier circuit got quite a few views so I thought I’d try a different circuit aiming for less noise. The waveform looks pretty clean in the last post but it’s still pretty noisy. This is a different circuit I found online that uses 5 UA741/ LM741 single operational amplifiers instead of the LM324 quad operational amplifier. I think 5 single op amps is a little bit easier to troubleshoot than a single quad op amp. Although I do pick up more EMI noise from the 5 single op amps because there’s more jumper wires which makes more antennas. The nice part about this circuit is it’s easier to break down into portions. In the schematic, the yellow portion is 3 op amps forming an instrumentation amplifier which amplifies the ecg signal. The orange portion is a notch filter which filters out 60hz noise from power supplies and capacitive coupling to the electrical grid. The blue portion is a low pass filter to filter out any EMI (electromagnetic interference) that might be picked up in the circuit. The pink portion is a high pass filter which blocks any noise below 0.5Hz. On the last circuit I found I got better results with no ground electrode, in this circuit you absolutely need the ground electrode because takes all the noise out of the circuit. The results of this circuit are pretty good, but you have to stay extremely still to get a good reading. I have an AD8232 module on the way with leads and real electrodes. The AD8232 is a miracle little integrated circuit (IC) that has an instrumentation amplifier and filters built in as well as a built in digital to analog converter for use with microcontrollers. And it’s all smaller than the tip of your pinky. I plan to use the analog output and hook it up directly to my oscilloscope. If you have questions message me.
8 notes · View notes
fuzzkaizer · 4 years
Photo
Tumblr media Tumblr media Tumblr media
FUZZOLOGY AND WAVE SHAPING
“I made some simulation on my pc (because I don't have an oscilloscope) and compared the different circuits, like the classical Hm2, Big muff and others, and they producing (in most cases) basically clipped sine and squared signals. They look and sound different, but also a bit similar. While mine looks noting like those, so it may sound a bit unusual, of course, these are just simulations, and some times they are not correct.... So, what is your best unusal distortion effect? Or any strange idea? I havent heard anything, like my design, yet, but almost sure that there are other strange distortions, maybe there is one that similarly use triangle waveform or something...or what is the most important difference between them? “
“ In the Meastro W-2/3 schematics there is what they call a “sawtooth converter” There is also a “squarer” circuit. “
“Just converting to a single wave shape ( sine trangle, sawtooth )  will just sound like a  fixed tone like a oscillator. The string generates changing Harmonics that give the sound character.  Sharper edges represent High freq harmonics,and rounder is the fundimental. As the String moves around it changes its harmonics.. also depending where on the string you picked”
visualizing vibrations on singin strings: https://youtu.be/ttgLyWFINJI
soundcard scope: https://www.zeitnitz.eu/scope_en?fbclid=IwAR0NAhKXatT5-uj_o-_oOx7HYCBLHTfmj0AxnajbIHUh9_c-uTB0MxdZXT8
“ Arbitrary waveforms are much easier to convert/generate in the digital domain from an input but in the analog domain, and only for mono inputs.... if you've ever tried this stuff, you know how un-sine-like a guitar output actually is, especially during the transient, and highly dependent as to pick-up, picking position, tone control, etc... SINE : An adaptive filter can give you a pure sine output. Easy to implement on a limited octave range, such as the filters in the Roland GR-300. More complex would be a Wiener filter (yes, it's a real thing named after Norbert Wiener). SQUARE : Can be generated from a comparator using a little bit of negative feedback, but you lose dynamics - you would need to sidechain an envelope followed VCA to preserve dynamics. If you go adaptive filter, you can can also control a second adaptive lowpass filter to roll off upper harmonics and get things like a triangle-ish output. RAMP/SAWTOOTH : Run a sine through a wideband all-pass network, or Hilbert filter, and you get a 90 degree, psuedo-sine-cosine relationship between inputs regardless of frequency. An analog divider and trig IC can take the two signals, divide them and take the arctangent, which gives you a linear ramp/sawtooth. TRIANGLE : Take the ramp, half wave rectify for the upswing - take the negative half, and phase invert by 180 degrees. Combine and you have a smooth triangle, but no longer AC biased, and 1/2 the scale of the original ramp.”
Fourier transformation: https://youtu.be/spUNpyF58BY
Tumblr media
"The output counter is gated by the input signal to be synced in real time. The amplitude output can be tuned by adjusting r/c to be within 1 or 2 cycles. “
Tumblr media Tumblr media
... and the thread goes on...
 cred: facebook.com/Dominik Ács, Jackson Son, Larry Kenny, Bosley D Bosley,
50 notes · View notes
spaceexp · 4 years
Text
55 Years Ago: Mariner 4 First to Explore Mars
NASA - Mariner-4 Mission patch. July 15, 2020 On the night of July 14-15, 1965, the Mariner 4 spacecraft made history when it completed the first flyby reconnaissance of Mars after a 228-day journey from Earth. Programmatically, Mariner 4’s journey began in November 1962, when NASA approved the Mariner Mars 1964 Project to send two spacecraft to fly by Mars to take photographs and make other measurements during the encounter. The Jet Propulsion Laboratory (JPL) in Pasadena, California, managed the project, building on its experience from the successful Mariner 2 encounter with Venus in December 1962.
Above: Diagram by Schiaparelli showing his observations of canali. Below: The best Earth-based telescopic image of Mars prior to Mariner 4’s mission, from the favorable 1956 opposition. Image Credits: Mt. Wilson Observatory.
Compared with our deeper yet still incomplete understanding of the Red Planet today, scientists in the 1960s knew relatively little about Mars. In the late 19th century, Italian astronomer Giovanni Schiaparelli claimed to have observed linear patterns on the surface of the planet that he called canali, which unfortunately were mis-translated into English as canals, leading some to believe they were built by intelligent beings on Mars. Although that idea fell out of favor among scientists by the early 20th century, it did permeate into science fiction as well as popular culture. Notions of a planet with a global climate relatively similar to Earth’s, including the possibility that it harbored some form of extraterrestrial life, remained popular even among scientists into the 1960s. The best Earth-based telescopic images of Mars revealed little surface detail but did show areas that changed size, shape and color with the Martian seasons, indicative to some observers of at least some form of simple plant-like life forms.
Above: Photograph of the Mariner 3 and 4 spacecraft. Below: Schematic of the Mariner 4 spacecraft indicating the science instruments. Images Credit: NASA.
To carry out their observations during their transit from Earth and during their flybys of Mars, each of the 575-pound Mariner Mars 1964 spacecraft carried seven science instruments: - The television imaging system enabled topographic reconnaissance of the Martian surface. - The Helium Magnetometer measured magnetic field strength around the planet. - The Ionization Chamber and particle flux detector measured the omnidirectional flux of particle radiation near Mars and in interplanetary space. - The Cosmic Dust Detector measured dust particle momentum and mass distribution. - The Cosmic Ray Telescope measured charged particles. - The Trapped Radiation Detector consisted of three Geiger-Muller detectors to measure any charged particles that may be trapped by a Martian magnetic field. - The Solar Plasma Probe measured the density, velocity, temperature, and direction of movement of protons streaming from the Sun. Each spacecraft generated 310 watts of electrical power at Mars from photovoltaic cells mounted on four solar panels mounted in a windmill-like arrangement around the probe’s octagonal frame. Mounted on the end of each solar panel were steerable pressure vanes to use the solar wind to control the spacecraft’s orientation. The experimental pressure vanes supplemented a set of nitrogen gas thrusters for attitude control. The spacecraft converted the analog signal from the camera to digital format, and following the flyby transmitted the photographs back to Earth at a rate of 8 1/3 bits per second, seemingly glacial today but, as the first digital imaging system used beyond Earth, considered state of the art for the mid-1960s. Each photograph took 10 hours to relay to Earth.
Above: Launch of Mariner 4. Below: Trajectory of Mariner 4 to Mars. Images Credit: NASA.
The first of the two spacecraft, Mariner 3, launched from Cape Kennedy Air Force Station, Florida, on Nov. 5, 1964, atop an Atlas-Agena D rocket. Due to the failure of the spacecraft’s payload shroud to jettison, its solar panels could not deploy and Mariner 3 sailed on into solar orbit as an inert spacecraft. Beneath a hastily redesigned payload shroud, the second spacecraft, Mariner 4, successfully launched on Nov. 28, just two days before the close of the launch window. During the eight-month cruise phase to Mars, the spacecraft took measurements on the conditions of interplanetary space and relayed the data to Earth. On July 14, 1965, Mariner 4 passed within 6,118 miles of Mars, snapping 22 photographs of the planet and taking scientific measurements. The spacecraft passed behind the planet as seen from Earth, allowing a radio occultation study to estimate the density of the Martian atmosphere. Playback of the flyby imagery began soon after Mariner 4 emerged from behind Mars and continued until Aug. 3.
Schematic representation of Mariner 4’s flyby of Mars. Image Credit: NASA.
At JPL, a "real-time data translator" machine converted the Mariner 4 digital image data into numbers printed on strips of paper. Too anxious to wait for the official processed image, employees from the Telecommunications Section attached these strips side by side to a display panel and hand colored the numbers like a paint-by-numbers picture. The completed image was framed and presented to JPL director William H. Pickering.
A hand-rendered picture from data transmitted by Mariner 4, made by eager engineers who didn’t want to wait for the official image. Image Credit: NASA.
The radio occultation results indicated a very low surface atmospheric pressure, about 1% that at Earth’s sea level. Scientists estimated the surface temperature at about -100o C and the spacecraft detected no magnetic field or trapped radiation belts around the planet. The photographs revealed a cratered surface resembling the Moon, although the photographs covered less than 1% of the Martian surface and did not represent Mars as we know it today.  By sheer chance, Mariner 4 imaged some of the oldest and most heavily cratered terrain on Mars, missing some of the more diverse and geologically more recent features. All in all, these findings dashed many scientists’ expectations of Mars as a place hospitable to life.
Above: Global image of Mars indicating the areas imaged by Mariner 4. Below: The highest resolution of the Mariner 4 photographs taken from a distance of 7,830 miles showing a cratered surface. Images Credit: NASA.
Although the images and data that Mariner 4 returned may have the dashed the hopes of some scientists that Mars harbored some form of life, its results should be placed in proper perspective. The imagery covered about 1% of the planet’s surface and the best resolution achieved was just under a mile per pixel, with significantly less on many of the images. When compared with imagery acquired later by spacecraft with more sophisticated imaging systems, it’s clear that as ground-breaking as Mariner 4 was, it missed a great deal. The photographs below of the same area (southern Amazonia Planitia) on Mars show the progressive improvement in resolution achieved as newer technology became available, beginning with the Mariner 4 photograph, followed by the Viking 1 Orbiter in 1980, the Mars Express orbiter in 2012 and finally the High Resolution Imaging Science Experiment (HiRISE) instrument aboard Mars Reconnaissance Orbiter in 2017 (the yellow rectangle in the preceding three photos), with a resolution of 50 centimeters per pixel.
Photographs of the same area in the southern Amazonia Planitia region on Mars as viewed by spacecraft over the years (above to below) Mariner 4 in 1965, Viking 1 Orbiter in 1980, Mars Express in 2012 and Mars Reconnaissance Orbiter in 2017. Images Credits: University of Arizona.
Having completed the first scientific reconnaissance of Mars, Mariner 4 sailed on in solar orbit, conducting engineering tests of its imaging and propulsion systems, showing no degradation after years in space. In late 1965, the spacecraft passed on the other side of the Sun as viewed from Earth and set a communications distance record of 190 million miles. In October 1967, engineers conducted tests with Mariner 4’s attitude control system to support the Mariner 5 spacecraft then approaching Venus. Finally, after running out of attitude control gas, Mariner 4 could no longer point its solar arrays toward the Sun and contact with the spacecraft was lost on December 21, 1967. Related links: Mariner: https://www.nasa.gov/mission_pages/mariner Mariner 2: https://www.nasa.gov/feature/55-years-ago-mariner-2-first-to-venus Mariner 4: https://www.nasa.gov/mission_pages/mariner Images (mentioned), Text, Credits: NASA/Kelli Mars/JSC/John Uri. Greetings, Orbiter.ch Full article
15 notes · View notes
open-e-drums · 5 years
Text
Using a LCD Shield
I received an email that said, "I want to use LCD Keypad Shield.
Apparently, there is a shield with an LCD and 5 tact switches on it, which is sold by DFRobot.
I didn't even know what the shield was because I always used the LCD as a standalone module. However, it has 5 buttons, which is the same as the MIDI converter I made before, so it will be much easier to build a circuit with this shield.
So I got the shield, made by DFRobot, and bought it at amazon. A copy of HiLetgo would be cheaper.
However, it seems that you can't use the library as is. Because these five tact switches are read by a single analog pin. In my library, each tact switch is connected to one digital pin, so I need to add a new method.
This is a schematic, borrowed from HiLetgo.
There is a circuit for the tact switch in the center. It is a voltage divider circuit, and each button pressed leads to a resistor with a different value, so you know which button you pressed. This is useful.
It's a pain to consume one analog pin, but it's not a problem, especially if you use a multiplexer.
First, let's check the behavior using the sample AnalogReadSerial.ino originally included in the arduinoIDE. You don't have to make a circuit in particular. Just connect it.
This is the serial monitor when the button is pressed.
RIGHT : 0
UP : 205
DOWN : 405
LEFT : 622
SELECT : 823
none : 1023
Now that we know the value when the button is pressed, let's create a test code.
gist94cd6241f0acc96c6ae19c7f8691fc8d
This code only displays the name of the button you press on the LCD.
It is quite convenient that five buttons can be used only by connecting to Arduino UNO without building a circuit.
However, there seems to be a considerable individual difference in the value when the button is pressed. So the above code may also need to adjust the range of the if statement.
I've updated my library to use this button as well. You can update it from the IDE's library manager, or you can download it from the link below.
As mentioned above, there are individual differences, so adjustments may need to be made.
In the source code, lines 4279 to 4301 of hellodrum.cpp, there is an if statement to set the value of the button, so you can set it by editing the value there.
By simply connecting a shield and a piezo, you can edit the setting values using EEPROM. I think it would be easy to make a module if I made a shield to sandwich one more piece in between and put a multiplexer or jack on it.
2 notes · View notes
educationtech · 3 years
Text
Introduction to Power Electronics  - Arya College
Tumblr media
Power electronics converts electrical power from one form to another. A lot of energy is wasted during this power conversion process due to the efficiency conversion of low power. It is estimated by the students of top BTech colleges Jaipur that power wasted in desktop PCs sold in one year is equivalent to seventeen 500MW power plants. Therefore, it is very important to improve the efficiency of these power conversion systems.
The electric machine is an electromechanical energy conversion device that works and delivers power to the load. The same electric machine can operate as a motor to convert electrical power to mechanical power directly and can operate as a generator to convert mechanical power to electrical power. The electric machine is related with the power electronic converter and the related controller makes the motor drive. The power electronic converter is made of solid-state devices that handles power from the source to the motor input terminals.
A research has been conducted by the students of Electronics and Communication Engineering Colleges which shows that the area of electric machines and drives is focused on design optimization. It uses 2D and 3D finite element analysis, and drives design at the systems level by considering operating requirements and control opportunities. It seeks innovations in machine configurations, motor control concepts, noise, parameter identifications, vibration analysis. Motor drives are designed to make the system more efficient, smoother in operation, fault tolerant, smaller and matched to the applications. Modeling and design tools are developed to fulfil the machine design and drive development efforts.
1. Electric Vehicle Systems
Within a single century, the demand for private automobiles has been increased. It is projected that the need for personal mobility among the students of Top BTech Colleges Rajasthan will grow even faster, as large numbers of people are lifted out of poverty in developing countries and demand transportation. Emissions from oil-burning automobiles blocks our air and contribute to global warming. Due to this, finding an alternative to oil for private transportation is imperative. Although several alternatives can propel a car, only electricity is readily available.
With the introduction of electric propulsion, a completely new drive-train is introduced in the vehicle which requires multidisciplinary research into system components. The Electric vehicle system is comprised of power electronics converters, electric motor, and energy storage devices like batteries. Additionally, the overall system must be optimized to maximize overall system efficiency.
2. Electronic Energy Systems Packaging
Electronic Energy Systems Packaging encompasses technologies that focuses on the physical implementation of energy storage systems and power electronic. Electrical engineers of best engineering colleges in Jaipur develop circuits and schematics. It is delivered to a customer are electro-physical circuits concurrently combined and designed into a hardware system. These hardware systems must meet metrics like weight, power, and size densities; government and industry standards; and reliability.
This research is broad-based and multidisciplinary with studies in magnetic, electric, thermal and mechanical components and circuits. Students of Engg colleges focuses on high-frequency, high-density topologies that use ultrafast-switching power semiconductors, and the materials and fabrication processes create such topologies.
Applications are in new integrated power systems ranges from chip to ship like land-based smart grid power systems, electric vehicle converters and drives, high performance power supplies for aerospace, telecom and DC distribution systems, and ultrafast fault protectors using the latest in various semiconductors.
3. Power Electronics
The technology of Power electronics is associated with the efficient control, conversion, and conditioning of electric power by static means from its available input form into the desired electrical output form. Power electronic converters do not require modifying the electrical energy form. With “classical” electronics, electrical currents and voltage are used by the students of Top Private Engineering Colleges in Rajasthan to carry information, whereas with power electronics, they carry power.
A research has been conducted by the students of engineering colleges Jaipur in this area. It includes power electronics applications to control large scale power transmission and distribution with the integration of distributed and renewable energy sources into the grid.
4. Power Management ICs
Power management ICs are used by the students of top MTech colleges in Jaipur to manage the accurate power flow in portable and handheld devices like cell phone power amplifiers and LED display, Graphics, CPU, DRAM, High Speed I/O and USB. Additionally, under-voltage or other fault conditions are monitored to prevent damage to the system. The soft-start feature reduces stress on power supply components and increase the reliability of product. Typically, implementation is done using analog integrated circuits but there is a strong trend to move towards digital or mixed signal implementation.
5. Power Semiconductor Devices
Power semiconductor devices are mainly semiconductor devices used as switches or rectifiers in power electronic circuits. Also, they are called as power devices or when used in integrated circuits, called power ICs. A research has been conducted by the students of top MTech colleges to increase the maximum power handling capability of the power devices. On the other hand, it includes the need to increase the speed they can switch. Also, power semiconductor is the key in determining the power conversion efficiency.
6. Power Systems
Electric power systems are comprised includes the components that produce electrical energy and transmit this energy to consumers. A modern electric power system consists of different components like power plants which generate electric power, transformers which raise or lower the voltages as needed, transmission lines to carry power, substations at which the voltage is stepped down for carrying power over the distribution lines, and distribution transformers which lower the voltage to the level needed for the consumer equipment. The electricity production and transmission are relatively efficient and inexpensive. Although unlike other forms of energy, electricity is not easily stored, and must be produced based on the demand.
0 notes
shunlongwei · 3 years
Photo
Tumblr media
ADI’s RF Platform Hunkers Down on Phase Determinism for Defense Communication Https://www.slw-ele.com; Email: [email protected]
Analog Devices (ADI) has unveiled  This new platform consists of a small family of reference designs, starting with the and the   
Tumblr media
  The new 16TX/16RX quad mixed (digital/analog) radio front end. Image used courtesy of
  The Quad-MxFE platform is available as a complete reference design, including an RF signal chain, software architectures and application samples, and the power design architecture. The calibration board, which is also available, is programmable with MATLAB.
MATLAB algorithms allow users to confirm channelization metrics such as combined channel dynamic range, phase noise measurements, and most importantly, phase determinism. 
According to Analog Devices, this platform may be especially useful in aerospace and defense applications ranging from phased-array radars to SATCOM (satellite communications) on the ground.
  ADI’s Quad-MxFE Specifications
At its core, this new from ADI is a synchronized array of multiple analog-to-digital (ADCs) and digital-to-analog converter (DACs). The platform comes in two quad-array offerings, with the  or the  chipsets, which have 4D4A or 4D2A converters, respectively. 
Tumblr media
  Quad-MxFE's block diagram. Image used courtesy of
  Eight serializer/deserializers () interface with a (separate optional platform) operating at upwards of 24.75 Gbps/lane () or 15.5 Gbps/lane () to move digital data into and out of each of the four chips on the platform. 
  Beamforming Technology Basics
Beamforming technology has seen massive investment over the past several years, with the military investing significant resources in phased-array technology. Applications can utilize both conventional RF and  (radar detection and characterization). 
Commercially,  with the optimization of MIMO antenna systems.
Fundamentally, beamforming operates by introducing analog and digital delays into a coherent signal chain. These delays steer the direction of the aggregate main lobe propagating from the antenna superstructure. 
Tumblr media
  A phased array receiver with time delays used in beam-steering. Image used courtesy of
  The propagated signals will add constructively (and destructively) to generate (or receive) a wavefront in the direction of interest and suppress unwanted side lobes in the antenna pattern.
This procedure can be complicated, requiring strict timing constraints on the digitizer array. Each digitizer module's phase must be deterministically quantified with respect to the other modules of the array to generate coherent and useful wavefronts. 
ADI tackles this complexity at the sub-system with multi-chip calibration algorithms and system-level with the calibration board. 
  Multi-chip Synchronization Calibration and Phase Determinism
Electronically steering an antenna pattern using a phased array requires knowing each array element's relationship (phase). —just that they be quantified so that software adjustment can be performed to align them.  
The AD9081/AD9082 can synchronize each digitizer chip in the complete system by reprogramming DSP blocks such as:
Numerically controlled oscillators (NCOs)
Programming finite impulse response blocks for phase and amplitude
Tumblr media
  A schematic of the multi-chip calibration between baseband FPGA and the MxFE platform. Image used courtesy of
  In the sub-assembly, two procedures are completed: NCO master-slave sync and a one-shot sync, which is used to prepare the array for the NCO master-slave sync. These procedures bring the system one step closer to phase determinism by aligning specific inputs.  
After those two procedures are completed, the phase-locked loops on the Quad-MxFE are calibrated for thermal drift with the calibration board. 
Tumblr media
  Calibration board (left) interfaced to MxFE board (middle) and Xilinx Virtex FPGA (right). Image used courtesy of
  ADI says its new reference design will help simplify prototyping and proliferation of advanced phased-array communication technology, especially for military, aerospace, and commercial applications.
    Do you work with phased-array applications for telecommunications? What aspect interests you the most about this new mixed RF design? Let us know in the comments below.
0 notes
cdrforea · 4 years
Text
Analog to Digital Converter
New Post has been published on https://cdrforea.com/analog-to-digital-converter/
Analog to Digital Converter
Tumblr media
What is Analog to Digital Converter
Analog to digital converter (ADC) or quantizer is a device with converts’ analog signal into discrete-time signal in the form of bits representing the magnitude of the input viz. voltage or current. An ADC consisted of analog input, sampling clock, buffer amplifier, and so on. The below figure shows the schematic diagram of the ADC.
Tumblr media
The ADC converts the analog signal periodically rather than continuously. This gives rise to a discrete-time signal output which is a two’s complement binary number of the respective input and this signal generated can be view on an oscilloscope.
The performance of an ADC depends on the factors such as resolution, accuracy, sampling clock and speed. With many different types of ADC available, it is used an ADC which outputs the digital signal using a successive approximation method providing a more accurate output signal.
ADC or digital quantizers are used heavily as compared to analog signal due to their advantages such as high flexibility, easy implementation of digital systems and complicated algorithms and ease of control of the digital logic program. Majority of the signals in the industry are analog. Thus, there arises a need to convert these signals into digital for better control and management of the desired output signal using a digital controller closed-loop system. These signals are reconverted back to analog signals or are attached to such a mechanical device that can be driven using digital signals to operate other machinery of the industrial plant.
Tumblr media Tumblr media
Depending on the resolution of the ADC, the number of output states possible is N=2m.
Analog quantization size Q = (VRH – VRL) / N.
The output stages quantized are given a unique digital code. Thus each discretized voltage range is assigned a code. Voltage within this range is represented by a particular code. From this we deduce that accuracy of ADC can be increased by
Increasing resolution of ADC
Increasing the sampling rate of ADC
The ADC output depends on the following parameters:
Reference voltages VRef (VRH and VRL)
The number of bits m (2m digital binary bits possibilities in the output signal)
E.g., for an 8-bit output of ADC, VRH is all high bits, and VRL is all zero bits. The number of output levels will be 28 or 256. (The levels can be seen in the graph or oscilloscope).
The resolution, VRS. (It is the slightest deviation observed in the analog input signal that causes variation in the ADC output level)
Tumblr media
Where: VREF is the reference voltage Vcc; VRS is resolution and m = no. of bits.
Any input voltage level Vin is converted to its decimal number equivalent as:
Tumblr media
where N is the decimal number.
In the case of this project, the sampling clock pins in ADC0804LCN, namely CLK IN and CLK R can be explained as follows:
CLK IN is an input pin connected to an external clock source.
CLK R pin is only used when inbuilt clock circuitry is selected for clock sampling.
0 notes
dfrobots-blog · 5 years
Text
ESP32 Arduino: Temperature, humidity and CO2 concentration web server
ntroduction
In this ESP32 tutorial we will check how to develop a HTTP web server that will expose an API for clients to retrieve measurements of temperature, humidity and CO2. These measurements will be gathered from the surrounding environment using two distinct sensors.Regarding the web server, we will use the async HTTP web server library that can be found here . As we have been covering in previous tutorials, this library allows us to set up an asynchronous HTTP web server, which means we don’t need to be periodically polling some object to handle incoming clients, like we had to in the original ESP8266 web server implementation.This library is very versatile and offers a lot of functionalities. Some of them have been covered in previous posts and you can check a list of them in the “Related Posts” section at the end of this article.If you haven’t yet installed and tested the library, then my recommendation is to check this
introductory tutorial, which explains how to install the library and its dependencies and how to get started.As CO2 sensor, we will use an Analog Infrared CO2 Sensor  from DFRobot, which we have been covering in the
previous tutorial . This sensor is based on the NDIR technology and you can consult its Wiki here .As detailed in the previous post, the sensor outputs an analog voltage that is proportional to the concentration of CO2 in the air, in the range of 0.4 V to 2.0 V. These voltages correspond to a concentration of 0 ppm (parts per million) and 5000 ppm, respectively.Note that to obtain the analog voltage outputted by the sensor, we will need to use the ESP32 Analog to Digital Converter (ADC). As discussed in this open issue of the
Arduino core, the analogRead function we will use is returning inconsistent values. This is caused by the non linearity of the ADC, which is currently not being compensated in the analogRead function.Nonetheless, for the sake of simplicity, we will assume a linear behavior of the ADC in the 0 V to 3.3 V range, like we did in the previous tutorial about interacting with the
CO2 sensor . Naturally, this will introduce some imprecision in the CO2 measurements, which means that this code should not be used if you need very accurate measurements.Finally, the temperature and humidity measurements will be obtained using a DFRobot DHT22 module. The DHT22 is a sensor that allows to get both humidity and temperature measurements from the surrounding environment and has a single wire interface to exchange data with a microcontroller.In order to interact with the sensor using a higher level API that abstracts from us the lower level details of the single wire interface of the sensor, we will use this Arduino library, which is compatible with the ESP32. Note that you can install it from the Arduino IDE libraries manager.For a detailed tutorial on how to get temperature measurements from the sensor, please consult this post. For humidity measurements, check this one. The tests were performed using a DFRobot’s ESP32 module integrated in a ESP32 development board.
The electronic schematic
The electronic schematic needed to connect the ESP32 to the sensors is very simple since each of them only need to be connected to a single pin of the microcontroller. Figure 1 illustrates the diagram.
Tumblr media
Figure 1 – Electronic schematic.
As mentioned before, theCO2 sensor needs to be connected to an analog pin of the ESP32, since it outputs an analog voltage. On the other hand, the DHT22 sensoras a digital interface, so we can connect it to any digital pin of the ESP32.The pins from each sensor to be connected to the ESP32 are generically labeled as data in the previous diagram, but in the physical devices those pins don’t have any labels. So we need to take into account the colors of the wires attached to them.As usual, in both devices, the red wire corresponds to VCC and the black to GND. In the DHT22 module, the green wire corresponds to the data pin and in the CO2 module the blue wire corresponds to the data pin.I’m not sure if different units may have different colors in the data pins, but the red and black wires should follow the convention of VCC and GND, respectively. Please analyse your devices carefully before proceeding with the connection.Note that the DHT22 and the CO2 sensor
have different supply voltages. The DHT22 is powered with 3.3 V and the
CO2 sensor with 5 V. You can use a cheap power supply such as
this, which can simultaneously provide both 5 V and 3.3 V outputs in different pins.Also, don’t forget to have a common ground for all the 3 devices, so everything works as expected.
Includes and global variables
The first thing we need to do is writing all the includes needed for our code to work. Since we are using a lot of different functionalities, we will need to include 3 different libraries.In order to connect the ESP32 to the WiFi network, so clients can reach our web server, we will need the WiFi.h library.
#include "WiFi.h"
To setup the server, we will need to include the ESPAsyncWebServer.h library, which will expose a class that we will instantiate in order to configure the server routes and functionalities.
#include "ESPAsyncWebServer.h"
Then we will need the DHTesp.h library to also have access to a class that exposes a very simple API to interact with the
DHT22
, abstracting from us the lower level details of the single wire protocol it uses under the hood.
#include "DHTesp.h"
Note that we don’t need any library to interact with the
CO2 sensor since it simply outputs an analog voltage that is proportional to the air concentration of this gas, as already mentioned.Moving on to the global variable declarations, we will store the number of the analog pin that will be connected to the CO2 sensor
in a variable, so it is easy to change if we want to use another pin in the future.I’m going to use pin 35 but you can use other if you want, as long as it supports analog voltage measurements. You can read more about the supported pins here
. Note that the ESP32 has 2 ADCs and supports 18 measurement channels but the channels of the second Analog to Digital Converter (ADC2) cannot be used when the WiFi driver is started [1], which will be our case.
int analogPin = 35;
Following the same approach, we will also declare a global variable to hold the number of the pin connected to the DHT22 sensor
. Note that in this case we don’t need to use an analog pin since the communication protocol between the DHT22 and the ESP32 is digital.
int dhtPin = 27;
Besides the DHT22
pin number, we will also need an object of class DHTesp, which is the one that we will use to both initialize the sensor interface and get temperature and humidity measurements from it.
DHTesp dht;
We will also need an object of class AsyncWebServer which will be used to configure the server, as already mentioned.Note that the constructor of this class receives as input the number of the port where the server will be listening. We will be using port 80, which is the default HTTP port. This value is passed as an integer.
AsyncWebServer server(80);
To finalize the global variables declaration, we will need the credentials of the WiFi network to which the ESP32 will connect. More precisely, we will need the network name (SSID) and password.
const char* ssid = "YourNetworkName"; const char* password = "YourNetworkPass";
The CO2 measurement function
Since we are not using any library to interact with the
CO2 sensor, we will need to code the calculations needed to convert the analog voltage into CO2 concentrations ourselves. Thus, we will encapsulate this logic on a function.
We will call our function getCo2Measurement and it will return an integer value with the CO2 concentration measured by the sensor.
int getCo2Measurement() { // Measurement processing code }
The code we are going to use in the function implementation is basically the one we have covered in the previous tutorial
.First, we obtain the analog voltage outputted by the sensor. We do it by calling the analogRead function and passing as input the number of the analog pin connected to the sensor. Remember that we have the pin number stored in a variable called analogPin, which we will use here.
int adcVal = analogRead(analogPin);
Since we are using the default mode of operation of the ESP32 ADC, then it means it is working with a bit width of 12. This means that the analogRead function call will return a value between 0 and 4095.Assuming the linear operation of the ADC between the voltage values of 0 V and 3.3 V, we can get the voltage with a simple proportion.Nonetheless, remember from the
previous tutorial that this linear behavior of the ADC is not true and at the time of writing is not being compensated in the AnalogRead function implementation, which means that our CO2 measurements will be affected by some imprecision.
float voltage = adcVal * (3.3 / 4095.0);
Since the CO2 sensor used outputs an analog voltage of 0 V if it detects any problem during its self check process, we will account for that scenario in a conditional block and return a -1 result if it verifies.That way, when using this function, we can do some error checking in the higher application layer and return a message to the client if the sensor is not working correctly.Similarly, we will also handle the case when the voltage returned is lesser than 0.4 V and greater than 0 V, which means that the sensor is still in its pre-heating phase, which takes 3 minutes, accordingly to the product
Wiki. For that case, we will return a -2 value.
if (voltage == 0) {    return -1; } else if (voltage < 0.4) {    return -2; } else {    // Measurement handling }
In case the voltage measurement is greater than 0.4 V, then we will convert it to a CO2 concentration. First, we remove the 0.4 V pre-heating threshold from our measurement, since 0.4 V corresponds to a concentration of 0 ppm.
float voltageDiference = voltage - 0.4;
Then, since the sensor has a linear relation between the voltage and the CO2 concentration in the 0.4 V to 2.0 V, we apply another proportion to get the concentration value, in parts per million (ppm).
return (int) ((voltageDiference * 5000.0) / 1.6);
The whole function code can be seen below.
int getCo2Measurement() {  int adcVal = analogRead(analogPin);  float voltage = adcVal * (3.3 / 4095.0);  if (voltage == 0)  {    return -1;  }  else if (voltage < 0.4)  {    return -2;  }  else  {    float voltageDiference = voltage - 0.4;    return (int) ((voltageDiference * 5000.0) / 1.6);  } }
The setup code
Now we move to the Arduino setup function, where we will take care of initializing some interfaces and configuring the web server.First, we will initialize the interface with the DHT22 sensor. To do it, we call the setup method on our previously declared DHTespobject.As input, this method receives the number of the digital pin of the microcontroller that is connected to the sensor. Remember that we have this value stored in a global variable called dhtPin, which we will pass as argument of the mentioned setup method.
dht.setup(dhtPin);
Next we will initialize the Serial interface, so we can output messages from our code. In our case, we will use it to print some feedback messages during the WiFi connection and, after that connection is established, to print the IP assigned to the ESP32 on the network, so we can later reach the web server from a client.
Serial.begin(115200);
To connect the ESP32 to the WiFi network, we call the begin method of an extern variable called WiFi, which is available when we import the WiFi.h library. As input, this method receives the network name and password, that we have also stored in global variables.
WiFi.begin(ssid, password);
Next, we will poll the mentioned WiFi extern variable for its status, until it corresponds to connected to the WiFi network. We can do it simply by calling the status method and comparing it against the WL_CONNECTED enumerated value.Note that this polling approach we are going to use is very simple and keeps the code short, but it is not very robust. If the credentials are wrong, the the program will enter in an infinite loop, since there is no error handling mechanism. Naturally, for a real application scenario, you should take in consideration the errors that may occur when trying to connect to the WiFi network.
while (WiFi.status() != WL_CONNECTED) {    delay(1000);    Serial.println("Connecting to WiFi.."); }
After the connection is established, we will print the local IP assigned to the ESP32 to the serial port. We do it by calling the localIPmethod on the WiFi extern variable.
Serial.println(WiFi.localIP());
Once the WiFi connection procedure is finished, we will handle the server routes configuration. Basically, for each endpoint in our server, we need to specify a handling function.We will have a route by each measurement type: temperature, humidity and CO2. Each route will only listen to HTTP GET requests.So, the first route we will configure is the CO2 measurement one. It will be called “/co2“.
server.on("/co2", HTTP_GET, [](AsyncWebServerRequest * request) { //Route handling function });
Inside the handling function, we will first get the CO2 concentration measurement, using the function defined in the previous section.
int measurement = getCo2Measurement();
Next, we will build a message to return to the client accordingly to the value returned by the function. Remember that we have two special return values, -1 and -2, which correspond to a sensor fault or sensor still pre-heating, respectively. In either of the cases, the message to return to the client will be a string describing the situation.In case it is a valid measurement, we will simply convert the integer to a string and append the units of the measurement (parts per million).
if(measurement == -1){message = "Sensor is not operating correctly";} else if(measurement == -2){message = "Sensor is pre-heating";} else {message = String(measurement) + " ppm";}
Finally, we return the message to the client with a HTTP status code 200 (success).Note that the value 200 may be arguable for when the sensor has a fault or is still pre-heating. In one hand, the server code executed fine and these are two cases predicted in the application logic. On the other hand, it was not possible to retrieve the measurement, so a different status code could be returned.Naturally, this is a more conceptual discussion which is outside the scope of this post. Thus, for this example we will use the 200 for all the situations.
request->send(200, "text/plain", message);
Next we will configure the route for the temperature, which will simply be “/temperature”.
server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest * request) { //Route handling code });
The handling code will be simpler than in the CO2 route handling function. First, we get the temperature measurement by calling the getTemperature method of the DHTesp object.This function takes no arguments and returns the temperature in degree Centigrade as a float.
float temperature = dht.getTemperature();
Then we simply convert the temperature to a string, append the unit and return it to the client.
request->send(200, "text/plain", String(temperature) + " ºC");
The last route will be called “/humidity” and will be returning the humidity measurements to the client.The route handling function is very similar to the previous one, expect that we call a different method to get the humidity. This method is called getHumidity. It also takes no arguments and returns the humidity, in percentage, as a float.
server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest * request) {    float humidity = dht.getHumidity();    request->send(200, "text/plain", String(humidity) + " %"); });
To finalize the setup, we call the begin method on our AsyncWebServer object, so it starts listening to incoming requests from clients.
server.begin();
The final code
The final complete code can be seen below. Note that since the server works asynchronously, our main loop function can be left empty because we don’t need to poll the server to check for client requests. Naturally, this leads to a much cleaner and efficient code.
#include "WiFi.h" #include "ESPAsyncWebServer.h" #include "DHTesp.h" int analogPin = 35; int dhtPin = 27; DHTesp dht; const char* ssid = "YourNetworkName"; const char* password =  "YourNetworkPass"; AsyncWebServer server(80); int getCo2Measurement() {  int adcVal = analogRead(analogPin);  float voltage = adcVal * (3.3 / 4095.0);  if (voltage == 0)  {    return -1;  }  else if (voltage < 0.4)  {    return -2;  }  else  {    float voltageDiference = voltage - 0.4;    return (int) ((voltageDiference * 5000.0) / 1.6);  } } void setup() {  dht.setup(dhtPin);  Serial.begin(115200);  WiFi.begin(ssid, password);  while (WiFi.status() != WL_CONNECTED) {    delay(1000);    Serial.println("Connecting to WiFi..");  }  Serial.println(WiFi.localIP());  server.on("/co2", HTTP_GET, [](AsyncWebServerRequest * request) {    int measurement = getCo2Measurement();    String message;    if(measurement == -1){message = "Sensor is not operating correctly";}    else if(measurement == -2){message = "Sensor is pre-heating";}    else {message = String(measurement) + " ppm";}    request->send(200, "text/plain", message);  });  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest * request) {    float temperature = dht.getTemperature();    request->send(200, "text/plain", String(temperature) + " ºC");  });  server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest * request) {    float humidity = dht.getHumidity();    request->send(200, "text/plain", String(humidity) + " %");  });  server.begin(); } void loop() {}
Testing the code
To test the previous code, simply compile it and upload it to your ESP32 device after wiring all the electronics.
Once the procedure finishes, open the Arduino IDE serial monitor. You should get an output similar to figure 2 as soon as the WiFi connection is established with success.
Tumblr media
Figure 2 – Successful connection to the WiFi network.As can be seen, the IP assigned to the ESP32
on the network gets printed. Copy that IP, since we are going to need it to reach the server.
Now, to send a request to the server, open a web server of your choice and type the following on your address bar, changing{yourDeviceIP} by the IP you have just copied, and {route} by one of the route names defined previously.
http://yourDeviceIp/route
Figure 3 shows the result of sending the request to the CO2 measurements route. Note that your values will differ depending if you are on a well ventilated place or not. Also, remember that due to assuming a linear behavior of the ESP32 ADC, the measurements will be affected by some imprecision.
Tumblr media
Figure 3 – CO2 measurement returned by the ESP32 server.If we try the temperature route, we should get an output similar to figure 4. As illustrated, it returns the temperature value appended with the unit, like we defined in the route handling function.
Tumblr media
Figure 4 – Temperature measurement returned by the ESP32 server.
Finally, figure 5 illustrates the result for the humidity endpoint. The behavior is similar and, as expected, we get the measurement and its unit.
Tumblr media
Figure 5 – Humidity measurement returned by the ESP32 server.
0 notes
lorenzoquintimd · 6 years
Video
undefined
tumblr
WEEK 3 SENSOR AND BUZZER: 
• Input device: select a sensor from the Arduino and Sensor kits. The input device must be used to sense the presence of a person.
• Output device: passive buzzer 
• Functionality: trigger a melody or sound using the input device. 
• Decide the story of your project (where would you use it? What is the circumstance in which you detect the person), make the schematic, make the circuit on breadboard, define the functionality, write the code, document it.
Xiaoyao and I chose the KY013 Analog Temperature Sensor
Tumblr media
This is a Analog Temperature Sensor that measures ambient temperature. It is based on the resistance of the thermistor.
^Thermistor
If the temperature is < 27 °C , the buzzer reacts to the temperature input.
What it read:
Tumblr media
SKETCH MADE IN FRITZING:
Tumblr media
CODE
/* * Lorenzo Quint
* November 14 * Based on example from: https://arduinomodules.info/ky-013-analog-temperature-sensor-module/ */ #include <math.h> int led_pin = 2; // digital pin for the led int sensorPin = A0; // select the input pin for the potentiometer int buzzer = 8; // digital pin for the buzzer
double Thermistor(int RawADC) { double Temp; Temp = log(10000.0*((1024.0/RawADC-1))); Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp ); Temp = Temp - 273.15;            // Convert Kelvin to Celcius //Temp = (Temp * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit return Temp; }
void setup() { pinMode(buzzer, OUTPUT); // Stating that the buzzer is the output Serial.begin(9600); // Serial code to read / test if it’s working.   }
void loop() { int readVal=analogRead(sensorPin); // an integer to read the value of an analog sensor double temp =  Thermistor(readVal); //
// if statement to say if the temperature is under 27 degrees, the buzzer will react, if it’s not, there’s no sound.
if(temp < 27){ tone(buzzer,1000); } else { noTone(buzzer); }
Serial.println(temp);  // display temperature //Serial.println(readVal);  // display temperature
delay(500); // delay of 500 ms }
0 notes
moarobotics-blog · 7 years
Text
Creating Custom Hardware Pt.1
So if anyone has been paying attention to my twitter and other social media accounts you may have seen the neat little recurrent spiking neural network I created
youtube
This is a network of 16,384k neurons arranged in a 128x128 grid. Each neuron has connections between itself and it's 8 immediate neighbors, as well as an “axon” which receives signals from a selection of neurons within a specific radius around the axons 2D position.
Each of these connections is weighted, and during run-time if the neuron detects that the target neurons of any of these connections is also firing then the weighting factor will increase, otherwise it slowly decays each update.
Signals are modeled as a rising and falling output that follows the SIN function from 0 to (PI/2*3) which isn't psychically accurate and can be swapped out with outer activation functions easily but I haven't done that yet. The rate at which the neuron sweeps through this 0-(PI/2*3) range is also modified, with the sweep rate increasing when the neuron fires and decreasing otherwise.
Each neurons output is then mapped to a single pixel in the image above, leading to a very impressive visualization! All in all, this is less than 175 lines of code counting white-space and comments in the file. It's worthy of a post of it's own, and I'll be writing one after this series.
I've created a lot of different neural networks but none of them were as realistic and certainly none of them showed the interesting activity seen with this model. One thing I really like is the different wave like frequencies seen in the average activation level of the network. So I started to wonder, what would happen to this network if I could feed it some real world information?
Assumptions
Tumblr media
This is not a beginners guide by any means, but that doesn't mean a beginner couldn't follow along. Our main assumption is that you've at least programmed a microcontroller such as an Arduino, PIC, etc. If you haven't we highly recommend it before starting this article, Arduinos are very cheap and readily available, with tons of project ideas and a great community behind it.
It's also assumed you know how to read schematics, and are familiar enough with them to at least draw them at a novice level.
Designing Hardware 101 – The Specifications
Tumblr media
The first step to designing good hardware is to come up with an idea of exactly what your project needs to be successful. These specifications guide the design process and component selection, and help us to avoid a lot of wasted time pursuing dead ends (keep reading for an example within this project).
This project needs to:
Run a artificial neural network (ANN) with 128x160 neurons, 20,480 neurons total
Display the output of this network on a LCD screen at a minimum of 30 frames per second
Receive inputs such as audio and orientation from the environment
Be capable of running for a limited duration detached from its power source
These simple specifications will help keep our project on track.
Component Selection
Now that we have a set of specifications lets proceed to choose the kind of hardware we want to build our project from. Since so many things are dependent on it, choosing a processor is a good first step, and will help avoid any revisions to include a different chip because of something we didn't think about. We'll be ordering all our components through Digikey because they are awesome, trustworthy and have great customer support. I've used them for years and can't recommend them enough.
I've only programmed Microchip PIC16/PIC18 microprocessors. And while I'd love to use them, they can't run as fast as I'd like (capped at 64MHz) and even if I got a PIC32 and ran it at 100MHz. I'm still limited by the fact that the instruction clock is internally divided by four...that means our instructions are only running at 25MHz. There are lots of alternatives out there that are much faster, for example AVRs instruction clock is the same as the input. ARM Cortex processors are 1.25x the clock which means for every 4 clock cycles you get 5 instructions! Lets go with that! But...out of the 3,000 different ones on Digikey which one would be the best fit? Well, let's specify exactly what we want:
100MHz or faster
Enough I/O pins to handle a TFT display and any peripherals we might require.
TFT display buses are USUALLY 16-bits wide with 3 to 4 control lines. This comes out to 20 pins at least. I like to double that, so anything with 40+ I/O pins will work.
Analog to Digital Converter, we plan on feeding audio into the network so we'll need a way to convert that to a digital value for input into the network.
These specifications reduce our choices from 3,000 to ~124 or so. From that point it's mostly the price point that drives my selection. The one I chose is the NXP MK02FN128VLH10, a Cortex M4 processor. It has 46 I/O lines, and ADC, and can run at 100MHz! Perfect!
The next thing we need to think about is memory, the processor alone doesn't have enough memory to handle running an ANN. This is easy to calculate by looking at the data structure of an individual neuron:
unsigned int ID unsigned char x unsigned char y unsigned char status unsigned int weights * N unsigned int targets * N unsigned int signal_t unsigned int signal_start unsigned int input unsigned int output unsigned int threshold
N is the maximum number of neurons an individual neuron can be connected to. For N=50, each neuron takes up 217 bytes of memory, for 20,480 neurons (128x160) that's 4,444,160 bytes or 4.24 MB. Looks like we're going to need some memory, because most microcontrollers do not come with that much onboard ram. Our specifications for  memory are:
64Mb of memory
MB = Megabytes, Mb = Megabits. Divide Megabits by 8 to get Megabytes, and divide to convert the other direction. For a 4.24MB dataset we need 33.92Mb of space to store it. Memory is cheap, so we'll go with 64Mb
8-bit wide parallel interface. Having 2 16-bit bus devices would eat up 32/40 I/O lines, and we'd like to preserve some for other uses. 8-bit should work fine.
WARNING! DEAD END AHEAD! DRAM, it has a high write cycle reliability, when I first designed this project I chose flash memory which lets you write and erase only about 100,000 times before things start failing. That means if our project ran at 60FPS our memory would wear out in less than 3 hours. If I had thought about the write cycles beforehand I could have avoided wasting the time on the flash memory altogether.
These restrictions made it easy to narrow our selections down to less than 200 or so on Digikey. The cheapest price point was the Cypress Semiconductor S27KL0641DABHI020 at $3. It's a BGA component however, and so you'll need a hot-air rework station to place it if you're using it.
The rest of the components is simply selecting input sensors, the battery, and the display. For the display I already was aware of the DT018ATFT 1.8” 128x160 display and had decided I would use that. It has a 16-bit wide bus, full color display and a backlight. Everything we could want. For inputs I'm using a MEMS Microphone (INMP510ACEZ-R7), an Accelerometer/Gyroscope combo (LSM6DS3TR), a Magnetometer (MAG3110FCR), and a NTC Thermistor. For the battery we're using the popular 102535 800MAh Lipo battery along with the MCP73831T02ACL/OT single cell lipo charger. The last thing we need is a 3.3v Linear voltage regulator, really any will do for this application but I recommend one with a current capacity of 400mA (or more) like the MIC5504-3.3YM5-TR
With this we have a Bill-of-Materials for our design, the major components are:
MK02FN128VLH10
S27KL0641DABHI020
DT018ATFT
INMP510ACEZ-R7
LSM6DS3TR
MAG3110FCR
MCP73831T02ACL/OT
MIC5504-3.3YM5-TR
The rest of the components are minor ones such as flat panel connectors, a Micro-B USB, and resistors and capacitors and not listed here. If you’re interested in the complete component listing you can get the Bill-of-Materials by clicking the following link:
BrainBox Bill-Of-Materials
MCUExpresso Configuration Tools
Before we get into creating a schematic and circuit board, we should take some time to check out the pin configuration tool created by NXP for our MK02FN128VLH processor. This processor has a lot of pins that can function as standard GPIO, but only some of these are available for things such as the crystal oscillator, I2C, and analog functions. These can be found on page 48 of the datasheet for our processor:
Tumblr media
NXP makes it very easy to set these pins up with their Pin Configuration Tool
Tumblr media
This tool will even generate the code to setup all the pins properly! How cool is that?
Tumblr media
And I've made it even easier to follow along with this guide by making the configuration use for this project available for you to download here
BrainBox MCUXpresso Config
Use this when creating your schematic symbols in your preferred software to help save some time.
Schematics and Board Drafting
Once all of the packages and symbols are defined in our electronics drafting software, we can begin the process of laying out a schematic for everything. I like to use a modular process where everything is isolated and connected by their pin function, for example:
Tumblr media
Here you can see that the pins in the bottom  half our routed to the pins on the object in the top half. I can move these objects and all of their associated pins and passive components independantly of the object they connect to, which allows me to organize the schematic like this.
Tumblr media
This makes it really easy to double check everything before sending the board out for production. Does U5 have the right caps? Are all the pins connected like they are supposed to be? All verifiable visually.
When setting up each device I always have the datasheet for that device up for me to look at the application example within the datasheet, take U2, the magnetometer,
Tumblr media
and compare it to our schematic:
Tumblr media
you can see that I basically just copied the application example from the schematic. And honestly that's what 99% of hardware designers do! There might be the occasional deviation, in mine I omit the .1uF capacitor because I have several near this IC that will provide that function just fine. Simply repeat this process for our 8 major components, and in the end you'll have a schematic that looks similar to this:
Tumblr media
Routing the board is easy if you have software that allows backward annotations, this ensures that the software checks constantly for the board and schematic to remain true to one another. At this point you can route and place components wherever you want as long as you connect everything, and this is left as an exercise for the reader because if you can create the schematic this part is easy. Lets take a look at how my final design looks, and discuss some points that will make your routing easier:
Tumblr media
Looking at my routings it's easy to see that the first thing I did was place the display so it is centered on the PCB board. I then placed major components like the processor U4, the JTAG header at the bottom, and the memory IC above it. I then routed all the data signals between the processor, display, and DRAM memory, because we want to keep these traces very short to reduce noise. I don't do this with the I2C bus however, why? Well this bus operates at a MUCH slower speed, 400kHz-1MHz compared to the parallel bus, 10MHz+, this means I don't need to worry about keeping these lines as short.
After that is done, I group components with their ICs and route them in their own little space. This is in the same deal as when we did this with the schematics, it keeps everything modular and easy to identify, and makes troubleshooting a lot easier if I need to examine a part of the board that might misbehave. Those are moved into suitable positions on the board, and then their data signals are routed.
The very final thing I do is route the power and ground lines. This is because we really don't have to worry about HOW these get routed, and you can daisy chain the routing between chips to make it easier. Additionally, most ICs have multiple data lines but only 2 lines for power and ground. After all is said in done, you should have a nice and compact circuit board, that is ready to be sent off to a production facility to be fabricated and later assembled by you!
This is the point we are at so far and the end of part 1 of this article. Check back in a couple weeks when I should have received my circuit boards and can begin the last two parts of this series. Thank you for reading!
1 note · View note
schematicdesigns · 7 years
Link
Analog-to-Digital Converters are devices that convert analog signal to digital signal. These devices come in different resolutions and performance to fit various applications. This circuit is an evaluation board that helps users to assess the ADC121C021s’ performance. The ADC121C021 is a 12-bit A...
0 notes
Text
The MQ-4 is one of many gas sensors ready to be interfaced with microcontrollers. Just like the rest of the MQ sensors, the MQ-4 is most sensitive to a particular gas. This time, it’s methane, although the sensor can still detect other flammable gases like butane and propane.
MQ-4 Methane Sensor Overview
At the heart of the MQ-4 is a heater and electrochemical sensor. When the target gas enters the membrane and reaches the sensor, it undergoes a redox reaction which creates current. This current is stronger for sensors at specific gases. In the case of the MQ4, it’s more sensitive to methane, butane and propane.
If you are looking to buy a MQ-4 sensor, you should choose the one that comes in a breakout board like this:
#gallery-0-4 { margin: auto; } #gallery-0-4 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 33%; } #gallery-0-4 img { border: 2px solid #cfcfcf; } #gallery-0-4 .gallery-caption { margin-left: 0; } /* see gallery_shortcode() in wp-includes/media.php */
This breakout board has four output pins, namely A0, D0, GND and VCC.
The power pins VCC and GND can be connected directly to an Arduino’s 5 V pin and GND respectively.
Using Digital Output
The D0 pin generates a high (equal to VCC) when in the presence of methane gas and low (equal to around 0.1 V) otherwise. You can calibrate this “digital” output through the trimmer pot on the board.
If your project only requires detection of methane then reading the D0 pin will do. Here’s a circuit diagram with an Arduino UNO:
Here, the D0 pin connects to digital pin 2 of the Arduino. The Arduino sketch below uses an interrupt so that the microcontroller always detects the MQ-4 first.
/* MQ4 Sensor - Digital Output Example * by R. Pelayo * * From TeachMeMicro (www.teachmemicro.com/arduino-mq4-methane-sensor * * Date Created: 09/11/2020 */ const byte MQ4_Pin = 2; //MQ4 D0 pin void setup() { pinMode(MQ4_Pin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(MQ4_Pin), sensor_triggered, CHANGE); //attach interrupt on MQ4 pin Serial.begin(9600); } void loop() { // Do anything you want here } void sensor_triggered() { Serial.println("Methane detected!"); // Output to serial monitor }
If however you need to determine methane concentration, you’ll need the A0 pin.
Using Analog Output
Determining PPM Equation
The sensitivity curve of the MQ-4 is shown below:
This curve is from the device datasheet and shows the sensitivity of the MQ-4 to gases. As seen here, it’s most sensitive to CH4, the chemical name of methane. Absent in the curve are propane and butane gases although both are known components of LPG (which is second to methane in this curve).
The curve is a log-log scale and shows the relationship between RS/R0 and gas concentration in parts-per-million (PPM). RS/R0 is the ratio of sensor resistance at target gas (RS) and resistance in clean air (R0). Hence, by knowing RS/R0, we can determine the concentration of the gas in PPM.
We take two points on this graph to derive a formula. This formula will then be used in our Arduino sketch later on.
The most obvious point is when RS/R0 = 1 and PPM = 1000. The second point is when RS/R0 is somewhere around 0.58 and PPM = 5000. The equation starts with:
Here, we will assign Y1 = 1, X1 = 1000 from the first point and Y2 = 0.58 and X2 = 5000 from the second point. Substituting these values in the equation above:
Changing Y to RS/R0 and X to PPM and solving for PPM:
We can now use this formula in our sketch. But before that, we need to determine the resistance ratio RS/R0.
Methane PPM Output Arduino Sketch
As mentioned, RS is the sensor resistance in the presence of Methane while R0 is the sensor resistance in clean air. Of these two, R0 would be easier to determine. We measure the resistance of the electrodes 1-6 or 4-3 (see figure below) using an ohmmeter.
My MQ-4 electrodes give out 945 ohms of resistance for both 1-6 and 4-3 electrodes. This means my R0 is 945 ohms.
The value of RS would have to be known through a sketch. The MQ-4 breakout board uses this schematic:
As you can see, Aout connects to one of the electrodes and in parallel to a resistor RL. This means the electrode resistance creates a voltage divider with RL and the voltage at Aout is:
Here, RS is our target electrode resistance which varies depending on methane concentration.
BTW, RL is an SMD resistor with label 102. This corresponds to a resistance of 1k.
So to get RS we use this formula:
The Arduino sketch to give out methane concentration in PPM is now:
/* MQ4 Sensor - Analog Output Example * Prints out methane concentration in PPM to serial monitor * by R. Pelayo * * From TeachMeMicro (www.teachmemicro.com/arduino-mq4-methane-sensor * * Date Created: 09/11/2020 */ const byte MQ4_Pin = A0; //MQ4 A0 pin const int R_0 = 945; //Change this to your own R0 measurements void setup() { Serial.begin(9600); } void loop() { Serial.println(getMethanePPM()); } /* * getMethanePPM returns a float value in PPM of methane concentration */ float getMethanePPM(){ float a0 = analogRead(A0); // get raw reading from sensor float v_o = a0 * 5 / 1023; // convert reading to volts float R_S = (5-v_o) * 1000 / v_o; // apply formula for getting RS float PPM = pow(R_S/R_0,-2.95) * 1000; //apply formula for getting PPM return PPM; // return PPM value to calling function }
That’s two ways to use the MQ-4 methane gas sensor. Note that this sketch is for display methane concentrations only, not butane or propane. For any questions, reactions, or suggestions, kindly drop a comment below.
How to Use MQ-4 Methane Gas Sensor The MQ-4 is one of many gas sensors ready to be interfaced with microcontrollers. Just like the rest of the MQ sensors, the MQ-4 is most sensitive to a particular gas.
0 notes