LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple slaves

There are two elements in the array, so the For Loop will run twice.  Then the while loop will iterate and the process will repeat.

0 Kudos
Message 11 of 41
(1,019 Views)

@RavensFan wrote:

There are two elements in the array, so the For Loop will run twice.  Then the while loop will iterate and the process will repeat.


Yes. I meant the 10 readings that I want from each of the two slaves. A loop condition for the while loop?

0 Kudos
Message 12 of 41
(1,014 Views)

Sure.  Or if you only want 10 readings, then turn the while loop into a For Loop with a 10 wired to the N terminal.

0 Kudos
Message 13 of 41
(1,011 Views)

Thank you!
When I for example read the registers 1004-1007 (temp:1004-1005, current:1006-1007), they are saved together in one column (temp, current, temp, current etc.)' in the excel file. How can I save the data in two columns? 

0 Kudos
Message 14 of 41
(1,002 Views)

You need to work with your arrays a little better.  Each iteration of the For Loop gives you a 1-D array consisting of Temp and Current for a single slave.  They are in columns.  The 2nd iteration of the loop gives you another 1-D array and that is auto-indexed into the first.  So now you have a 2-D array like this.

 

Slave1 Temp,  Slave 1 Current

Slave2 Temp,  Slave 2 Current

 

Now you are using index array to get out the 1st row (which only gives you the first slave).

 

Instead of 2 columns, don't you actually want 4?  (They are 4 different distinct data points).  I would turn the For Loop tunnel into concatenating.  Now you will have a 1-D array coming out that is like this:

Slave1 Temp,  Slave 1 Current, Slave2 Temp,  Slave 2 Current

 

Send that to the To DDT Express VI and make it set for 1-D array of scalars-multiple channels.

 

PS:  You'll find you'll need to do something with that Set Dynamic Attributes.  I'll let you figure that out.  Reading the help on the Express VI would be a good idea.

0 Kudos
Message 15 of 41
(995 Views)

Thank you RavensFan, I appreciate you patience.
Yes, I want four columns.


When I change the For-loop tunnel into "Auto-concatenated" I wasn't able to use the Index Array.

But when I changed it to Insert Into Array and configured the dynamic data to 1d array of scalars multiple channels, I got the data into different columns (tried with one slave).I got:

Time, Untitled (temp), Time 1, Untitled1 (curr). The time displays 1904-01-01 00:00:00,000 even if I have check the relative Time mode in the Set Dynamic Attributes. And It would be enough with one Time stamp..

 

I didn't wire the Signal Index on the Set Dynamic Attributes, should this be used for the different distinct data pts?

 

save2array.PNG

0 Kudos
Message 16 of 41
(988 Views)

I said you have to get rid of the Index Array.

 

Your time is 1/1/1904 00000 because you don't have any time data.  You started with an array of data.  It doesn't have any t0 or dT data associated with it like it would if you had a waveform data type.

 

Yes. You'd need to set the Signal Index and have that run each time for each signal.  I'd do it in a For Loop where you use the i value and an array of names for each signal.

0 Kudos
Message 17 of 41
(984 Views)

I created a string array with some headers. But how can I add the string array and the array with the signal data when they contain different data types? I tried with clusters but it didn't let me wire to the Array.

header.PNG

0 Kudos
Message 18 of 41
(976 Views)

Why did you put in an Insert into Array?

 

Wrap the Dynamic Attributes with a For Loop.  Use the i from the For Loop not the While Loop.

 

If you are still stuck, attach your latest VI.

0 Kudos
Message 19 of 41
(971 Views)

The outer loop is a For loop, so the "i" I use is from a For loop.
I am stuck in getting the two different data types (header+signal) into the Dynamic Attributes. I though putting them into an array first would let me send it into Dynamic Attributes.


0 Kudos
Message 20 of 41
(966 Views)