Both correct, but best to use the "Pause/Resume logging" button as it will correctly close the connection and allow proper reconnection. Killing Excel will result in an unstable state of the COM connection.
I've done this. However, it does not do what I've wanted originally, partly. I want to make the Arduino stops sending data to PLX-DAQ at 11:55:00 pm and then resume logging at 12:00:00 mn automatically. I've read from your reply #26 at page 2 of this thread, a somehow of what I want to do but not with Sensorvalue but rather based at the real-time clock of the pc/laptop.
You can put the logging commands FROM Arduino TO Excel in your loop function to constantly get data. Every now and then (use a counter, e.g. every 50 steps) you can jump into a sub routine and use "CELL,GET" to query a certain cell from Excel. In said sub routine you have to wait as long as the data is received. That time long no data will be send from Arduino to Excel. It might take about half a second or so.
Is this doable, say all the data from Cell D?
You can use the SAVEWORKBOOKAS command to save the current workbook by a new name (and stay in it). That way you can kind of leave a "trail" of historic data. On the other hand you could also copy the data to a new workbook which can be saved (all fully automatic of course). Please take a look at this post (response to OneLeafAutumn) where I explained how to build this into PLX DAQ as a new command. You need to exchange the CSV references to your desired data format (xlsm or xlsx).
Okay, I'll try looking into it. But just in case, is it possible to save it to another specific folder? Since from the guide, it says that the new workbook will be saved in the same folder as the current.
You should save first and clear then. Doing that is a good idea in case you don't need the historic data but only the current 500 values). The command CLEARSHEET removes all data from the sheet (including headlines), whereby CLEARDATA only removes starting at row 2 downwards.
Oh, in this question, I mean, I will save the whole 500 data first, save it into another excel file and then CLEARDATA* the current excel and then starts logging again.
I don't quite get that question. But I guess you mean to ask if there is any way to automatically start and connect PLX DAQ e.g. after a new code is uploaded to Arduino? In that case no, there currently is no function to do that. It will be tricky though as there can always only be one active connection to the Arduino via the COM port and uploading will block this (naturally) thus PLX DAQ can not listen to what is going on on the port as well.
Yeah, this is what I meant. Sorry for the vague question.
And thanks for replying and reading my long posts Thanks for your effort.
I've did some work while waiting for your response, and here's the code I've made.
#include "EmonLib.h"
// Include Emon Library
EnergyMonitor emon1;
// Create an instance
unsigned long previousMillis = 0;
const long interval = 60000;
void setup()
{
Serial.begin(9600);
Serial.println("CLEARDATA");
Serial.println("LABEL,Date,Time,Current,Power,millis()");
emon1.current(1, 85.1); // Current: input pin, calibration.
}
void loop()
{
double Irms = emon1.calcIrms(2580); // Calculate Irms only
double Prms = Irms*230.0;
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
Serial.print(Prms); // Apparent power
Serial.print(" ");
Serial.println(Irms); // Irms
Serial.println(" ");
Serial.println( (String) "DATA,DATE,TIME," + Irms + "," + Prms + "," + millis() + ",AUTOSCROLL_30");
previousMillis = currentMillis;
}
}
I've done this. However, it does not do what I've wanted originally, partly. I want to make the Arduino stops sending data to PLX-DAQ at 11:55:00 pm and then resume logging at 12:00:00 mn automatically. I've read from your reply #26 at page 2 of this thread, a somehow of what I want to do but not with Sensorvalue but rather based at the real-time clock of the pc/laptop.
I've searched that the delay() function has limited uses and that millis() function is the better choice when working with intervals. But I can't seem to make this work (the one above). And the time frame of 11:55:01 pm to 11:59:59 pm, I will save all the data gathered in that day into an excel file and then use another excel to resume logging at 12:00:00 mn