Hi, from the command wiki
In pipeline mode, measurement tasks and processing tasks are handled separately (in a "measurement task sequencer" and a "processing task sequencer") and executed concurrently
It's not clear to me if in this code SerialOut is always executed before SerialIn or not:
SerialOpen(ComC3,38400,3,0,138,4)
Scan (50,mSec,100,0)
SerialOut (ComC3,"?Q",&H02,0,2) 'open poll request
SerialInRecord (ComC3,row2,&H02,0,&H0D0A,n2,01)
SerialOut (ComC3,"!","",0,0) 'close poll request
NextScan
In the terminal I see the commands in the following order: ?Q, ! , row2. And 20 ms between ?Q and row2. The data is still collected correctly.
I don't understand why with the modified code like this:
SerialOpen(ComC3,38400,3,0,138,4)
Scan (50,mSec,100,0)
SerialOut (ComC3,"?Q","",0,0)
SerialInRecord (ComC3,row2,&H02,0,&H0D0A,n2,01) '2 and 3 ascii char or &H02
NextScan
I continue to see the command ?Q and 20 ms after the Row2 response. Why exactly 20ms if I have not set any delay or timeout?
If SerialOut and SerialIn are considered one Process and the other Measure, how is sequentiality maintained in pipelinemode?
Thanks
To pair with SerialInRecord, use SerialOutBlock. With the right conditions, both run in the digital measurement task. There are notes in the CRBasic help for those instructions.
Do note that neither SerialOutBlock nor SerialInRecord delay the task. You would want a Delay in between them set to the digital task. The length of the delay depends on the response time of the sensor.
With the right conditions
What are these right conditions? I read the Serial Note but I can't find a distinction between pipeline and sequential mode.
If I run this program in sequential mode I obatin all data, with no row1 = NAN, as I want:
SequentialMode 'string: Q,-000.061,+000.049,+000.039,M,+024.73,00,04 BeginProg SerialOpen(ComC3,38400,3,0,512,4) Scan(50,mSec,1,0) SerialOutBlock (ComC3,"?Q",2) 'start polled mode Delay (0,25,mSec) '20ms from terminal emulator W' SerialInRecord (ComC3,row1,&H02,0,&H0D0A,n1,01) ChkSumF_1=HexToDec(Mid(row1,44,2)) Eqv CheckSum(row1,9,42) If ChkSumF_1 Then u_1 = Mid(row1,3,8) v_1 = Mid(row1,12,8) w_1 = Mid(row1,21,8) Ts_1 = Mid(row1,32,8) SS_1 = Mid(row1,40,2) EndIf SerialOutBlock (ComC3,"!",1) 'stop polled mode CallTable Sonic NextScan EndProg
Output terminal:
10:40:34.220 R .Q,-000.037,-000.023,+000.010,M,+023.51,00,.01 10:40:34.230 T ! 10:40:34.250 T ?Q 10:40:34.270 R .Q,-000.039,-000.021,+000.006,M,+023.49,00,.03 10:40:34.280 T ! 10:40:34.300 T ?Q 10:40:34.320 R .Q,-000.040,-000.022,+000.004,M,+023.47,00,.02 10:40:34.330 T ! 10:40:34.350 T ?Q 10:40:34.370 R .Q,-000.040,-000.021,+000.003,M,+023.49,00,.08 10:40:34.380 T !
If I run the same code in PipelineMode, I obtain lot of records with row1 = NAN and a terminal output like this:
10:30:00.900 R .Q,-000.056,-000.004,+000.038,M,+023.47,0 10:30:00.903 R 0,.0E 10:30:00.933 T ?Q 10:30:00.935 T ! 10:30:00.950 R .Q,-000.056,-000.002,+000.036,M,+023.49,0 10:30:00.953 R 0,.08 10:30:00.983 T ?Q 10:30:00.985 T ! 10:30:01.000 R .Q,-000.059,-000.001,+000.035,M,+023.46,0 10:30:01.003 R 0,.08 10:30:01.033 T ?Q 10:30:01.035 T ! 10:30:01.050 R .Q,-000.058,+000.004,+000.035,M,+023.51,0 10:30:01.053 R 0,.0C 10:30:01.083 T ?Q 10:30:01.085 T ! 10:30:01.100 R .Q,-000.058,+000.007,+000.035,M,+023.49,0 10:30:01.103 R 0,.06
I need Pipelinemode beacuse the whole program includes other measurements and operations, the tests above are done with only the code you see.
Try option 2 in the Delay() instruction.
I don't think you need the second SerialOutBlock(). There isn't a reason to tell the sensor to turn off polled mode.