//The returned data is a 12-bit int
//max186 channel ch0 corresponds to 0, which is max186 pin 1
//max186 channel ch1 corresponds to 1, which is max186 pin 2
//max186 channel ch2 corresponds to 2, which is max186 pin 3
//max186 channel ch3 corresponds to 3, which is max186 pin 4
//max186 channel ch4 corresponds to 4, which is max186 pin 5
//max186 channel ch5 corresponds to 5, which is max186 pin 6
//max186 channel ch6 corresponds to 6, which is max186 pin 7
//max186 channel ch7 corresponds to 7, which is max186 pin 8
//For example: int ch3;
// ch3=ad186(3);
//ch3 is the analog voltage signal input from the 4th pin of max186, the unit is mv. If the 4th pin (ch4) of max186 inputs a voltage of 1.000 volts, it returns 0x3E8H (that is, 1000 in decimal).
//Similarly: ad186 (4) represents the signal input from the 5th pin (ch4). (See the attached picture)
uint ad186(uchar ss)
{
uchar i,kki,s;
uint i_da
switch(ss)
{
case 0: s=0x8E;break;
case 1: s=0xCE;break;
case 2: s= 0x9E;break;
case 3: s=0xDE;break;
case 4: s=0xAE;break;
case 5: s=0xEE;break;
case 6: s=0xBE;break;
case 7: s=0xFE;break;
default: s=0xAE;break;
}
CS=1;
SCLK=0;
CS=0;
SCLK=0;
for(i=0;i<8;i++)
{
uchar adaddresstransfer;
adaddresstransfer=s;
adaddresstransfer=(adaddresstransfer>>(7-i))&0x01;
DIN=adaddresstransfer;
SCLK=1;
for(kki=0;kki<2;kki++);
SCLK=0;
}
CS=1;
for(i=0;i<6;i++);
CS=0;
SCLK=1 ;
for(i=0;i<12;i++)
{
SCLK=1;
SCLK=0;
i_datatransfer=DOUT;
i_datatransfer=i_datatransfer<<(11-i);
i_da
}
addata=i_da
for(i=0;i<4;i++)
{
SCLK=1;
SCLK=0;
}
CS=1;
i_da
delay(5);
return(addata);
}
Previous article:About 51 MCU external interrupt response
Next article:51 MCU short time delay
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Live streaming portal now open | TI IoT display solution using DLP micro-projection technology
- A netizen asked me if there is a chip that can turn the machine on and off by long pressing.
- Programming: MSP430 temperature, humidity and light measurement and display
- Engineers must know: Use and selection tips of power supply filters
- Nordic nRF52832 program download problem analysis
- The result of arctan calculation by IP core is not converted
- Good thing to share: MobIR Air ultra-high cost-effective portable mobile thermal imager
- This module can meet the "high current" required for 3C lithium battery pack testing. You should know about it?
- Please help me with this DCDC IC model, thank you very much
- Which technology is best? 5G or Wi-Fi 6