Go Down

Topic: PLX-DAQ version 2 - now with 64 bit support! (and further new features) (Read 166436 times) previous topic - next topic

tgod2100

Hi NetDevil, i have a problem here...

I downloaded PLX-DAQv2.11, uploaded the PLX-DAQ-v2-DefaultSketch to UNO R3, and opened the excel file PLX-DAQ-v2.11. After execution, an excel file is automatically saved and called 450-Line-File. However, I can't open this file. A window displays "Excel can't open file '450-Line-File.xlsm'. Because the file format or file name is invalid, please make sure the file is not damaged, and the file name matches the file. format"

I would like to ask how to solve this problem, thank you

NetDevil

Hi folks,
took me some time but let's get started:



@Tony:,

your second approach sounds good:
Quote
In "DATA" section, I check if row > 40; if not, then add new data at row=row+1; and if yes, then delete row2 with shift up, and add new data at row 42.
You need to check how Excel handles the deletion of the rows with regards to the data set of the diagram. In case your diagram is set to e.g. A2:A42, then deleting rows may result in moving the grid to A1:A41.
In my PowerDemo (included in the ZIP file) I used to set the data grid anew with every data read. The command is a bit cryptic and reads something like this:
Code: [Select]
ChartObjects("MyMainDiagram").Chart.FullSeriesCollection(1).XValues = "='Simple Data'!$C$" & IIf(newRow - 1 <= maxRows, "2", newRow + 1 - maxRows) & ":$C$" & newRow
Just try with dummy data: put 40 data sets in manually, set the data grid of your diagram to those 40 rows, delete row #2 and check the data set settings of your diagram again. then add another row and check again. I guess it will start off good but row by row get smaller and smaller until there is simply no data left to display. And that could be why you need to align the data set after every data input.




@BunnyTee:

Anyway, the command "CELL/ROW,SET" enables you to put the data to a certain cell in the Excel itself and the command "CELL/ROW,GET", on the other hand, will be sent back to Arduino.
Correct :)


But what I am planning to do is that I send data from the Arduino in real time to the PLX-DAQ. Therefore, the data will log into the Excel non-stop unless I close the Excel itself (?) or I clicked the "Pause/Resume logging" button (?).
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.


1. I am planning to get the data from the Excel and use it for forecasting and I want the logging of data to continue as I get a sample data (like working simultaneously). Is it possible? (I don't think SET/GET command can do it based on my understanding)
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.


2. And I think if I continue to send data from Arduino to Excel, the file may be burdened as data compiles non-stop. Is it possible to save the other incoming data, say the 501st data (counter) to another Excel file? (like for Day1 data to Excel1, Day2 data to Excel2)?
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).


3. Or is it better to just clear the sheet for every 501st, for example, but before clearing the 500 logged data will be save to a database (?) or something first and then clear the sheet.
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.


4. And lastly, when uploaded (Arduino), PLX-DAQ can only be manually connected?
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.




@tgod2100:

However, I can't open this file. A window displays "Excel can't open file '450-Line-File.xlsm'. Because the file format or file name is invalid, please make sure the file is not damaged, and the file name matches the file. format"
That one is tricky. It is a good sign that the file gets created, thus all code is running fine. Which version of Excel are you using? And can you please post the full file name that gets created? Most likely it does not store as ".xlsm"?



Cheers to everyone!

BunnyTee

Quote
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.

Quote
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?

Quote
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.

Quote
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.

Quote
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.

Code: [Select]

#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;
 
  }
}



Quote
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

tgod2100

@tgod2100:
That one is tricky. It is a good sign that the file gets created, thus all code is running fine. Which version of Excel are you using? And can you please post the full file name that gets created? Most likely it does not store as ".xlsm"?

@NetDevil:

Hi,NetDevil

The version of Excel I am using is 2003.

The full file name is 450-Lines-File.xlsm

JackSilva

hi Net Devil

I'm Brazialian

I have a problem, with your software

My excel hangs when I put for a grafics.

I use Win10 and Excel 365

Can you help me?


NetDevil

Hi there,
I kind of feel like it is becoming my signature move to reply to a couple of questions with nearly two weeks delay all the time....





@BunnyTee:
Quote
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
You can use the real time clock as a module to connect to your Arduino, yes. On the other hand you could use one cell within Excel as a "Do sending: yes/no" information that is passed back and forth from Excel to Arduino. Nevertheless you need you Arduino to run 24/7 as well as your PC and they need to be connection with each other throughout the time.
What I would is to use a cell e.g. A10 and write a "Yes" or "No" in the cell by VBA based on the PC time. You can use the loops running in PLX DAQ for that. In Arduino I would use a millis counter to send a query for cell A10 like every one minute. Based on what is returned to the Arduino it should or shouldn't send data to Excel.

Quote
Is this doable, say all the data from Cell D?
"D" is not a cell but a whole column. Getting all data from one column is tricky and would require some change in code. However getting only the data from cell D7 (or as above A10) is within the standards of PLX DAQ. The Beginners Guide does have some example data for that.

Quote
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.
well kind of yes I guess. The code in PLX DAQ is
Code: [Select]
ThisWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & DataVal(1) & ".xlsm"
whereby DataVal(1) is what you pass as a file name.
Let's say "ThisWorkbook.Path" is equal to C:\Users\YourName\Desktop", then:
- passing "NewFile" would result in storing a copy of the workbook as C:\Users\YourName\Desktop\NewFile.xlsm
- passing "folder\NewFile" would result in storing a copy of the workbook as C:\Users\YourName\Desktop\folder\NewFile.xlsm [the subfolder needs to already exist !!]
- passing "..\NewFile" would result in storing a copy of the workbook as C:\Users\YourName\NewFile.xlsm

So by building the path you can change it, but in any way the current folder is the reference and starting point.

Quote
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.
Sure that is possible. After every 500 lines send by Arduino (you need to make the counter in the Arduino code) you can send a SAVEWORKBOOKAS command followed by a CLEARDATA command

Quote
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
Delay will typically pause the whole code running on Arduino for the time that should be waited. Total disaster of course as you want to continue logging . Using millis is better as you can just save the current value of millis, add (1000*60*60*25) to it (one full day) and place in variable x and in your loop function check if the current millis is larger then x (thus the day has passed). However this will result in pretty large numbers. I might think that my way (Cell A10 with Yes/No value) is a bit more stable.





@tgod2100:
yeah I would totally suggest this to be an issue with the old Excel version. That version of Excel is older then many users on this board  :smiley-mr-green:  :smiley-mr-green:
Do you have any option to try to switch to a more up to date version? Maybe 2013?





@JackSilva:
Brazilian, nice :) I should start a world map and put pins in and try to get as many continents as possible :)
My first guess is that Excel 365 is a problem. However I haven't used it myself... it is a native running client or a cloud service? Does PLX DAQ work with it in general (fetching / receiving data) but crashes only when using graphics?
Just to be sure: by graphics you mean graphs and plots and diagrams? Not pictures? But your goal is to receive data and visualize it? Does your graph auto-update while receiving data or do you receive data, stop the connection, then create a graph of the data and by that Excel crashes?





Cheers everyone!
(see you in 2 weeks time  :smiley-confuse:  :smiley-roll-blue:  :smiley-eek: )

rtek1000

Interesting, but do I need to use a computer to generate a xls file?  Wouldn't it be possible to bring to the Arduino platform any existing Python library and use a board like Mega2560, DUE, ESP32 etc?

I found this library in C:
https://forum.arduino.cc/index.php?topic=642853.0

But that doesn't compile with Arduino Due
Please avoid private messages, your question may be someone's answer in the future!

NetDevil

Interesting, but do I need to use a computer to generate a xls file?  Wouldn't it be possible to bring to the Arduino platform any existing Python library and use a board like Mega2560, DUE, ESP32 etc?

I found this library in C:
https://forum.arduino.cc/index.php?topic=642853.0

But that doesn't compile with Arduino Due
Hi rtek1000,

that is an interesting idea, yeah. Having a look at your linked thread I see that the possibilities of Libxlsxwriter  go way beyond "just" creating a valid xls file (Autofilters, merged cells, charts, they go the full way). That is a full blown solution for creation on the device itself.
PLX-DAQ's intention was to simply collect data with as little overhead as possible. "DAQ" stands for "Data Acquisition" by the way :) The intention was to visualize real time data or collect and store data periodically without adjusting too much on the Arduino code itself.

So yeah, basically PLX DAQ has to run on the PC, but a side project to collect/store/export data from Arduino directly would be nice as well. Maybe as a "simple" CSV, or a lightweight xls(x) or a full blown Excel file. Maybe via USB or Email (would require additional hardware). But that will be something you have to look into ;)

Greetings

derekpelotte1

Hi,

Thank you for continuing to support this incredibly useful program.

I have an error I'm not seeing addressed in any other thread. I'm on Windows 10 with Excel 2016. I have macros enabled. 

When I open any of the Excel files that come with V2.11 I first get a Run time Error 91: Object variable or With block variable not set. Debugging, it zooms in on

Private Sub Workbook_Open()
    frmStampDAQ.Show
End Sub

in the ThisWorkbook Excel Object. I'm not sure what this means, but that's where it points.

The second error comes when I then click 'Connect' on the DAQ UI. It spits back

COM ErrorL Error (453): CommOpen -Can't find DLL entry point FormatMessage A in kernel32. Aborting!

This one I can only hit ok to. I'm wondering if you have any suggestions.

Thank you.

NetDevil

When I open any of the Excel files that come with V2.11 I first get a Run time Error 91: Object variable or With block variable not set. Debugging, it zooms in on

Private Sub Workbook_Open()
    frmStampDAQ.Show
End Sub

in the ThisWorkbook Excel Object. I'm not sure what this means, but that's where it points.

The second error comes when I then click 'Connect' on the DAQ UI. It spits back

COM ErrorL Error (453): CommOpen -Can't find DLL entry point FormatMessage A in kernel32. Aborting!
Hi Derekpelotte1,

at first I thought it was 'Macros not enabled' but "sadly" you've already said that you did... sadly because I have not really any idea where the problem might come from alternatively...

The "ThisWorkbook Excel Object" does just mean that every time something happens with the Excel workbook (in this case open) the code should be executed. And the code just opens the main form.
Somehow the form does open I guess (otherwise you wouldn't be able to click the connect button). How did you manage to get it to open?

The COM Error message states it has a problem with the kernel32.dll. E.g. like you don't have that specific function in yours, what is totally crazy because it is a standard component. Did you ever run other Excel macros on that computer? Maybe didn't you install the VBA package at the time you installed MS Office?
Sorry to ask but, have you tried re-installing Excel?

This is really all just trial and error. I did some Google research but the problem seems to be quite seldom (if not unique...).

I will give it another look tomorrow on a PC with Excel installed. Maybe we could just omit the call from the code to get it running on your PC, I must take a look.

Greetings

Jonathan

NetDevil

So I took another look and basically you could just get rid of all the FormatMessage calls and functions using it. You will loose only some debug / status information of the COMM port.

However I fear that you will run into the next error right afterwards.

Could you do me a favor please and state which version of Excel 2016 and Windows 10 you are using? Which of them is either 32 or 64 bit?
It looks like PLX DAQ is currently only distinguishing between Excel versions, not Windows 10 versions. There might be room for improvement here.

Go Up