From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remote Command/ACK Response

Hello everyone,
 
I am sending a ?SCU (scan) command to record transmittance from a set wavelength and the data comes up a line at a time and I have to reply to each line with an ACK response (ASCII - 6, control - F).  I also have to detect the ##END= line to know when the data set ends.
 
Problem lies in how to do this and where I have to add it in my VI.
 
Attached is my VI (the read portion is all messed up, I deleted a portion of it and haven't been able to modify it), and an old text file of the data I will be looking to receive.
 
 
Thanks in advance for any help with this
 
 
**For some reason the text file isn't uploading properly.  I'll try and get it up real quick though..

Message Edited by Steve.Briggs on 01-11-2007 09:37 AM

0 Kudos
Message 1 of 17
(4,060 Views)
The original text file was given to me as a .jcp file, which won't upload on the forums, and as a .txt file it doesn't show up as anything.  So here it is...
 
##TITLE=
##JCAMP-DX=4.24
##DATA TYPE=UV/VIS SPECTRUM
##ORIGIN=CECIL INSTRUMENTS LTD
##OWNER=PUBLIC DOMAIN
##DATE=93/11/26
##TIME=14:40:34
##SPECTROMETER/DATA SYSTEM=CECIL  CE 3040
##INSTRUMENT PARAMETERS=
     SCAN RATE=10.0NM/S
     REFERENCE=
     OPERATOR=
##DATA PROCESSING=Smoothing:   1.0 nm
##RESOLUTION=2.0
##SAMPLE DESCRIPTION=
##TEMPERATURE=
##PATH LENGTH=
##XUNITS=NANOMETERS
##YUNITS=TRANSMITTANCE
##XFACTOR=1
##YFACTOR=0.00004
##FIRSTX=0200.00
##LASTX=0700.00
##NPOINTS=1001
##FIRSTY=0.00028000000000
##MINY=0.0001
##MAXY=0.8219
##XYDATA=(X++(Y..Y))
200.00 7 9 9 6 6 8 9 8 8 9 7 6 5 5 8 7 5 3 3 5 6 5 5 5 5 5 7 7 5 5 5 6 4 5
217.00 5 5 6 7 9 8 8 12 16 20 26 30 34 42 52 64 78 90 103 119 140 161 183
228.50 208 235 261 289 318 346 376 408 438 471 510 545 581 621 663 704 744
237.00 789 834 872 911 964 998 1008 1015 1011 1015 1050 1119 1218 1321 1414
244.50 1501 1581 1657 1731 1803 1868 1932 2000 2066 2124 2183 2239 2294
251.00 2356 2426 2504 2598 2697 2796 2895 2993 3092 3191 3286 3377 3467
257.50 3562 3674 3793 3897 3990 4077 4160 4241 4332 4437 4551 4678 4822
264.00 4974 5128 5282 5431 5582 5734 5882 6031 6179 6318 6456 6592 6720
270.50 6851 6987 7128 7269 7408 7543 7677 7807 7924 8038 8162 8290 8409
277.00 8506 8572 8566 8446 8243 8091 8172 8515 9000 9486 9899 10231 10495
283.50 10727 10931 11112 11257 11304 11208 10972 10669 10415 10315 10454
289.00 10763 11059 11305 11558 11869 12216 12550 12846 13155 13349 13477
294.50 13667 13852 14029 14197 14372 14551 14716 14873 15035 15198 15354
300.00 15497 15626 15738 15843 15954 16068 16171 16270 16371 16462 16545
305.50 16634 16722 16804 16892 16978 17053 17119 17179 17254 17331 17393
311.00 17455 17526 17594 17647 17699 17755 17810 17865 17967 18025 18024
316.50 18085 18131 18162 18205 18250 18286 18324 18350 18375 18420 18465
322.00 18489 18508 18537 18565 18595 18630 18667 18706 18737 18756 18775
327.50 18807 18818 18811 18806 18780 18726 18663 18575 18444 18271 18061
333.00 17851 17691 17672 17801 17997 18201 18366 18476 18546 18610 18665
338.50 18710 18738 18746 18759 18758 18753 18757 18763 18757 18725 18674
344.00 18648 18657 18660 18640 18610 18573 18525 18490 18494 18541 18623
349.50 18726 18828 18887 18905 18915 18923 18933 18949 18975 18994 18996
355.00 18972 18904 18772 18570 18259 17804 17163 16244 14971 13395 11680
360.50 10320 9808 10183 11186 12416 13587 14564 15321 15915 16429 16923
366.00 17375 17750 18041 18238 18364 18454 18542 18652 18929 19127 19321
371.50 19486 19619 19721 19792 19838 19867 19884 19897 19902 19900 19898
377.00 19897 19904 19908 19877 19833 19770 19674 19548 19412 19306 19272
382.50 19312 19382 19435 19425 19360 19261 19164 19103 19108 19196 19329
388.00 19465 19601 19701 19747 19751 19747 19749 19760 19797 19848 19894
393.50 19933 19968 20001 20013 20015 20017 20019 20026 20043 20054 20056
399.00 20056 20072 20145 20127 20050 20046 20045 20054 20062 20064 20066
404.50 20068 20071 20071 20071 20068 20055 20041 20038 20030 20016 19991
410.00 19953 19904 19834 19731 19598 19420 19203 19024 18891 18796 18702
415.50 18560 18349 18041 17665 17293 16977 16789 16809 17019 17397 17811
421.00 18228 18582 18938 19059 18971 18916 18839 18799 18812 18878 18998
426.50 19151 19305 19451 19584 19696 19784 19848 19885 19899 19894 19881
432.00 19865 19849 19826 19808 19788 19757 19708 19639 19542 19425 19289
437.50 19125 18927 18672 18338 17931 17415 16690 15653 14194 12268 10016
443.00 7696 5519 3772 2675 2124 1989 2194 2699 3518 4654 6056 7522 8753
449.50 9646 10180 10335 10121 9614 8984 8417 8062 8019 8350 8990 9809 10625
456.00 11224 11432 11174 10528 9615 8583 7621 6996 6855 7143 7697 8386 9187
462.50 10076 11037 12098 13292 14477 15478 16282 16908 17404 17791 18093
468.00 18359 18602 18771 18864 18898 18890 18854 18802 18749 18694 18591
473.50 18562 18681 18722 18749 18874 19025 19184 19349 19499 19615 19689
479.00 19715 19680 19619 19537 19442 19330 19208 19094 18973 18853 18760
484.50 18719 18733 18770 18805 18824 18831 18823 18805 18805 18843 18905
490.00 18984 19050 19160 19312 19426 19538 19647 19747 19850 19945 20012
495.50 20068 20119 20167 20203 20224 20246 20267 20292 20311 20320 20327
501.00 20338 20334 20332 20334 20330 20330 20333 20336 20336 20331 20328
506.50 20323 20320 20318 20308 20304 20310 20320 20324 20323 20327 20329
512.00 20328 20325 20325 20329 20353 20378 20361 20337 20337 20338 20337
517.50 20331 20325 20322 20326 20328 20324 20319 20314 20307 20299 20288
523.00 20276 20265 20250 20227 20203 20176 20143 20113 20085 20041 19987
528.50 19927 19850 19751 19631 19491 19315 19089 18805 18440 17957 17355
534.00 16717 16138 15639 15242 14970 14829 14806 14899 15100 15400 15799
539.50 16228 16597 16941 17285 17589 17837 18052 18235 18366 18468 18543
545.00 18570 18574 18571 18563 18553 18580 18650 18752 18910 19073 19202
550.50 19326 19432 19522 19594 19649 19706 19770 19843 19921 20006 20093
556.00 20169 20232 20287 20330 20364 20396 20405 20402 20411 20416 20418
561.50 20426 20437 20444 20448 20445 20436 20445 20456 20458 20458 20463
567.00 20465 20467 20467 20463 20461 20469 20473 20471 20468 20471 20472
572.50 20473 20476 20480 20483 20485 20485 20474 20467 20466 20467 20467
578.00 20476 20492 20499 20502 20480 20474 20475 20476 20475 20476 20476
583.50 20479 20478 20480 20484 20486 20484 20478 20477 20475 20473 20474
589.00 20477 20463 20448 20464 20476 20478 20477 20478 20483 20480 20477
594.50 20470 20464 20466 20468 20472 20477 20478 20477 20475 20475 20468
600.00 20463 20467 20469 20471 20476 20475 20452 20455 20481 20481 20478
605.50 20479 20482 20483 20481 20481 20480 20478 20478 20479 20476 20472
611.00 20475 20476 20472 20472 20470 20470 20472 20470 20468 20465 20462
616.50 20457 20455 20455 20450 20445 20442 20435 20430 20423 20414 20406
622.00 20398 20388 20379 20369 20357 20341 20330 20317 20299 20274 20247
627.50 20221 20200 20173 20137 20098 20047 19977 19896 19799 19685 19562
633.00 19427 19262 19069 18864 18663 18483 18316 18153 18009 17897 17816
638.50 17760 17727 17726 17766 17849 17964 18094 18225 18350 18462 18557
644.00 18632 18687 18727 18748 18751 18742 18729 18710 18686 18657 18627
649.50 18597 18572 18573 18614 18679 18770 18866 18968 19074 19180 19277
655.00 19363 19443 19513 19567 19617 19640 19642 19642 19633 19613 19584
660.50 19555 19531 19503 19473 19443 19413 19393 19383 19390 19408 19442
666.00 19489 19546 19610 19678 19746 19822 19910 19997 20076 20145 20211
671.50 20268 20314 20353 20385 20408 20424 20441 20453 20464 20473 20480
677.00 20487 20492 20497 20501 20503 20505 20508 20508 20508 20511 20515
682.50 20517 20515 20516 20520 20520 20521 20523 20523 20522 20523 20522
688.00 20523 20527 20529 20529 20531 20531 20531 20532 20534 20535 20534
693.50 20537 20538 20538 20542 20545 20540 20539 20539 20539 20541 20545
699.00 20547 20542 20541
##END=
0 Kudos
Message 2 of 17
(4,045 Views)

Is there a terminator after each line of data? If there is, then you could do something like the attached. After each line is read, the string is searched to see whether the text 'END' is included. If it is, then the while loop stops. If it doesn't, then the ack is written. If there is no termination character after each line then it will be a just a little more complicated. You would check the number of bytes and read that number and keep reading until the number of bytes available is 0. Check the returned string for 'End' as in the example.

I rewrote the code for writing all of the command strings too. mainly to get rid of the sequence structure. Because you have not data flow between the VISA Writes and the delays, you don't know whether the delay will happen before or after the VISA Write. You could actually have something like VISA Write, VISA Write, Delay, Delay and I think you want to have a delay between each write.

Message 3 of 17
(4,036 Views)
Dennis, once again you show your brilliance.
 
Through my VI I was getting a read of \06\06\06\06\06\06\06\06\06\06\06\16\06##TITLE=\r\n...
 
I wasn't sure how to write the ack when the 'END' wasn't found.
 
The sequence structure before my read was doing what I wanted it to, but it proved to be a mess when I wanted to read and write the ack.
 
Thanks again Dennis, you saved me yet again. Smiley Very Happy Smiley Very Happy
0 Kudos
Message 4 of 17
(4,021 Views)

Well I see that i am too late.  Well see if this attached vi helps any.  I did a similar thing by getting rid of the sequence structure and using more of an Interrupt read thread.  let me know if you can open it i saved it as 7.1 from 8.0 so you might need to replace the time delay vi and the serial config vi

 

 

-James

Message Edited by James R on 01-11-2007 10:18 AM

- James

Using LV 2012 on Windows 7 64 bit
0 Kudos
Message 5 of 17
(4,021 Views)
Hi all,
 
Out of no where I am receiving a timeout error 1073807339 in the VISA Write/Read portion of my VI.  This subVI hasn't given me any problems since Dennis first helped me out.  I have the byte count set at 100, while the VI was working properly the byte count would never be greater than 74...ranging from 7 to 74.  However, I am getting a byte count of 0, and then the timeout error.  Nothing has changed with the actual write/read procedure so this error comes without reason to me.
 
Any input would be greatly appreciated.
 
Thanks
 
Attached is my updated VI.

Message Edited by Steve.Briggs on 01-30-2007 10:37 AM

0 Kudos
Message 6 of 17
(3,968 Views)
Now I am receiving the proper byte count and my commands are going through fully.  Can this sporadic activity be explained somehow...or could it be faulty connections/machines?
 
Much thanks,
0 Kudos
Message 7 of 17
(3,960 Views)

your read vi is reading as fast as the loop is going so if nothing is at the port then there will be 0 bytecount.  if you only want to read data when it arrives at the port look at the code that i posted earlier to use an interrupt method of retrieving data from the serial port. if you wish to continue to read like you are try to put a small delay in the loop and you will get much better performance.

you can also use the bytes at port property node and when it is greater than 0 then read the bytes at the port

 

 

Message Edited by James R on 01-30-2007 12:00 PM

- James

Using LV 2012 on Windows 7 64 bit
Message 8 of 17
(3,958 Views)

At this point, every attempt is resulting in error 1073807339 for timeout. Smiley Sad

I took a look at the vi you created James and the string read resulted in infinite a never ending feed of "\r\n", and then the same timeout error.

I then took a look at the bytes at port property node, and have it read the bytes when they are greater than 0.  This worked for one line, when the byte count was 17, but then resulted in byte counts of 0 there after, so nothing ever progressed.

I then put a small delay in my loop where I read and write the ack command (hex "06"), but it gave me an instant error 1073807339 for timeout rather than occurring after I read one line of data, which usually happens.

When I talked to one of the creators of the spectrophotometer I am using he said..."Note that data comes up a line at a time and each line has to be ACK'd in a few seconds or it times out, approximately less than 8 seconds."  I told him of my failure and errors, to which I received a reply of "I do not understand why you are having these troubles" and nothing more after that.

With that being said, I decided to take an opposite approach and removed every Time Delay during a write/read procedure and it would work...partially Smiley Indifferent.  Out of the 5 scans I need, it would successfully get through 2 or 3 scans, and then timeout at the 4th scan.  I assume this has something to deal with how fast I am reading, the byte count, or not being able to respond with the ack command at the end of each line quick enough.

I know full well that begging won't get me anywhere, but I am in dire need of a solution to this problem.  I'm sure many of you can relate to my frustration...having something work so well, being very close to finishing the project, then having these errors pop up and having no way of fixing them.

The VISA write/read vi is attached.

Many thanks for any input to this problem.

Message Edited by Steve.Briggs on 02-02-2007 10:57 AM

0 Kudos
Message 9 of 17
(3,910 Views)
Hi Steve,

What about increasing the timeout value; giving your session more time to read/write?  I don't know if you have already tried this, or if it's not possible, but it's something to check at least.  Here's another KB that deals with Serial timeouts in general and some troubleshooting techniques. 

Hope this helps!

Adam W
Applications Engineering
National Instruments

0 Kudos
Message 10 of 17
(3,891 Views)