{"id":13422148,"url":"https://github.com/rahul-sb/EIT","last_synced_at":"2025-03-15T10:31:43.020Z","repository":{"id":201344874,"uuid":"173807946","full_name":"rahul-sb/EIT","owner":"rahul-sb","description":"Electrical Impedance Tomography (EIT) ","archived":false,"fork":false,"pushed_at":"2019-12-12T20:38:18.000Z","size":194,"stargazers_count":31,"open_issues_count":1,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-27T22:32:12.500Z","etag":null,"topics":["arduino","eidors","eit","electrical-impedance-tomography","image-reconstruction","matlab"],"latest_commit_sha":null,"homepage":"","language":"MATLAB","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rahul-sb.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-03-04T19:29:06.000Z","updated_at":"2024-07-25T14:46:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"b54e566f-d268-4aec-941e-6f7b4a5d8fb7","html_url":"https://github.com/rahul-sb/EIT","commit_stats":null,"previous_names":["rahul-sb/eit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-sb%2FEIT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-sb%2FEIT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-sb%2FEIT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rahul-sb%2FEIT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rahul-sb","download_url":"https://codeload.github.com/rahul-sb/EIT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243719119,"owners_count":20336592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","eidors","eit","electrical-impedance-tomography","image-reconstruction","matlab"],"created_at":"2024-07-30T23:00:38.089Z","updated_at":"2025-03-15T10:31:42.555Z","avatar_url":"https://github.com/rahul-sb.png","language":"MATLAB","readme":"\r\n# Electrical Impedance Tomography (EIT) using Arduino and Matlab\r\n\r\n\r\n## Table of Contents:\r\n\r\n* [Introduction](#introduction)\r\n* [Electrical connection](#electrical-connection)\r\n* [How data is collected](#how-data-is-collected)\r\n* [Passing Settings to Arduino](#passing-settings-to-arduino)\r\n* [Function of LED pins](#function-of-led-pins)\r\n* [How data is printed](#how-data-is-printed)\r\n* [Run, Pause and Stop Data collection](#run,-pause-and-stop-data-collection)\r\n* [Important References and Links](#important-references-and-links)\r\n* [How to run Arduino code?](#how-to-run-arduino-code?)\r\n* [How to run Matlab code?](#how-to-run-matlab-code?)\r\n \r\n  \r\n## Introduction\r\n \r\nThis code primarily collects the data that is required to generate an Electrical Impedance Tomography (EIT) Image. It also collects the\r\nresistance between any two electrodes. The arduino code works only on Arduino Mega. The Matlab code works only on Matlab versions 2019a and above.\r\n \r\n  \r\n## Electrical connection\r\n  \r\nThe hardware setup consists of 16 electrodes (arranged evenly in a circular fashion) connected to a sensor / conductive material. \r\nThe electrodes are connected to the 16 analog pins of the arduino mega and also the 16 channels of the three DG407 Muxes. \r\n\r\nThe 'D' pin of mux0 is connected to a  constant current source.  \r\nThe 'D' pin of mux1 is connected to ground.  \r\nThe 'D' pin of mux2 is connected to VCC and a constant resistor. (Used to measure resistance, using a voltage divider circuit)\r\n\r\n\r\n## How data is collected\r\n \r\nOne can collect two types of data from this code:\r\n\r\n1. Voltage Data for EIT Image\r\n     \u003e Current is injected between any two adjacent electrodes and the voltages from the remaining electrodes are measured. Then the current is injected between the next two electrodes. This cycle starts from (electrodes) [0,1] and ends at [15,0]. For this type of data collection the muxes 0 and 1 are enabled. \r\n\r\n2. Resistance Data between any two electrodes (the data that is actually \r\n   collected is the potential difference) - Using a Voltage divider circuit.\r\n   \u003e To measure the resistances between any two electrodes, (using combinatorics it is nC2, n = 16 electrodes, a total of 120 readings), the muxes 1 and 2 are enabled. This circuit works as a voltage divider circuit. For this we switch the muxes 1 and 2 from (0,1),(0,2)...(0,15)(1,2),...(14,15) and we measure the voltage difference between those pair of electrodes.\r\n       \r\nNote: In both the cases mentioned aboue, the value is printed out as a value from 0 to 1023, one has to convert that data according to the Analog Reference that was given. The analog reference for the voltage divider circuit is 5V and for the EIT, it is what you give initially (more on this in section IV, V and X).\r\n\r\n \r\n  \r\n## Passing Settings to Arduino:\r\n \r\n  The communication with arduino is purely SERIAL. So send these settings via serial and NOT I2C or any other modes of communication.\r\n  You can customize data collection by sending these values in a specific order to the arduino (after it has been connected serially, ofcourse).\r\n  The order in which you have to send is:\r\n  \r\nSetting           |    Range  |\r\n------------------|-----------|\r\nnum_repeats        |  [0, 255) |\r\ninj_pattern        |  [1, 15]  |\r\nanalog_ref_voltage |  [1, 5]   |\r\nprescaler_value    |  [1, 7]   // Refer [here](#important-references-and-links) |\r\nsending_order      |  [0, 4]   |\r\ndelay_after_mux_on |  [0, 65,535) |\r\n\r\nwhere,\r\n\r\n    num_repeats :\r\n          Number of times \"analogread\" is called (for both voltage and resistance data)\r\n\r\n    inj_pattern :\r\n          Current Injection pattern. Not the measurement pattern. Google EIT injection pattern.\r\n   \r\n    analog_ref_voltage  : \r\n          You can tell arduino the reference value to compare against when performing analog read. For the \r\n          resistance data collection this value is set to 5V. But for Voltage data collection, you can set\r\n          any of the available reference values. Refer [here](#important-references-and-links) for more details.\r\n\r\n    prescaler_value :\r\n          You can tell arduino at what speed to collect the data. This is determined by the prescaler value \r\n          of the analog read function in arduino. Refer the table in Section X, to see acceptable values.   \r\n\r\n    delay_after_mux_on  :\r\n          You can specify the amount of time (in microseconds) the arduino can start collecting data after \r\n          the muxes have been turned on.\r\n\r\n    sending order:\r\n \r\n0     |        1      |        2    |      \r\n------|---------------|-------------|\r\nVoltage |   Resistance |  Resistance | \r\nVoltage |   Resistance |  Voltage| \r\nVoltage |   Resistance |  Resistance | \r\nVoltage |   Resistance |  Voltage| \r\n.     |       .       |      .      |\r\n.     |       .       |      .      |\r\n.     |       .       |      .      |\r\n\r\n\r\n    In which,\r\n    Voltage :   \r\n          The entire voltage matrix (14x16) is sent. This matrix is collected when the current is switched \r\n          between all 16 pairs of electrodes.  \r\n\r\n    Resistance :   \r\n          The potential difference between any two electrodes. All the 120 values are sent.\r\n         \r\n\r\nNote: There are no checks performed on these values, please ensure that you send the approporate values within the bounds.\r\n   \r\n  \r\n## Function of LED pins:\r\n  \r\nThe 2 LED pins that are connected to digital pins are mentioned in the variable \"led_pins\".\r\nIt is specified as {Green_LED, Red_LED}.\r\n\r\n    Green_LED:\r\n        Shows that the serial connection has been established.\r\n        If ON: Active Communication\r\n        If OFF : Communication Disconnected\r\n    Red_LED:\r\n        Denotes the data collection status.\r\n        If ON: Data has been collected\r\n        If OFF: Data is being collected or Arduino is in \"Pause\" or \"Stop\" data collection state\r\n \r\n \r\n\r\n  \r\n## How data is printed:\r\n \r\nThe values of any variable Voltage_1 or Voltage or Resistance (see section IV) are sent with a ' ' (space) in between them.\r\nAfter all the values of the variable are finished printing, then a newline and carraiage return character is sent. This is done to\r\ndistinguish between the two subsequent variables that are sent.\r\n\r\nThe start time (in milliseconds) is sent first (in a separate line) before any other variable is sent.\r\n\r\n    Voltage:\r\n        The Voltage values of electredes 2 to 15 are sent (0 indexed) - [current passed through 0 and 1] then \r\n        voltage values of electrodes 3 to 15 and 0 are sent - [current passed through 1 and 2], and so on..., \r\n        so a total of 14x16 = 226 values are printed with a ' ' (space) between successive values.\r\n\r\n    Resistance:\r\n        The potential difference between (0,1),(0,2)...(0,15)(1,2),...(14,15) electrodes are printed.\r\n\r\nNote: The values of these variables are separated by ' ' (blank space). The variables are itself separated by a newline and carriage return.\r\n  \r\n\r\n \r\n## Run, Pause and Stop Data collection:\r\n  \r\nWhile the arduino is collecting data to\r\n    \r\nAction| Data to send |\r\n------|-----------------|\r\nPause |\t 0  |\r\nStop  |\t-1  |\r\nResume after pause |\t 1  |\r\nWarn about possible circuit failure\t|   -2   |               \r\n\r\nNote: When \"-2\" is sent the green and red led's flash together at a constant frequency and arduino goes to \"Stop\" state\r\n\r\n\r\n## Important References and Links:\r\n\r\nReference Table for Prescaler:\r\n\r\nPrescale | ADPS2,1,0 | Clock (MHz) | Sampling rate (KHz) | Data to Send \r\n---------|-----------|-------------|---------------------|-------------\r\n  2      |     0 0 1 |  8          |     615              |        1         |\r\n  4      |     0 1 0 |  4          |     307              |        2         |\r\n  8      |     0 1 1 |  2          |     153              |        3         |\r\n  16     |     1 0 0 |  1          |     76.8             |        4    (Good Choice, but small errors near 5V)   |\r\n  32     |     1 0 1 |  0.5        |     38.4             |        5    (Excellent Choice) | \r\n  64     |     1 1 0 |  0.25       |     19.2             |        6         |\r\n  128    |     1 1 1 |  0.125      |     9.6 (default)    |        7    (Default Value) | \r\n  \r\n\r\nList of all analog reference values: (for Arduino MEGA)\r\n\r\n    DEFAULT     : Default analog reference of 5 volts (on 5V Arduino boards) or 3.3 volts (on 3.3V Arduino boards)\r\n    INTERNAL1V1 : A built-in 1.1V reference\r\n    INTERNAL2V56: a built-in 2.56V reference\r\n    EXTERNAL    : The voltage applied to the AREF pin (0 to 5V only) is used as the reference \r\n\r\nThe value that you have to send to arduino for \r\n\r\n    INTERNAL1V1  : 1\r\n    INTERNAL2V56 : 2\r\n    3.3V         : 3  (Note: This voltage has to be provided to the external pin)\r\n    EXTERNAL     : 4  (Note: This voltage has to be provided to the external pin)\r\n    DEFAULT      : 5\r\n\r\n\r\nLink to MUX Datasheet:\r\nhttps://www.intersil.com/content/dam/Intersil/documents/dg40/dg406-407.pdf \r\n  \r\nFor list of baud rates see Page 226 in\r\n\r\nhttp://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2549-8-bit-AVR-Microcontroller-ATmega640-1280-1281-2560-2561_datasheet.pdf\r\n \r\n \r\n## How to run Arduino code?\r\n\t\r\nCopy and paste the contents of \"/lib\" to \"C:\\Users\\user-name\\Documents\\Arduino\\libraries\\\" and then upload the \"EIT.ino\" in \"/Arduino/src/EIT\" folder to Arduino.\r\n\r\n## How to run Matlab code?\r\n\r\nSpecify the necessary settings in all the files in \"Matlab/Settings/\". Make sure EIDORS v3.9.1 or above is installed. Run the \"main.m\" code in \"Matlab/Main\"\r\n\r\n","funding_links":[],"categories":["MATLAB","EIT simulation libraries"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul-sb%2FEIT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frahul-sb%2FEIT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frahul-sb%2FEIT/lists"}