Hello guys!
I have a problem, the code below simulate an aquisition of a waveform by a TCP/IP Server, then the results have to be send to a client.
#include <chipKITEthernet.h>
#include <SPI.h>
byte MAC[]= {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
byte IP[]= {192,168,1,3};
Server server (1369);
boolean refresh = LOW;
const float pi = 3.1415;
float t=0, V1[999];
Client client;
void setup()
{
Ethernet.begin(MAC, IP);
server.begin();
Serial.begin(9600);
delay(1000);
}
void loop()
{
client = server.available();
if(client.available())
{
Serial.println("Reading client");
Serial.println(" ");
char c = client.read();
Serial.print(c);
if(c==1)
{
refresh = HIGH;
}
}
if(client.connected() && refresh)
{
refresh = LOW;
Serial.println("Conectado ao servidor, inciando o envio de dados");
Serial.println(" ");
aquisition();
}
Ethernet.PeriodicTasks();
}
void aquisition()
{
for(int j=0;j<1000;j++)
{
V1[j] = 10*sin(2*pi*60*t) + 0.5*sin(3*2*pi*60*t) + 0.7*sin(5*2*pi*60*t) + 1.2*sin(7*2*pi*60*t);
t = t + 0.0002;
}
Serial.println("ADC simulation done, sending data");
Serial.println(" ");
for(int j=0;j<1000;j++)
{
client.println(V1[j]);
}
Serial.println("Aquisition done");
Serial.println(" ");
}
I can only do the routine 3-4 times at the most, then the code is stopped here:
for(int j=0;j<1000;j++)
{
client.println(V1[j]); // <--- the code stops here after 3-4 times
}
I tried almost everything possible, but I can’t figure out what’s going on.
Anything?
Best regards!!!