Go Down

Topic: Naming new Sheets in PLXDAQ (Read 343 times) previous topic - next topic

Izzy13

Hi there,

I'm using PLX DAQ v2.11 made by Net Devil, and within the manual highlights the ability to print the values into a named sheet other than ActiveSheet

Quote
a.   CELL,SET
By this command you can set the value of any cell in the Excel workbook with any value you want. This can either be done on the ActiveSheet or on any other sheet.
Syntax to set a value on the ActiveSheet:
Serial.println("CELL,SET,C9,MyValue");
Syntax to set a value on a named sheet somewhere in the workbook:
Serial.println("CELL,SET, ONSHEET,AnySheet,C,9,MyValue");
My question is how do you name the other sheet (which in this case is AnySheet)? Do I have to manually name it in Excel or is there a command that I'm missing (like how with LABEL you can rename the uppermost column of the sheet)

Thanks in advance!

sumguy

If you right click with your mouse on any of the tabs on the bottom of each worksheet it brings up a menu that allows you to rename that particular worksheet. So for example if you right clicked the second tab and renamed that worksheet to Izzy13 you would be able to write data to the cell of choice using the following syntax

Code: [Select]
Serial.println("CELL,SET,ONSHEET,Izzy13,C,2,13");

that would write the value 13 into cell C2 on the worksheet Izzy13

ieee488

If you right click with your mouse on any of the tabs on the bottom of each worksheet it brings up a menu that allows you to rename that particular worksheet. So for example if you right clicked the second tab and renamed that worksheet to Izzy13 you would be able to write data to the cell of choice using the following syntax

Code: [Select]
Serial.println("CELL,SET,ONSHEET,Izzy13,C,2,13");

that would write the value 13 into cell C2 on the worksheet Izzy13
He's not asking how to do it manually.

He's asking whether doing it manually is the only option.

sumguy

Yes that crossed my mind but the effort did not seem worth it when manually modifying the worksheet name is so simple and can be saved for re-use.

But yes the worksheet can be renamed in VBA and yes a new command can be added to the existing VBA so that the name could be modified over a serial connection

Izzy13

If you right click with your mouse on any of the tabs on the bottom of each worksheet it brings up a menu that allows you to rename that particular worksheet. So for example if you right clicked the second tab and renamed that worksheet to Izzy13 you would be able to write data to the cell of choice using the following syntax

Code: [Select]
Serial.println("CELL,SET,ONSHEET,Izzy13,C,2,13");

that would write the value 13 into cell C2 on the worksheet Izzy13
Thanks for the help!

But can I use this method/syntax to print large amount of data towards another sheet? Like Serial.println("DATA, ONSHEET, Data1");

sumguy

That's a good question and as far as I can see the Serial.println("CELL,SET,ONSHEET,Izzy13,C,2,13"); only allows for one data value.

The user interface has a combo box and "load" button that allows switching between worksheets but again this is a manual operation, is that what you would want?.

There is a variable called WStoUse in the VBA code which contains the value of the active worksheet and although I have not tried it I would think it is a simple matter to modify its value on the fly. This brings the additional task of tracking the value of columns and rows. Additionally there is a hidden sheet that you would not want to write to by mistake but apart from all of that it is not extremely difficult.

sumguy

Out of curiosity I thought I would try switching sheets using the tab name.


EXCEL:
I added 3 new worksheets and named them Izzy1 Izzy2 and Izzy3

Then I modified the VBA code slightly, all the mods were done in the DataReady sub, three mods in total

Mod1 was to add the static integer columnOffset
Code: [Select]
Private Sub DataReady(Data As String)

    On Error GoTo Data_Error
    Dim DataVal() As String
    Static columnOffset As Integer


Mod2 was to add another Case to the Select Case routine, I called it "SHEETNAME". It takes three values, sheet name, column and row. The following goes just above the Case "CLEARDATA"
Code: [Select]
Case "SHEETNAME"
                Set WStoUse = ThisWorkbook.Sheets(DataVal(1))
                columnOffset = DataVal(2)
                row = DataVal(3)


Mod3 is in the Case "DATA" and adds the columnOffset to FinalColumnCount enabling us to move the data around the sheet
Code: [Select]
WStoUse.Cells(row, FinalColumnCount + columnOffset).Value = ReplaceData(DataVal(x)) '.Value is important for Excel to recognize e.g., numbers as numbers


Arduino:
I used the following sketch as a test @ 9600 baud, the command is "SHEETNAME",anysheetname,column,row
Code: [Select]
void setup()
{
  Serial.begin(9600);  //start Serial in case we need to print debugging info
  delay(50);
  doAloop();
}
 
void doAloop()

{
Serial.println("SHEETNAME,Izzy1,0,1");
firstCount();
Serial.println("SHEETNAME,Izzy2,0,1");
firstCount();
Serial.println("SHEETNAME,Izzy3,0,1");
firstCount();
Serial.println("SHEETNAME,Izzy1,4,1");
secondCount();
Serial.println("SHEETNAME,Izzy2,4,1");
secondCount();
Serial.println("SHEETNAME,Izzy3,4,1");
secondCount();
}

void firstCount()
{
  int z;
 for(z=0;z<10;z++){ Serial.println("DATA,1,2,3");}
}

void secondCount()
{
  int z;
 for(z=0;z<10;z++){ Serial.println("DATA,4,5,6");}
}

void loop(){}


It may need a little work but I can see where it might be useful

Go Up