From e40d81e71c5659fe8348d5706265b172c4ad1eb8 Mon Sep 17 00:00:00 2001 From: Hakan Bastedt Date: Fri, 14 Feb 2025 20:06:27 +0100 Subject: [PATCH] Works in TwinCAT. Prepare for test in machine. --- Cards/.gitignore | 2 + .../Firmware/.vscode/c_cpp_properties.json | 4 +- .../Firmware/.vscode/settings.json | 6 +- .../soes-esi/MetalMusings_EaserCAT_7000.xml | 131 +++++++++++++++--- .../Firmware/lib/soes-esi/ecat_options.h | 2 +- .../Firmware/lib/soes-esi/esi.json | 34 ++++- .../Firmware/lib/soes-esi/objectlist.c | 47 +++++-- .../Firmware/lib/soes-esi/utypes.h | 8 +- .../Firmware/platformio.ini | 4 +- .../Firmware/src/main.cpp | 113 ++++----------- Cards/THTIC/Kicad/THTIC.kicad_sch | 6 +- 11 files changed, 221 insertions(+), 136 deletions(-) diff --git a/Cards/.gitignore b/Cards/.gitignore index a6ab190..dcac726 100644 --- a/Cards/.gitignore +++ b/Cards/.gitignore @@ -32,3 +32,5 @@ fp-info-cache # Exported BOM files *.xml *.csv +*.step +*.stp diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/c_cpp_properties.json b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/c_cpp_properties.json index 7858fb9..b563010 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/c_cpp_properties.json +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/c_cpp_properties.json @@ -10,6 +10,7 @@ "includePath": [ "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/include", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/src", + "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/MyMCP3221", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.pio/libdeps/genericSTM32F407VGT6/MCP3X21", @@ -58,6 +59,7 @@ "path": [ "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/include", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/src", + "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/MyMCP3221", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes", "Z:/src/MyOwnEtherCATDevice/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.pio/libdeps/genericSTM32F407VGT6/MCP3X21", @@ -106,7 +108,7 @@ "PLATFORMIO=60117", "STM32F407xx", "STM32F4", - "NOECAT", + "ECAT", "STM32F4xx", "ARDUINO=10808", "ARDUINO_ARCH_STM32", diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/settings.json b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/settings.json index 912692f..e83dccd 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/settings.json +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/.vscode/settings.json @@ -11,7 +11,11 @@ "system_error": "cpp", "numeric": "cpp", "ostream": "cpp", - "cmath": "cpp" + "cmath": "cpp", + "cstddef": "cpp", + "array": "cpp", + "string_view": "cpp", + "initializer_list": "cpp" }, "C_Cpp.errorSquiggles": "disabled", "cmake.configureOnOpen": false diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml index 489350e..49724fd 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/MetalMusings_EaserCAT_7000.xml @@ -138,7 +138,7 @@ 1 - ArcVoltage + RawData UDINT 32 16 @@ -162,7 +162,31 @@ 1 - Voltage + CalculatedVoltage + UDINT + 32 + 16 + + ro + + + + + DT1A03 + 48 + + 0 + Max SubIndex + USINT + 8 + 0 + + ro + + + + 1 + Status UDINT 32 16 @@ -238,15 +262,15 @@ DT1C13ARR UINT - 48 + 64 1 - 3 + 4 DT1C13 - 64 + 80 0 Max SubIndex @@ -260,7 +284,7 @@ Elements DT1C13ARR - 48 + 64 16 ro @@ -436,7 +460,7 @@ #x1A01 - ArcVoltage + RawData DT1A01 48 @@ -447,7 +471,7 @@ - ArcVoltage + RawData #x60010020 @@ -459,7 +483,7 @@ #x1A02 - Voltage + CalculatedVoltage DT1A02 48 @@ -470,7 +494,7 @@ - Voltage + CalculatedVoltage #x60020020 @@ -480,6 +504,29 @@ ro + + #x1A03 + Status + DT1A03 + 48 + + + Max SubIndex + + 1 + + + + Status + + #x60030008 + + + + + ro + + #x1C00 Sync Manager Communication Type @@ -548,12 +595,12 @@ #x1C13 Sync Manager 3 PDO Assignment DT1C13 - 64 + 80 Max SubIndex - 3 + 4 @@ -574,6 +621,12 @@ #x1A02 + + PDO Mapping + + #x1A03 + + ro @@ -581,7 +634,7 @@ #x2000 - VoltageScale + Scale REAL 32 @@ -591,6 +644,18 @@ ro + + #x2001 + Offset + REAL + 32 + + 0 + + + ro + + #x6000 Input12 @@ -606,8 +671,8 @@ #x6001 - ArcVoltage - REAL + RawData + DINT 32 0 @@ -619,7 +684,7 @@ #x6002 - Voltage + CalculatedVoltage REAL 32 @@ -630,6 +695,19 @@ T + + #x6003 + Status + USINT + 8 + + 0 + + + ro + T + + #x7000 Output4 @@ -677,26 +755,37 @@ #x1A01 - ArcVoltage + RawData #x6001 #x0 32 - ArcVoltage - REAL + RawData + DINT #x1A02 - Voltage + CalculatedVoltage #x6002 #x0 32 - Voltage + CalculatedVoltage REAL + + #x1A03 + Status + + #x6003 + #x0 + 8 + Status + USINT + + diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/ecat_options.h b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/ecat_options.h index 9bf3003..eb45c8c 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/ecat_options.h +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/ecat_options.h @@ -34,7 +34,7 @@ #define SM3_act 1 #define MAX_MAPPINGS_SM2 1 -#define MAX_MAPPINGS_SM3 3 +#define MAX_MAPPINGS_SM3 4 #define MAX_RXPDO_SIZE 512 #define MAX_TXPDO_SIZE 512 diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/esi.json b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/esi.json index 6dd7836..a82feec 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/esi.json +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/esi.json @@ -36,12 +36,21 @@ "sdo": { "2000": { "otype": "VAR", - "name": "VoltageScale", + "name": "Scale", "access": "RO", "dtype": "REAL32", "value": "1", "isSDOitem": true, - "data": "&Obj.VoltageScale" + "data": "&Obj.Scale" + }, + "2001": { + "otype": "VAR", + "name": "Offset", + "access": "RO", + "dtype": "REAL32", + "value": "0", + "isSDOitem": true, + "data": "&Obj.Offset" }, "A": { "otype": "RECORD", @@ -83,25 +92,36 @@ }, "6001": { "otype": "VAR", - "name": "ArcVoltage", + "name": "RawData", "access": "RO", "pdo_mappings": [ "txpdo" ], - "dtype": "REAL32", + "dtype": "INTEGER32", "value": "0", - "data": "&Obj.ArcVoltage" + "data": "&Obj.RawData" }, "6002": { "otype": "VAR", - "name": "Voltage", + "name": "CalculatedVoltage", "access": "RO", "pdo_mappings": [ "txpdo" ], "dtype": "REAL32", "value": "0", - "data": "&Obj.Voltage" + "data": "&Obj.CalculatedVoltage" + }, + "6003": { + "otype": "VAR", + "name": "Status", + "access": "RO", + "pdo_mappings": [ + "txpdo" + ], + "dtype": "UNSIGNED8", + "value": "0", + "data": "&Obj.Status" } }, "rxpdo": { diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/objectlist.c b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/objectlist.c index 08980b4..78118d7 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/objectlist.c +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/objectlist.c @@ -19,12 +19,15 @@ static const char acName1600_01[] = "Output4"; static const char acName1A00[] = "Input12"; static const char acName1A00_00[] = "Max SubIndex"; static const char acName1A00_01[] = "Input12"; -static const char acName1A01[] = "ArcVoltage"; +static const char acName1A01[] = "RawData"; static const char acName1A01_00[] = "Max SubIndex"; -static const char acName1A01_01[] = "ArcVoltage"; -static const char acName1A02[] = "Voltage"; +static const char acName1A01_01[] = "RawData"; +static const char acName1A02[] = "CalculatedVoltage"; static const char acName1A02_00[] = "Max SubIndex"; -static const char acName1A02_01[] = "Voltage"; +static const char acName1A02_01[] = "CalculatedVoltage"; +static const char acName1A03[] = "Status"; +static const char acName1A03_00[] = "Max SubIndex"; +static const char acName1A03_01[] = "Status"; static const char acName1C00[] = "Sync Manager Communication Type"; static const char acName1C00_00[] = "Max SubIndex"; static const char acName1C00_01[] = "Communications Type SM0"; @@ -39,10 +42,13 @@ static const char acName1C13_00[] = "Max SubIndex"; static const char acName1C13_01[] = "PDO Mapping"; static const char acName1C13_02[] = "PDO Mapping"; static const char acName1C13_03[] = "PDO Mapping"; -static const char acName2000[] = "VoltageScale"; +static const char acName1C13_04[] = "PDO Mapping"; +static const char acName2000[] = "Scale"; +static const char acName2001[] = "Offset"; static const char acName6000[] = "Input12"; -static const char acName6001[] = "ArcVoltage"; -static const char acName6002[] = "Voltage"; +static const char acName6001[] = "RawData"; +static const char acName6002[] = "CalculatedVoltage"; +static const char acName6003[] = "Status"; static const char acName7000[] = "Output4"; const _objd SDO1000[] = @@ -89,6 +95,11 @@ const _objd SDO1A02[] = {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A02_00, 1, NULL}, {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A02_01, 0x60020020, NULL}, }; +const _objd SDO1A03[] = +{ + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1A03_00, 1, NULL}, + {0x01, DTYPE_UNSIGNED32, 32, ATYPE_RO, acName1A03_01, 0x60030008, NULL}, +}; const _objd SDO1C00[] = { {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C00_00, 4, NULL}, @@ -104,14 +115,19 @@ const _objd SDO1C12[] = }; const _objd SDO1C13[] = { - {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 3, NULL}, + {0x00, DTYPE_UNSIGNED8, 8, ATYPE_RO, acName1C13_00, 4, NULL}, {0x01, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_01, 0x1A00, NULL}, {0x02, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_02, 0x1A01, NULL}, {0x03, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_03, 0x1A02, NULL}, + {0x04, DTYPE_UNSIGNED16, 16, ATYPE_RO, acName1C13_04, 0x1A03, NULL}, }; const _objd SDO2000[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO, acName2000, 0x3f800000, &Obj.VoltageScale}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO, acName2000, 0x3f800000, &Obj.Scale}, +}; +const _objd SDO2001[] = +{ + {0x0, DTYPE_REAL32, 32, ATYPE_RO, acName2001, 0x00000000, &Obj.Offset}, }; const _objd SDO6000[] = { @@ -119,11 +135,15 @@ const _objd SDO6000[] = }; const _objd SDO6001[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0x00000000, &Obj.ArcVoltage}, + {0x0, DTYPE_INTEGER32, 32, ATYPE_RO | ATYPE_TXPDO, acName6001, 0, &Obj.RawData}, }; const _objd SDO6002[] = { - {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6002, 0x00000000, &Obj.Voltage}, + {0x0, DTYPE_REAL32, 32, ATYPE_RO | ATYPE_TXPDO, acName6002, 0x00000000, &Obj.CalculatedVoltage}, +}; +const _objd SDO6003[] = +{ + {0x0, DTYPE_UNSIGNED8, 8, ATYPE_RO | ATYPE_TXPDO, acName6003, 0, &Obj.Status}, }; const _objd SDO7000[] = { @@ -141,13 +161,16 @@ const _objectlist SDOobjects[] = {0x1A00, OTYPE_RECORD, 1, 0, acName1A00, SDO1A00}, {0x1A01, OTYPE_RECORD, 1, 0, acName1A01, SDO1A01}, {0x1A02, OTYPE_RECORD, 1, 0, acName1A02, SDO1A02}, + {0x1A03, OTYPE_RECORD, 1, 0, acName1A03, SDO1A03}, {0x1C00, OTYPE_ARRAY, 4, 0, acName1C00, SDO1C00}, {0x1C12, OTYPE_ARRAY, 1, 0, acName1C12, SDO1C12}, - {0x1C13, OTYPE_ARRAY, 3, 0, acName1C13, SDO1C13}, + {0x1C13, OTYPE_ARRAY, 4, 0, acName1C13, SDO1C13}, {0x2000, OTYPE_VAR, 0, 0, acName2000, SDO2000}, + {0x2001, OTYPE_VAR, 0, 0, acName2001, SDO2001}, {0x6000, OTYPE_VAR, 0, 0, acName6000, SDO6000}, {0x6001, OTYPE_VAR, 0, 0, acName6001, SDO6001}, {0x6002, OTYPE_VAR, 0, 0, acName6002, SDO6002}, + {0x6003, OTYPE_VAR, 0, 0, acName6003, SDO6003}, {0x7000, OTYPE_VAR, 0, 0, acName7000, SDO7000}, {0xffff, 0xff, 0xff, 0xff, NULL, NULL} }; diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/utypes.h b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/utypes.h index 3353c11..786e4ff 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/utypes.h +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/lib/soes-esi/utypes.h @@ -14,8 +14,9 @@ typedef struct /* Inputs */ int32_t Input12; - float ArcVoltage; - float Voltage; + int32_t RawData; + float CalculatedVoltage; + uint8_t Status; /* Outputs */ @@ -23,7 +24,8 @@ typedef struct /* Parameters */ - float VoltageScale; + float Scale; + float Offset; } _Objects; extern _Objects Obj; diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/platformio.ini b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/platformio.ini index 28a999d..7ab797c 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/platformio.ini +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/platformio.ini @@ -15,10 +15,10 @@ board = genericSTM32F407VGT6 upload_protocol = stlink debug_tool = stlink debug_build_flags = -O0 -g -ggdb -monitor_port = COM15 +monitor_port = COM17 monitor_filters = send_on_enter, time, colorize, log2file monitor_speed = 115200 -build_flags = -Wl,--no-warn-rwx-segment -DNOECAT +build_flags = -Wl,--no-warn-rwx-segment -DECAT lib_deps = SPI robtillaart/ADS1X15@^0.5.1 diff --git a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/src/main.cpp b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/src/main.cpp index 3e5cf3b..9440ce4 100755 --- a/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/src/main.cpp +++ b/Cards/EaserCAT-7000-DIO+THCAD+I2C/Firmware/src/main.cpp @@ -19,8 +19,9 @@ uint8_t outputPin[] = {PE10, PE9, PE8, PE7}; #include "Wire.h" TwoWire Wire2(PB11, PB10); -#include "ADS1X15.h" -ADS1115 ADS(0x48, &Wire2); +#include "MyMCP3221.h" +MyMCP3221 mcp3221_0(0x48, &Wire2); +MyMCP3221 mcp3221_7(0x4f, &Wire2); #define bitset(byte, nbit) ((byte) |= (1 << (nbit))) #define bitclear(byte, nbit) ((byte) &= ~(1 << (nbit))) @@ -38,15 +39,27 @@ void cb_set_outputs(void) // Get Master outputs, slave inputs, first operation void cb_get_inputs(void) // Set Master inputs, slave outputs, last operation { + static float validData0 = 0.0, validVoltage0 = 0.0; for (int i = 0; i < sizeof(inputPin); i++) Obj.Input12 = digitalRead(inputPin[i]) == HIGH ? bitset(Obj.Input12, i) : bitclear(Obj.Input12, i); - float scale = Obj.VoltageScale; + float scale = Obj.Scale; if (scale == 0.0) scale = 1.0; - float ADCvoltage = ADS.toVoltage(ADS.getValue()); - Obj.ArcVoltage = scale * ADCvoltage; // * ADCvoltage; // Scaled voltage, to give Plasma arc voltage - Obj.Voltage = ADCvoltage; // Raw voltage, read by ADC + int data0 = mcp3221_0.getData(); + if ((Obj.Status = mcp3221_0.ping()) == 0) + { // Read good value + Obj.CalculatedVoltage = scale * data0 + Obj.Offset; // + Obj.RawData = data0; // Raw voltage, read by ADC + validVoltage0 = Obj.CalculatedVoltage; + validData0 = data0; + } + else + { // Didn't read a good value. Return a hopefully useful value and restart the I2C bus + Obj.CalculatedVoltage = validVoltage0; // Use value from previous call + Obj.RawData = validData0; + // Reset wire here + } } void ESC_interrupt_enable(uint32_t mask); @@ -98,33 +111,10 @@ void setup(void) digitalWrite(PB6, HIGH); digitalWrite(PB7, HIGH); #endif -#if 1 - // SPDX-FileCopyrightText: 2023 Carter Nelson for Adafruit Industries - // - // SPDX-License-Identifier: MIT - // -------------------------------------- - // i2c_scanner - // - // Modified from https://playground.arduino.cc/Main/I2cScanner/ - // -------------------------------------- Wire2.begin(); + Wire2.setClock(400000); - Serial1.begin(115200); - while (!Serial) - delay(10); - Serial1.println("\nI2C Scanner"); - -#else - Wire2.begin(); - - ADS.begin(); - ADS.setGain(0); // 0 = 6.144 volt, 1 = 4.096 V - ADS.setDataRate(7); // 0 = slow 4 = medium 7 = fast - ADS.setMode(0); // continuous mode - ADS.setWireClock(400000UL); // 400 kHz - ADS.readADC(0); // first read to trigger settings -#endif #ifdef ECAT ecat_slv_init(&config); #endif @@ -146,63 +136,16 @@ void loop(void) if (dTime > 5000) // Not doing interrupts - handle free-run ecat_slv(); #else -#if 1 - byte error, address; - int nDevices; - Serial1.println("Scanning..."); - - nDevices = 0; - for (address = 1; address < 127; address++) - { - // The i2c_scanner uses the return value of - // the Write.endTransmisstion to see if - // a device did acknowledge to the address. - Wire2.beginTransmission(address); - error = Wire2.endTransmission(); - - if (error == 0) - { - Serial1.print("I2C device found at address 0x"); - if (address < 16) - Serial1.print("0"); - Serial1.print(address, HEX); - Serial1.println(" !"); - - nDevices++; - } - else if (error == 4) - { - Serial1.print("Unknown error at address 0x"); - if (address < 16) - Serial1.print("0"); - Serial1.println(address, HEX); - } - } - if (nDevices == 0) - Serial1.println("No I2C devices found\n"); - else - Serial1.println("done\n"); - - delay(5000); // wait 5 seconds for next scan - -#else - Serial1.print("TIC "); - int tot = 0; - uint32_t before = millis(); - for (int i = 0; i < 10000; i++) - { - int16_t raw = ADS.getValue(); - tot += raw; - } - uint32_t after = millis(); - - int16_t value = ADS.getValue(); - float fval = ADS.toVoltage(value); - Serial1.printf("Time för 10000=%d värdet=", after - before); - Serial1.println(fval); -#endif + Serial1.println("\nI2C Scanner"); + Serial1.printf("Ping0=%d\n", mcp3221_0.ping()); + Serial1.printf("Ping7=%d\n", mcp3221_7.ping()); + int16_t res0 = mcp3221_0.getData(); + int16_t v0 = (res0 * 5027 * 39) / 4096; + Serial1.printf("Voltage_0: %d Voltage_7: %d\n", v0, res0); + delay(1000); #endif + } void sync0Handler(void) diff --git a/Cards/THTIC/Kicad/THTIC.kicad_sch b/Cards/THTIC/Kicad/THTIC.kicad_sch index e8c32d7..2c55fc5 100644 --- a/Cards/THTIC/Kicad/THTIC.kicad_sch +++ b/Cards/THTIC/Kicad/THTIC.kicad_sch @@ -4087,7 +4087,7 @@ ) (uuid "df56f7ac-826c-40a4-abc7-ebd3b2b28cb4") ) - (text "Typisk Varc=100V\nMätområde 0-200V\nOp-amp in 0-5V\nR1=(200/2.5-1)*R0\nR1=79*R0\nFinns inte så gott om\nmotstånd som tål över 200V,\nvälj 100k 2512 som tål 500V.\nR0 = 100k/79 = 1k266\nvälj 1k27" + (text "Typisk Varc=100V\nMätområde 0-200V\nOp-amp in 0-5V\nR1=(100/2.5-1)*R0\nR1=39*R0\nFinns inte så gott om\nmotstånd som tål över 200V,\nvälj 100k 2512 som tål 500V.\nR0 = 100k/39 = 2.56\nvälj 2k7" (exclude_from_sim no) (at 17.018 41.148 0) (effects @@ -4203,7 +4203,7 @@ ) ) ) - (property "Value" "1k27" + (property "Value" "2k7" (at 52.324 82.296 90) (effects (font @@ -4408,7 +4408,7 @@ ) ) ) - (property "Value" "1k27" + (property "Value" "2k7" (at 51.054 126.746 90) (effects (font