Go Down

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

NetDevil

Hi 30percent,

You deserve more than karma and kudos for the work!
Thanks a lot :) that is my I published under the beer license. Come to Germany and toast me a Hefeweizen (Wheat beer) if you like ;) You are more then welcome.

Before I get too far in experimenting with the demo code, I would like to know if what I'm trying to do is possible using PLX-DAQ and the cell.get.xx command.
Ok let's get to the real work here :)
It is actually possible, yes. As you know the dimensions of your matrix in Excel you can create a loop counter in Arduino to go from x to y and from column a to b and read the value, wait for the response, act according to it and move on. However I fear the delay between request and response might be pretty long. Also it requires some tricky programming because you can either a) request-and-wait for the response (which would block the execution of all other code) or b) request, set a global variable to name to current LED you are looking for, continue with the standard Arduino loop all over as long as you have no response, once you get the response react on it (as you know which LED you are currently operating on) and move on to the next LED.
How frequent do you want to change the LEDs? Like 24 times per second to show a movie or like playing Tetris and changing some of them once per second?
I would really like to know if it works :)





Hi cryotan,
well let's see:

I am playing with CustomDevPointNewData to stop logging at certain duration (set at a textBox). I am thinking to get the millis or timer from the newdata string to pause the logging! But never can get it to work.
Why not read the value from the textbox to Arduino and stop sending log data there once the value is reached?
Otherwise "CustomDevPointNewData" can be used, sure. It is called each and every time a DATA command is received. Simply split up the information passed to function by the "," and select n-th part (your millis-part, e.g. the 4-th one in "DATA,TIME,DATE,millis(),Something,Something")), compare that to the value in your textbox and in case it is larger return a "false" by the function. As far as i know (got no access to the code at the moment) that should prevent PLX DAQ from logging. Otherwise just create a global variable on your own and set it to false and expand my function that actually writes to the sheet to check that variable. Or if you are comfortable with completely stop PLX DAQ from running programmatically click the "Stop logging" button (something like btn_loggin.click() or stuff like that).

I have a 4 channel temperature shield and it fails when the memory reaches the limit. I have to drop those Serial.print lines for it to operate.
Ok that is though. Would you mind doing me the favor to check how much memory my demo sketch takes upon just by itself? The 8% for that few lines is though but there won't be any good workaround in case someone really needs to use those boxes as the command is pretty long itself already....

How do I save the last config values in settingsheet?
That is kind of tricky ... on load there is a function that looks up all values on the (hidden in Excel) sheet and puts them into variables. Just look for the function that has multiple identical lines - it was dirty coding ;) Saving to the sheet by VBA is pretty simple. It is just Sheetname.cells(row,column).value = YourValue. That's all.


-----------------------------

Greetings
Jonathan


30percent


Hefeweizen! We are definitely on the same page Sir. The night is on me if I ever make it to German. Salute!

I will be working on this all day. Hopefully have something to share later. The operation I need this for is much slower, manually controlled between LED changes approximately 10sec to 2 minutes apart. I think option B) is where I'll start. I will create global variables for each x,y LED and have the value in the cell trigger the variable/turn on the LED until the next row/cell is selected. Unfortunately its not for anything as cool as animation or imaging. This is to control LED light through hundreds (124x2)of 1mm fiber optic end light cable strands and turn off/on individual strands from each matrix from Excel. There are some photos in the album attached above showing some 3D printed parts securing the fiber strand. When I get the software operational, mechanical won't take long to finish so I can share the complete project/purpose, (o.-).

Off topic, Are you signed up on Code Mentor?

cryotan

@NetDevil  Hi Jonathan,  

The memory consumption for the full default sketch:
------------------------------------------------------------------
Sketch uses 5258 bytes (16%) of program storage space. Maximum is 32256 bytes.
Global variables use 844 bytes (41%) of dynamic memory, leaving 1204 bytes for local variables. Maximum is 2048 bytes.

and after removing the following lines:

Code: [Select]
// set the names for the 3 checkboxes
 //  Serial.println("CUSTOMBOX1,LABEL,Stop logging at 250?");
 //  Serial.println("CUSTOMBOX2,LABEL,Resume log at 350?");
 //  Serial.println("CUSTOMBOX3,LABEL,Quit at 450?");

 // check 2 of the 3 checkboxes (first two to true, third to false)
 //  Serial.println("CUSTOMBOX1,SET,1");
 //  Serial.println("CUSTOMBOX2,SET,1");
 //  Serial.println("CUSTOMBOX3,SET,0");


-------------------------------------------------------------------
Sketch uses 5054 bytes (15%) of program storage space. Maximum is 32256 bytes.
Global variables use 688 bytes (33%) of dynamic memory, leaving 1360 bytes for local variables. Maximum is 2048 bytes.

Snaggles

Hi NetDevil,

I'm hoping that you or anyone can help me.

I'm will be running 8 probes (only 2 for now) and I can get data to go into Excel great. I even have it able to tell me which probe is with which data. The only problem is that it all goes into 1 sheet and I really would like it to go to their own sheets based off of which probe it's reading from.

I tried CELL,SET,ONSHEET but that didn't work the way I wanted. I'm thinking that I might have to do some VBA in the Excel sheet but I'm a little lost there as well.

Thanks!

This is what I have now:

Code: [Select]

// WhiteBox Labs -- Tentacle Shield -- I2C example
// www.whiteboxes.ch
//
// How to retrieve continuous sensr readings from op to 8 Atlas Scientific devices on the I2C bus
// and send the readings to a host computer via serial.
//
// This code is intended to work on all 5V tolerant Arduinos. If using the Arduino Yun, connect
// to it's usb serial port. If you want to work with the Yun wirelessly, check out the respective
// Yun version of this example.
//
// USAGE:
//---------------------------------------------------------------------------------------------
// - Set all your EZO circuits to I2C before using this sketch.
//    - You can use the "tentacle-steup.ino" sketch to do so)
//    - Make sure each circuit has a unique I2C ID set
// - Adjust the variables below to resemble your setup: TOTAL_CIRCUITS, channel_ids, channel_names
// - Set host serial terminal to 9600 baud
//
//---------------------------------------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------------------------
//
//Adapted with PLX-DAQ V 2
//
//---------------------------------------------------------------------------------------------

#include <Wire.h>                     // enable I2C.

char sensordata[30];                  // A 30 byte character array to hold incoming data from the sensors
byte sensor_bytes_received = 0;       // We need to know how many characters bytes have been received

byte code = 0;                        // used to hold the I2C response code.
byte in_char = 0;                     // used as a 1 byte buffer to store in bound bytes from the I2C Circuit.

#define TOTAL_CIRCUITS 2        // <-- CHANGE THIS | set how many I2C circuits are attached to the Tentacle shield(s): 1-8

int channel_ids[] = {97, 98};// <-- CHANGE THIS.
// A list of I2C ids that you set your circuits to.
// This array should have 1-8 elements (1-8 circuits connected)

char *channel_names[] = {"Probe 1", "Probe 2"}; // <-- CHANGE THIS.
// A list of channel names (must be the same order as in channel_ids[])
// it's used to give a name to each sensor ID. This array should have 1-8 elements (1-8 circuits connected).
// {"PH Tank 1", "PH Tank 2", "EC Tank 1", "EC Tank2"}, or {"PH"}

/*
   Setup Save Workbook Timer
*/

unsigned long previousMillis = 0;
const long interval = 30000;

/*
   End Save Workbook Timer
*/

void setup() {                      // startup function
  Serial.begin(9600);                // Set the hardware serial port.
  Wire.begin();                // enable I2C port.


  //Serial.println("CLEARDATA"); // Clears starting at row 2
  Serial.println("CLEARSHEET"); //Clears sheet Probe 1 starting at row 1


  //Define Columns
  Serial.println("LABEL,Time,Timer,Probe,mg/L 02,");

  //Set the names for the 3 checkboxes
  //Serial.println("CUSTOMBOX1,SET,0");
  //Serial.println("CUSTOMBOX2,SET,0");
  //Serial.println("CUSTOMBOX3,SET,0");

}

void loop() {
  //Read Probe Data
  for (int channel = 0; channel < TOTAL_CIRCUITS; channel++) {       // loop through all the sensors

    Wire.beginTransmission(channel_ids[channel]);     // call the circuit by its ID number.
    Wire.write('r');                              // request a reading by sending 'r'
    Wire.endTransmission();                            // end the I2C data transmission.

    delay(1000);  // AS circuits need a 1 second before the reading is ready

    sensor_bytes_received = 0;                        // reset data counter
    memset(sensordata, 0, sizeof(sensordata));        // clear sensordata array;

    Wire.requestFrom(channel_ids[channel], 48, 1);    // call the circuit and request 48 bytes (this is more then we need).
    code = Wire.read();

    while (Wire.available()) {          // are there bytes to receive?
      in_char = Wire.read();            // receive a byte.

      if (in_char == 0) {               // null character indicates end of command
        Wire.endTransmission();         // end the I2C data transmission.
        break;                          // exit the while loop, we're done here
      }
      else {
        sensordata[sensor_bytes_received] = in_char;      // append this byte to the sensor data array.
        sensor_bytes_received++;
      }
    }

    //End Read Probe Data

    //Print Probe Data

    Serial.println(':');

    switch (code) {                          // switch case based on what the response code is.
      case 1:                               // decimal 1  means the command was successful.
        Serial.println( (String)"DATA,TIME,TIMER," + channel_ids[channel] + "," + sensordata + ",AUTOSCROLL_20");       // print the actual reading
        break;                                // exits the switch case.

      case 2:                                // decimal 2 means the command has failed.
        Serial.println("command failed");   // print the error
        break;                                 // exits the switch case.

      case 254:                              // decimal 254  means the command has not yet been finished calculating.
        Serial.println("circuit not ready"); // print the error
        break;                                 // exits the switch case.

      case 255:                              // decimal 255 means there is no further data to send.
        Serial.println("no data");          // print the error
        break;                              // exits the switch case.

    }
  }

  // for loop

  //Automatically save workbook every minute (60000ms)
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    Serial.println("SAVEWORKBOOK");
  }
  //End Workbook Saving

}


NetDevil

Hi @all,
first of all sorry for the late responses. I am moving houses at the moment and will be pretty busy over the next days. Therefore any responses will be delayed. And worst of all .... there are currently problems with the internet connection at my new place ... might be I won't be able to respond at all for a few weeks ....

That's said let's solve what is here:




Hi NetDevil,
(...)
I tried CELL,SET,ONSHEET but that didn't work the way I wanted. I'm thinking that I might have to do some VBA in the Excel sheet but I'm a little lost there as well.
@Snaggles,
hi :) there are two ways to solve your problem I think.

The first one is to use CELL,SET,ONSHEET,SheetNameX => what didn't work here? The big advantage of the DATA command is that it automatically writes to the next free row; CELL,SET on the other hand does not. For that one to work in your case you need a counter for each probe indicating the current line to write to on the respective sheet. Also please note the information in the Beginners Guide about adding a short delay of maybe 3 ms before each CELL,SET command to clear the buffer. Otherwise many times 0's were written in Excel.

The other option is indeed using VBA and to write an own command like "SETACTIVESHEET,SheetNameX" to set the globally used variable in PLX DAQ to the posted SheetNameX. That way all DATA commands coming in afterwards will be routed to that sheet. The command can be added within the CustomDevPoint function. However I guess there might be issues with the row variable for the sheet since that is a global counter as well I guess. Therefore it should be adjusted as well each time the sheet changes (there is a function to get the currentMaxRow for a sheet).

If I were you I'd start with the first option as all changes can be done in Arduino code.




@cryotan,
great, thanks for checking and posting that!
The strings really take up a lot of dynamic memory. I should warn the users in future versions to be careful with such long written commands. But I'm glad the basic code does not take away that much space  :smiley-mr-green:




@30percent,
those pictures look really cool! Especially the 3D printed parts are amazing. 3D printing is a fantastic thing in combination with Arduino. One can build his own hardware, software and even cases to make a project look totally professional and robust. Nice work :) Good luck on finishing the code!
I never knew about CodeMentor but checked the site and it is a really great idea. Can I somehow see what kind of questions or projects or coding langues are popular there? And in the end one can even sign up for a paid project :o good way to earn some money ;) but shouldn't tell my boss about it  :smiley-cool:




Greetings to all of you

30percent




@30percent,
those pictures look really cool! Especially the 3D printed parts are amazing. 3D printing is a fantastic thing in combination with Arduino. One can build his own hardware, software and even cases to make a project look totally professional and robust. Nice work :) Good luck on finishing the code!
I never knew about CodeMentor but checked the site and it is a really great idea. Can I somehow see what kind of questions or projects or coding langues are popular there? And in the end one can even sign up for a paid project :o good way to earn some money ;) but shouldn't tell my boss about it  :smiley-cool:




Greetings to all of you
Thank you Jonathan! Learning 3D printing has been a lot of fun along the way. Glad you checked out code mentor. There are mentors for all code languages, some that specialize in one, some that special in all.  As good as you are helping people here, thought you might earn some $ at the same time. :D

Made some more progress on remixing the PLX demo sketch. I can see data pulled from Excel in the serial monitor. So cool! Almost got this sketch solved.

Good luck on the housing/internet change.






Snaggles





@Snaggles,
hi :) there are two ways to solve your problem I think.

The first one is to use CELL,SET,ONSHEET,SheetNameX => what didn't work here? The big advantage of the DATA command is that it automatically writes to the next free row; CELL,SET on the other hand does not. For that one to work in your case you need a counter for each probe indicating the current line to write to on the respective sheet. Also please note the information in the Beginners Guide about adding a short delay of maybe 3 ms before each CELL,SET command to clear the buffer. Otherwise many times 0's were written in Excel.

The other option is indeed using VBA and to write an own command like "SETACTIVESHEET,SheetNameX" to set the globally used variable in PLX DAQ to the posted SheetNameX. That way all DATA commands coming in afterwards will be routed to that sheet. The command can be added within the CustomDevPoint function. However I guess there might be issues with the row variable for the sheet since that is a global counter as well I guess. Therefore it should be adjusted as well each time the sheet changes (there is a function to get the currentMaxRow for a sheet).

If I were you I'd start with the first option as all changes can be done in Arduino code.
@NetDevil Thanks for your reply. I would prefer to get it to work in Arduino myself. Here are some troubleshooting trials I've tried.

If I put in
Code: [Select]

Serial.println("CELL,SET,ONSHEET,Probe 2");


(Probe 2 is my 2nd sheet name) I get all the data printed on the first sheet still and a Error within command 9/Subscript out of range. I've tried different combinations of commas added in thinking it might be a missing variable confusing it but get the same problem.

If I put in my string that I want printed
Code: [Select]

Serial.println("CELL,SET,ONSHEET,Probe 2, (String)DATA,TIME,TIMER," + channel_ids[channel] + "," + sensordata + ",AUTOSCROLL_20");


I get nothing printed and an error 13/Type mismatch

If I follow the beginner's guide and do
Code: [Select]

Serial.println("CELL,SET,ONSHEET,Probe 2,B,2,DATA");


It prints the actual word DATA in sheet Probe 2, Cell B2 just fine but also keeps overwriting it. All the probe data is still printed on the first sheet as well even though I'm not changing the sheet again.

 I guess I'm not exactly clear on the syntax of the command or maybe I'm trying to do something that it can't do...?

dasaya007

Thanks for this program.
it works ,but sometimes comerror pops up

zueses

hi, does anyone know the fastest sampling rate the plx-daq/excel can handle?

trying to analyze sound frequencies and so need to take readings at a few hundred Hz at the minimum, not sure if i can do that with excel. was initially going for a sampling rate of 1000Hz

after experimenting I feel like what I'm having trouble with also is printing the time elapsed from progam start to excel as the code works fine with serial monitor

Code: [Select]
// EmonLibrary examples openenergymonitor.org, Licence GNU GPL V3

#include "EmonLib.h"             // Include Emon Library



#define VOLT_CAL 269
#define CURRENT_CAL 60
unsigned long time;

EnergyMonitor emon1;             // Create an instance

void setup()

  Serial.begin(9600);

  Serial.println("CLEARDATE");
  Serial.println("LABEL, Time Elapsed,Wall Voltage,Wall Current, Wall Power, Mic Voltage");
 
  emon1.voltage(A0, VOLT_CAL, 1.7);  // Voltage: input pin, calibration, phase_shift
  emon1.current(A1, CURRENT_CAL);       // Current: input pin, calibration.
}

void loop()
{
  emon1.calcVI(20,50);         // Calculate all. No.of half wavelengths (crossings), time-out

  float currentDraw     = emon1.Irms;             //extract Irms into Variable
  float supplyVoltage   = emon1.Vrms;                    //extract Vrms into Variable
  int sensorValue = analogRead(A4);

   time = millis();

  Serial.print(time);
  Serial.print(",");
 
Serial.print(supplyVoltage);
Serial.print(",");
Serial.print(currentDraw);
Serial.print(",");
Serial.print(supplyVoltage*currentDraw);
Serial.print(",");
Serial.println(sensorValue);

 
}

jandres

Hi. I have some problems printing data from MPU6050. Excel goes out frecuently. I want print almost 1000 data but I get around 100. Thanks.

Andres Bravo

JRArduino

Hi friends!
Firts, thanks for this fantastic program! But, I have a question about PLX-DAQ. I need to import about 50 columns of dates in Excel. Is it possible to do? Exist any version capable to do it?
Thanks you!

ddominique

Hi,

Thank you for this beautiful application.

I currently use it to test it with an Arduino Uno, and that seems to work.

I would like to use your Macro to read and place in Excel the value of a RFID Tag.

The RFID reader is directly connected to RS232 (without Arduino).

Could you guide me to change the part of the macro?

I am asking you this because I am absolutely not a specialist in this language VBA.

Regards

NetDevil

Oh wow, a lot that happened here!
Internet is still not stable, but good enough to post some replies (although time is short as well, should be building furniture instead of Arduino :) )




@Snaggles
Yeah you need to use the full command for writing to a specific sheet.
Code: [Select]
Serial.println("CELL,SET,ONSHEET,Probe 2");missing arguments (too few)
Code: [Select]
Serial.println("CELL,SET,ONSHEET,Probe 2, (String)DATA,TIME,TIMER," + channel_ids[channel] + "," + sensordata + ",AUTOSCROLL_20");wrong syntax of String parsing. The "(String)" thing needs to be right after the "(" of "Serial.println(". Also the AUTOSCROLL might not work with CELL,SET - not quite sure right now.
Code: [Select]
Serial.println("CELL,SET,ONSHEET,Probe 2,B,2,DATA");that code will only print the word DATA to cell B2 on sheet "Probe 2", you should use a counter to increase the row (here 2) by one in each loop.
What seems to be best for you is:
Code: [Select]
Serial.println((String)"CELL,SET,ONSHEET,Probe 2,A," + i + "," + "TIMER");
Serial.println((String)"CELL,SET,ONSHEET,Probe 2,B," + i + "," + channel_ids[channel]);
Serial.println((String)"CELL,SET,ONSHEET,Probe 2,C," + i + "," + sensordata);
i = i + 1;

You need to paste each value you want to have specifically to a cell. Thus in your example it is three data per row what makes three commands one for each column A and B and C. Starting with row "i" which is increased afterwards.

I must admin that command is not very cool at the moment - I should put that on my bucket list to improve it with the next version.




@dasaya007
You're welcome :) Thanks for the feedback.
The COM error is typically a result of an already in use COM port. Most likely the running PLX DAQ was closed without disconnecting first or the connection between the computer and Arduino was interrupted e.g. by pulling the cable. Afterwards the port is still blocked and it is best to close PLX DAQ and disconnect + reconnect Arduino.





@zueses
I transferred data at over 1.000.000 baud but it got unstable. At the moment I would recommend going over 18.000. But it also depends on how many delays you have in your code. The baud rate is only the speed of transfer - if you transfer one data set every 10 seconds all is fine, but if you spam data at 1.000.000 baud in your loop function it will most likely crash.
1000 Hz is once every millisecond which is quite fast. That will most likely not work at the moment.

Regarding your issue: your code is fine, but you need to start with the "DATA" key word for the correct command in Excel to trigger.
Using String class your code can be shortened (however this is not good regarding performance since the class has a huge memory consumption):
Code: [Select]

  Serial.println( (String) "DATA," + time + "," + supplyVoltage + "," + currentDraw + "," + (supplyVoltage*currentDraw) + "," + sensorValue );





@jandres
Try lowering your baud rate (at maybe 5xxx) and building in some delays of maybe 3 to 10 milliseconds. Spamming too much data in too little time can kill PLX DAQ




@JRArduino
Thank you very much :)
The standard version of PLX DAQ should be able to do that. Using the DATA command followed by each value separated by a comma from the next one. I programmed it to be dynamically in size - let's hope that works with up to 50 :)




@ddominique
Beautiful is a nice word :) thanks a lot :)
There is no need for you to be a VBA specialist. All you need is the C language as you will write all your code in Arduino IDE. Simply read your RFID ID as normal with Arduino, maybe save it in a variable and use the CELL,SET command to post it to a sheet in Excel with a specific column + row combination (e.g. cell D5 if you want it there).
Otherwise you can also use the DATA command to just post it to the next free row on your Excel sheet.
Take a look at the Beginners Guide where all those commands are explained.





Greetings to all of you.

Brilliantgp

Hey NetDevil,

I want to ask, I am using Mac OS currently, and is trying to use the PLX-DAQ. What I am confused is that in my arduino application, which I have reinstalled multiple times just in case. I just can't seem to find COM in port? Or is it possible to use usbmodem in PLX-DAQ excel?

Thx

CarlosOliveira

Hello!
Thank you for the great effort

I'm trying to send data from an Excel Document to Arduino UNO

Basically what I'm doing is changing the set point of the temperature every second to make a "Reflow profile for soldering"

is it possible to do that with the PLX-DAQ ?

Thanks

Go Up