05-13-2009 06:36 PM
Guys,
I've been fooling with this for awhile and can't seem to get it to work properly so I thought I'd ask for help.
I've written an interface for a PIC and can't seem to get it to send commands and receive them reliably. Sometimes, they'll go through and other times they won't. The PIC output is read through another 'while loop' repeating every 10 ms, while the user commands are sent in another 'while' loop that runs only upon front panel activity. I'm not sure if the two different run times have anything to do with it. The 'read' portion is much slower than it ought to be when compared with hyperterminal and it often doesn't read at all.
I know part of the problem has to do with RF leaking into the serial cable because the program runs better at my desk than at the test setup, where our device is emitting RF. Other than that, though, I don't know what the problem is. Hyperterminal seems to communicate with the PIC much more reliably. Does anyone have any suggestions? Do I need to send commands multiple times? Why is the 'read' so unreliable? I know all of the commands are being sent correctly and in the correct format, BTW.
The first 2 attachments are sub-VIs and the last is the main program.
Thanks in advance.
Solved! Go to Solution.
05-13-2009 08:06 PM
Update: OK, it turns out that it was actually reading, but that the 'read' loop was cycling so quickly that what was being read just flashed on the screen and you would only see it occasionally. The 'read' loop now looks like this:
I changed the read loop delay to half a second and now you can see the output from the PIC. I also added a property to the read property node so that the VISA read would just grab whatever bytes were available.
What I really want to do is make a scrollable waterfall display of the incoming commands from the 'read' that just continually appends more. Does this make sense?
05-13-2009 08:22 PM
05-13-2009 09:31 PM
05-13-2009 09:55 PM
If you want to store it as an array of strings, you would need to do the following:
0) Disconnect the input of the shift register (right side).
1) Connect the output of the build array to the shift register (right side). [You don't want the output of the read going to the shift register]
2) Disconnect the output of the first read going to the shift register (left side).
3) Connect the output of the first read to a build array (single input). [The output of that will be a 1-D array with one element in it]
4) Connect the output of the build array in step 3 to the shift register (left side).
5) Delete the PIC output indicator
6) On the output of the build array inside the loop, right click and select Create--> Indicator
05-14-2009 05:31 PM
Is this what you meant? (attached)
It wouldn't allow step 4 so I couldn't get it to work.
05-14-2009 07:18 PM
I think you meant "wire the left side of the shift register to the input of the 'build array' function" for 4). (see 1st attachment)
That seems to work almost the way I want, but it still has this indicator on the side and doens't really show the current command coming down the pipe and the last few, which is what I want. Instead, you have to keep clicking up on the indicator (see 2nd image). I want it to look exactly like HyperTerminal's display
05-14-2009 07:34 PM
Dennis,
Is this what you meant? I'm not quite sure how to wire up the scroll property node to get it to show the most recent command and the past few.
05-14-2009 10:54 PM
05-15-2009 01:37 PM
Dennis,
Thanks a lot. Is this what you meant? (attachment 1) It works!
The only issue I have now is that I want to turn the read 'on' and 'off', but when it's 'off,' I still want to be able to scroll back through what has already been read. I tried adding a true/false case statement inside of the 'while' loop and putting the 'read' inside of the 'true' statement (attachment 2), but I don't quite know what to do with the 'false' statement (att. 3). It seems to me that it will keep concatenating as long as the 'while' loop is running, and I only want it to concatenate when the 'read' control is flipped to 'on.'