LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

serial only reads 2 characters....

Solved!
Go to solution
Clean up your code. You are using local variables and you are not guaranteed what value you will read or in what order they are set. You have introduced a race conditions in yor code. I highly recommend that you change your code to use a state machine. It will be MUCH easier for you to maintain and control your execution.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 31 of 35
(1,017 Views)

I've removed the array and local variable (just replaced with a wire) and it just locks up as soon as i try to send the data.

 

I'm not farmiliar with state machines, ive seen them in the help file but they look a bit complicated (i'm trying to get the thing running quckly, then can look at a more efficient method later)

 

I'm not sure if my hardware is too slow to recieve the data from labview, its running at 8mHz and once data is detected it is in a loop with no extra delay until it sees "E"

 

The hardware will stay in the recieve loop untill E is recieved so if i send "h100E" it would have to recieve the "h1" miss the "00" but get the "E" in order to set the signal to 1 and exit the recieve loop like it is doing....

0 Kudos
Message 32 of 35
(1,015 Views)
A state machine is very easy to learn and work with and it will be significantly easier to understand, maintain and debug than your current code. LabVIEW is a dataflow language and that will dictate the order of execution. Simply removing the local variable and making it a wire may not get what you want. Visually you are building what you want to send AFTER you are sending it. I am not sure if think that your code is executing left to right or not. Your code is fairly difficult to follow and understand. A good book to read is the "LabVIEW Style Guide". You can also look at the coding styles posted here on NI's site.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 33 of 35
(1,010 Views)

i've stuck it in a sequence and it seems to work ok, when i close it i get an error saying that the recieve missed a character but i guess i just need to disable the recieve whilst i'm transmitting....

 

 

Thanks for your help...

 

 

zlast.jpg

0 Kudos
Message 34 of 35
(1,006 Views)
You don't need the sequence frame that you are using. The data dependency between the VIs will control the order of execution. You should spend some time trying to understand what dataflow means and how to use it.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 35 of 35
(1,000 Views)