From 0cae35f693b1a4d57e8a9e29c751f7310ba136b5 Mon Sep 17 00:00:00 2001 From: Eric Yu Date: Wed, 21 Dec 2022 16:33:53 -0800 Subject: [PATCH 1/4] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7d23562..10bde68 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ ATTENTION MAC USER: currently the software cannot correctly functional on mac (e - axis window size is not correct - on PyInstaller, windows misdetected our executable as a virus - change the scale on Y-axis so that graph looks smoother +- Errors thrown when >1 reference resistances entered ## Todos & [Old Specs](https://docs.google.com/document/d/1Km2HZel7rILOvgHG5iXlUcXFx4Of1ot2I7Dbnq8aTwY/edit?usp=sharing): - [ ] Fix Issues From ccae95273ad0eb649c7ec2bd1e9df326e3a3f74d Mon Sep 17 00:00:00 2001 From: zayn121381 <62085161+zayn121381@users.noreply.github.com> Date: Sun, 8 Jan 2023 13:50:38 -0800 Subject: [PATCH 2/4] Add files via upload --- ADS1115_driver/main.c | 120 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 ADS1115_driver/main.c diff --git a/ADS1115_driver/main.c b/ADS1115_driver/main.c new file mode 100644 index 0000000..2b0da5a --- /dev/null +++ b/ADS1115_driver/main.c @@ -0,0 +1,120 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:megaatmega2560] +platform = atmelavr +board = megaatmega2560 +framework = arduino + +#include "led.h" +#include "delay.h" +#include "sys.h" +#include "usart.h" +#include "lcd.h" +#include "key.h" +#include "ads1115.h" + +float aa; + + int main(void) + { + float t1; + u16 t,result; + u8 key; + u16 i=0; + + NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);// Set interrupt priority group 2 + delay_init(); + uart_init(9600); // The serial port is initialized to 9600 + LED_Init(); + //LCD_Init(); + KEY_Init(); + //IIC初始化 + ADS1115_Init(); + + while(1) + { + key=KEY_Scan(0); + if(key==WKUP_PRES) + { + result=lvbo(0xeb,0x82); // A0 A1 is the differential input test terminal, low eight bits + high eight bits 1111 1011, 1000 0010 + + if(result >= 0x8000 && result <= 0xffff) + result = 0xffff - result; //If the difference is negative, take the absolute value, so that A0 and A1 can be connected positively and negatively. + else if(result >= 0xffff) + result = 0; + + t1=4.096*2*result/65535; //converted to voltage + + printf("The range is 4.096V, the voltage between A0-A1 = %f V\r\n",t1);//print + + if(result == 0x7fff || result == 0x8000) + { + printf("over range \r\n\r\n"); + } + else + { + printf("Read OK \r\n\r\n"); + } + } + + if(key==KEY0_PRES) + { + result=lvbo(0xe3,0xb2); //A2 A3 is the differential input test terminal, low eight bits + high eight bits 1111 0011,1011 0010 + + + if(result >= 0x8000) + result = 0xffff - result; //If the difference is negative, take the absolute value, so that A2 and A3 can be connected positively and negatively. + + + t1=4.096*2*result/65535; //converted to voltage + + printf("The range is 4.096V, the voltage between A2-A3 = %f V\r\n",t1); //print + + if(result == 0x7fff || result == 0x8000) // exceeds the maximum value or falls below the minimum value + { + printf("over range \r\n\r\n"); + } + else + { + printf("over range\r\n\r\n"); + } + } + + if(key == KEY1_PRES) + { + result=lvbo(0xe3,0xb4); //A2 A3 is the differential input test terminal, low eight bits + high eight bits 1111 0011,1011 0100 + + if((result >= 0x8000) && (result <= 0xffff)) + result = 0xffff - result; //If the difference is negative, take the absolute value, so that A0 and A1 can be connected positively and negatively. + else if(result >= 0xffff) + result = 0; + t1=2.048*2*result/65535; //converted to voltage + + printf("The range is 2.048V, the voltage between A0-A1 = %f V\r\n",t1);//打印 + if(result == 0x7fff || result == 0x8000) + { + printf("over range \r\n\r\n"); + } + else + { + printf("over range \r\n\r\n"); + } + } + + i++; + delay_ms(10); + if(i==20) + { + LED0=!LED0;//Prompt system is running + i=0; + } + } +} From 0731cf67210ee4a92e7d277b4d62b0972415f6ef Mon Sep 17 00:00:00 2001 From: zayn121381 <62085161+zayn121381@users.noreply.github.com> Date: Sun, 8 Jan 2023 13:51:30 -0800 Subject: [PATCH 3/4] Update main.c --- ADS1115_driver/main.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ADS1115_driver/main.c b/ADS1115_driver/main.c index 2b0da5a..389920a 100644 --- a/ADS1115_driver/main.c +++ b/ADS1115_driver/main.c @@ -1,13 +1,3 @@ -; PlatformIO Project Configuration File -; -; Build options: build flags, source filter -; Upload options: custom upload port, speed and extra flags -; Library options: dependencies, extra library storages -; Advanced options: extra scripting -; -; Please visit documentation for the other options and examples -; https://docs.platformio.org/page/projectconf.html - [env:megaatmega2560] platform = atmelavr board = megaatmega2560 From 47405699c90c8552f868aac57b702b1277e172b0 Mon Sep 17 00:00:00 2001 From: zayn121381 <62085161+zayn121381@users.noreply.github.com> Date: Sun, 8 Jan 2023 13:59:43 -0800 Subject: [PATCH 4/4] Update main.c --- ADS1115_driver/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ADS1115_driver/main.c b/ADS1115_driver/main.c index 389920a..2dbf99d 100644 --- a/ADS1115_driver/main.c +++ b/ADS1115_driver/main.c @@ -26,7 +26,7 @@ float aa; LED_Init(); //LCD_Init(); KEY_Init(); - //IIC初始化 + //IIC initilize ADS1115_Init(); while(1)