Jump to content

Recommended Posts

Posted

Hi everyone!

I need advice what is the right way to load from an array?

Below is picture of my ladder, where is also shown previously stored data in the same array that I want to load from.

Rung 6 - data is saved from C  (TalkKgIzmereno)  into B ( Array Talk[Array Talk_0] )

Rung 7 - I want to load result from B ( Array Talk[Array Talk_0] ) into C (proba)

Storing in Array woks perfect, but didn't have success to load...

Thanks in advance!

Petar

Untitled.jpg

Posted

I'm not sure what you are trying to do, but store in array inputs are:

A - Array

B - The index inside the array that the value will be stored to

C - the value to store.

 

I'm not sure why you are putting Array Talk[Array  Talk_0] in B. Assuming that it's initial value of Array  Talk_0 is 0, then the value of TalkKgIzmereno will be stored into index 0 of the array (into member Array  Talk_0), so it will not have the value 12.

Now, if you'll call the store in array again, it will not try to put the value into index 12 (Array  Talk_12), and I'm not sure that your array has 13 or more items.

 

The same thing is with Load from Array

A- Array

B - The index inside the array that the value will be read from

C - is the variable that the value will be written to.

 

You are trying to read the value of Array  Talk[Array  Talk_12] into proba.

I'm pretty sure that this is not what you are trying to do in both the Store and Load functions.

 

Posted

Let me try to explain my whole idea best as I can...

Rung 6 - I'm writing in array values that I'm getting from analog input (value is previously linearized) and that is TalkKgIzmereno. In this case I'm getting value of 12.

That value is stored in Array Talk [Array Talk_0] when I press StartTalk button. My mistake is that I didn's show on picture, that I have also button for Remove From Array block, so I can erase data from Array Talk and store again new value if I need in same array.

Rung 7- I'm trying to read value from that same Array, Array Talk [Array Talk_0] and store it in proba (so I can use that value for further compares). In this case it is previously saved value 12.

As I written in first post, Storing (and Removing) values from array works as expected, but I can't Load value.

I hope that this explanation is little bit understoodable than previous...

Again, thanks for your time and help

Posted

As I wrote on my previous post, you are using the Load and Store elements in correctly.

What your Store is actually doing is: Array Talk[Array Talk[Array Talk_0]] TalkKgIzmereno , 

and the load is actually doing: proba =  Array Talk[Array Talk[Array Talk_0]] .

 

When Array Talk_0 is 0, then Array Talk[Array Talk[Array Talk_0]]  becomes Array Talk[0] , 

but after you store the value 12, then Array Talk_0 has the value 12, then the load tries to do:  proba =  Array Talk[12]

 

The Load and Store in array utilities are meant for reading or writing to a different cell index on each time (For example, iterating an array). In your case, I understand that you always want to access index 0. If that's the case, then you don't need to even use Load from array and Store in array.

Just use a regular store Store element, where A contains TalkKgIzmereno  and B contains Array Talk [Array Talk_0]

and for Loading the value,  A contains Array Talk [Array Talk_0], and B contains proba

 

In pseudo code, the regular store element does: B = A  (Put the value of A inside B )

In pseudo code, the Store in Array does: A[ B ] = C   (Put the value of C inside array A, at index B )

 In pseudo code, the Load from Array does: C = A [ B ]  (put the value inside array A at index B inside C)

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.