Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /** 00002 * @file main.cpp 00003 * @brief Main file for the CN0357-example project 00004 * @author Analog Devices Inc. 00005 * 00006 * For support please go to: 00007 * Github: https://github.com/analogdevicesinc/mbed-adi 00008 * Support: https://ez.analog.com/community/linux-device-drivers/microcontroller-no-os-drivers 00009 * Product: www.analog.com/EVAL-CN0357-ARDZ 00010 * More: https://wiki.analog.com/resources/tools-software/mbed-drivers-all 00011 00012 ******************************************************************************** 00013 * Copyright 2016(c) Analog Devices, Inc. 00014 * 00015 * All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions are met: 00019 * - Redistributions of source code must retain the above copyright 00020 * notice, this list of conditions and the following disclaimer. 00021 * - Redistributions in binary form must reproduce the above copyright 00022 * notice, this list of conditions and the following disclaimer in 00023 * the documentation and/or other materials provided with the 00024 * distribution. 00025 * - Neither the name of Analog Devices, Inc. nor the names of its 00026 * contributors may be used to endorse or promote products derived 00027 * from this software without specific prior written permission. 00028 * - The use of this software may or may not infringe the patent rights 00029 * of one or more patent holders. This license does not release you 00030 * from the requirement that you obtain separate licenses from these 00031 * patent holders to use this software. 00032 * - Use of the software either in source or binary form, must be run 00033 * on or directly connected to an Analog Devices Inc. component. 00034 * 00035 * THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR 00036 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, 00037 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00038 * IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, 00039 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00040 * LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR 00041 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00042 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00043 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00044 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00045 * 00046 ********************************************************************************/ 00047 #include "mbed.h" 00048 #include "Thermocouple.h" 00049 #include "CN0391.h" 00050 00051 Serial pc(SERIAL_TX, SERIAL_RX); 00052 00053 int main() 00054 { 00055 pc.baud(115200); 00056 //Thermocouple *tcarray[4] = {new Thermocouple_Type_E, new Thermocouple_Type_E,new Thermocouple_Type_B,new Thermocouple_Type_B} 00057 CN0391 cn0391(D10); 00058 pc.printf("Reset the AD7124\r\n"); 00059 cn0391.reset(); 00060 wait_ms(500); 00061 pc.printf("Init the AD7124\r\n"); 00062 cn0391.init(); 00063 wait_ms(500); 00064 pc.printf("Done\r\n"); 00065 00066 cn0391.set_thermocouple_type(CN0391::CHANNEL_P1, new Thermocouple_Type_E); 00067 cn0391.set_thermocouple_type(CN0391::CHANNEL_P2, new Thermocouple_Type_B); 00068 cn0391.set_thermocouple_type(CN0391::CHANNEL_P3, new Thermocouple_Type_J); 00069 cn0391.set_thermocouple_type(CN0391::CHANNEL_P4, new Thermocouple_Type_S); 00070 00071 00072 00073 pc.printf("Calibration current for channel 1: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P1)); 00074 pc.printf("Calibration current for channel 2: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P2)); 00075 pc.printf("Calibration current for channel 3: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P3)); 00076 pc.printf("Calibration current for channel 4: %f\r\n", cn0391.calibrate(CN0391::CHANNEL_P4)); 00077 while(1) { 00078 pc.printf("Thermocouple temperature channel 1: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P1)); 00079 pc.printf("Thermocouple temperature channel 2: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P2)); 00080 pc.printf("Thermocouple temperature channel 3: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P3)); 00081 pc.printf("Thermocouple temperature channel 4: %f\r\n", cn0391.read_channel(CN0391::CHANNEL_P4)); 00082 00083 pc.printf("\r\n"); 00084 00085 wait_ms(1000); 00086 } 00087 return 0; 00088 }
Generated on Tue Jul 12 2022 17:59:52 by
1.7.2
CN0357 - Toxic gas measurement
CN0216 - Weight Scale