I'm trying to verify a code which i got from github for my project. When i try to verify it, Im getting an error as
C:\Users\ASUS\AppData\Local\Temp\cckAoUTF.ltrans0.ltrans.o: In function main': C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to loop'
collect2.exe: error: ld returned 1 exit status
Using library CD74HC4067-master at version 1.0.0 in folder: C:\Users\ASUS\AppData\Local\Arduino15\libraries\CD74HC4067-master
Using library TrueRMS-master at version 1.3.0 in folder: C:\Users\ASUS\AppData\Local\Arduino15\libraries\TrueRMS-master
exit status 1
Error compiling for board Arduino Mega or Mega 2560.
I'm hoping for a solution because if I get the code right, I gotta run the simulation in proteus
This is the code:
//library of the multiplexors
#include <CD74HC4067.h>
//library for calculating RMSvalues
#include <TrueRMS.h>
// loop period time in microseconds (time between samples)
#define LPERIOD 1000
// define the used ADC input channel
#define ADC_INPUT 0
// RMS window of 40 samples, means 2 periods at 50Hz
#define RMS_WINDOW 40
unsigned long nextLoop;
int adcVal;
int cnt=0;
// ADC full scale peak-to-peak is 5.00Volts
float VoltRange = 5.00;
// create an instance
Rms readRms ;
CD74HC4067 my_mux(22,23,24,25);
CD74HC4067 my_mux2(26,27,28,29);
CD74HC4067 my_mux3(30,31,32,33);
CD74HC4067 my_mux4(34,35,36,37);
void setup()
{
Serial.begin(9600);
Serial.println("LABEL,v");
Serial.print("DATA, ");
readRms.begin(VoltRange, RMS_WINDOW, ADC_10BIT, BLR_ON,CNT_SCAN);
readRms.start();
// Set the loop timer variable for the next loop interval.
//micros( ) Returns the number of microseconds since the Arduino board began running the current program.
nextLoop = micros() + LPERIOD;
//electrode 0 and 1//electrode 0 and 1
my_mux.channel(0);
my_mux2.channel(1);
for (int k=2;k<15;k++)
{
my_mux3.channel(k);
my_mux4.channel(k+1);
for(int i=0;i<500;i++)
{
// Read the ADC and remove the DC-offset
adcVal = analogRead(ADC_INPUT);
//take an instance again
readRms.update(adcVal);
cnt++;
//repeating the readings of one sample
if(cnt >= 500)
{
// publish every 0.5s
readRms.publish();
Serial.print(readRms.rmsVal,3);
Serial.println();
Serial.print("DATA, ");
cnt=0;
}
// wait until the end of the time interval
while(nextLoop > micros());
// set next loop time to current time + LOOP_PERIOD
nextLoop += LPERIOD;
}
}
//electrode 1 and 2//electrode 1 and 2
my_mux.channel(1);
my_mux2.channel(2);
for (int k=3;k<15;k++)
{
my_mux3.channel(k);
my_mux4.channel(k+1);
for(int i=0;i<500;i++)
{
// Read the ADC and remove the DC-offset
adcVal = analogRead(ADC_INPUT);
readRms.update(adcVal);
//take an instance again
cnt++;
//repeating the readings of one sample
if(cnt >= 500)
{
// publish every 0.5s
readRms.publish();
Serial.print(readRms.rmsVal,3);
Serial.println();
Serial.print("DATA, ");
cnt=0;
}
// wait until the end of the time interval
while(nextLoop > micros());
// set next loop time to current time + LOOP_PERIOD
nextLoop += LPERIOD;
}
}
my_mux3.channel(15);
my_mux4.channel(0);
for(int i=0;i<500;i++)
{
// Read the ADC and remove the DC-offset.
adcVal = analogRead(ADC_INPUT);
readRms.update(adcVal);
//take an instance again
cnt++;
if(cnt >= 500)
//repeating the readings of one sample
{
// publish every 0.5s
readRms.publish();
Serial.print(readRms.rmsVal,3);
Serial.println();
Serial.print("DATA, ");
cnt=0;
}
// wait until the end of the time interval
while(nextLoop > micros());
// set next loop time to current time + LOOP_PERIOD
nextLoop += LPERIOD;
}
//electrode 2&3//electrode 2&3//electrode 2&3
my_mux.channel(2);
my_mux2.channel(3);
my_mux3.channel(0);
my_mux4.channel(1);
for(int i=0;i<500;i++)
{
adcVal = analogRead(ADC_INPUT);
readRms.update(adcVal);
cnt++;
if(cnt >= 500)
{
readRms.publish();
Serial.print(readRms.rmsVal,3);
Serial.println();
Serial.print("DATA, ");
cnt=0;
}
while(nextLoop > micros());
nextLoop += LPERIOD;
}
for (int k=4;k<15;k++){
my_mux3.channel(k);
my_mux4.channel(k+1);
for(int i=0;i<500;i++)
{
adcVal = analogRead(ADC_INPUT);
readRms.update(adcVal);
cnt++;
if(cnt >= 500)
{
readRms.publish();
Serial.print(readRms.rmsVal,3);
Serial.println();
Serial.print("DATA, ");
cnt=0;
}
while(nextLoop > micros());
nextLoop += LPERIOD;
}
}
my_mux3.channel(15);
my_mux4.channel(0);
for(int i=0;i<500;i++)
{
adcVal = analogRead(ADC_INPUT);
readRms.update(adcVal);
cnt++;
if(cnt >= 500)
{
readRms.publish();
Serial.print(readRms.rmsVal,3);
Serial.println();
Serial.print("DATA, ");
cnt=0;
}
while(nextLoop > micros());
nextLoop += LPERIOD;
}}
Please follow the advice given in the link below when posting code. Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
@sid1901, your topic has been moved to a more suitable location on the forum. This is a compiler / linker error and has nothing to do with Avrdude, stk500 or Bootloader issues.
Hey! Actually I don't have any experience in coding. I found this code in GitHub. It's for my project caled "Electrical Impedance Tomography". I realized that there is no loop funtion and thought someone might help me with it
I actually did this and the error was gone. But I had a doubt that what should be in the loop function? I feel like i the code provided was incomplete so I guess something should've been in the loop function.
Electrical impedance tomography (EIT) is a noninvasive type of medical imaging in which the electrical conductivity, permittivity, and impedance of a part of the body is inferred from surface electrode measurements and used to form a tomographic image of that part.
Not necessarily. You can put everything in setup() if so inclined or if it's needed. I think that that is the case here but because you did not use code tags and I'm using a cell phone it's difficult to be sure.
Please edit your opening post, select all code and click the </> button. That will make it easier to read, prevents misinterpretation by the forum software and makes it easier to copy.
The project is called Electrical Impedance Tomography. It's a medical imaging project. Basically 16 electrodes are attached to a body or a resistor mesh and current is injected and voltages are calculates in a specific pattern. All these voltage differences are fed into EIDORS and image is constructed. Please read this paper to get a better understanding http://repository.sustech.edu/handle/123456789/24109
Yeah sure this is the link for the research paper that I've been referring. http://repository.sustech.edu/handle/123456789/24109
I actually have a pdf of circuit diagram but Im not yet allowed to upload attachments. I can mail it to you if that's possible
I suspected that setup() would be looping forever but it isn't. So the code does a number of readings, sends it over Serial and next stops doing things.
If you want to collect data, you need some form of program on the PC; e.g. Serial Monitor.
When the PC program opens the serial port, your Arduino is restarted and you get the readings.
If you want to collect new readings, either
you close the PC program and open it again
the program closes the serial port and opens it again
I think that this approach was intentionally.
Do you have a link to the github page where you found the code; it might explain why the approach was chosen.
Hey! Actually I mistakenly said that it was from a github page. I was confused with another code which I found on github. I found the above code from a research paper. I posted the link to the paper in above replies. Thanks
Hi, @sid1901
When you have new information, please add it as a new post, don't go back and edit old posts.
When you do update old posts, you make it just about impossible to read the flow of the thread, especially if code has been changed or edited.