04-16-2010 12:35 PM
Well guys I have a problem here sending the data.
When I made what is in left while loop, it works!
But when I made what is in right while loop I received a lot of crazy values.
Could some one help me on that?
The second while loop, I made only some simple math to the example. So don't worry with the math or anything so.
Only in the logic... the correct is I have to receive the correct value in bouth appended array. The only thing will change is the last 3 numbers!
If anyane can help me on that I will be pleasure!
Solved! Go to Solution.
04-16-2010 12:48 PM
Hi EduU,
left and right is not the same and i don't mean the local variables.
Why do you need it with the local variables if the other code runs?
Mike
04-16-2010 12:51 PM
EduU wrote:Well guys I have a problem here sending the data.
When I made what is in left while loop, it works!
But when I made what is in right while loop I received a lot of crazy values.
That's because you have a race condition due to your use of local variables. In the second loop the local variable instance gets read before you've actually written the new value to the indicator. You may want to peruse this thread.
04-16-2010 03:52 PM
Try this
It will remove your race conditions.
Dan07
04-19-2010 06:19 AM
Well guys, I was using Local variable because I use some boolean logic and depends on that the math with the number will be different.. but now I understand when I did the course I learned about Race condition.. but I forgot about it...
Now I only did something different and it works... I take off the local variable and linked the number inside the case selector =D
Thanks!
04-19-2010 11:16 AM
EduU wrote:Now I only did something different and it works... I take off the local variable and linked the number inside the case selector =D
Your code shows no case structures, so we have no idea what you're talking about. I'm willing to bet, though, that you probably still don't need to use a local variable and can probably use a wire directly.
04-19-2010 11:48 AM
Yes mate, is because the screen I sent is only an example
but yes, you are right... I don't use local variable anymore... I wire directly to case structure and it works nice =D
I had forget about race condition... =D
04-20-2010 06:37 AM
Hey mercurio... I thought my mistake was at local variable...
but today I fixed it
and still getting me crazy values.
So now I will upload a screen from my real code so maybe you can see any difference!
Thanks
This works:
and this don't work:
The only thing I changed is because before I send the last 4 elements... I check a case strucuture and modify this values...
but when I see in the other program... I get crazy values.... and in the first picture it works correct! -.-
If anyone know why it happens, please help me
04-20-2010 09:29 AM
04-20-2010 09:38 AM