LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

If (port[MSR] and $10)=$10 Then Inc(value);

Hello

Can someone please explain to me what this Pascal line does and if
possible how I could implement it in LabVIEW using the in port and out
port VIs.

the rest of the code is here...

Program serial_adc;

Uses Crt;

Const
combase=$2f8; { I/O address of the COM port you are using }
MCR=combase+4;
LCR=combase+3;
MSR=combase+6;

Procedure Initialize_converter;
Begin
Port[MCR]:=3; { make DTR line to supply power and set CS input
of chip to 1 }
Port[LCR]:=0; { set clock line of the chip to 0 }
End;

Function Read_value:byte;
Var
value:byte;
count:byte;
Begin
value:=0;
Port[MCR]:=1; { set CS down }
For count:=0 to 7 Do Begin { do the bit value eading 7 ti
mes
}
value:=value SHL 1; { value=2*value }
Port[LCR]:=64; { clock line up }
If (port[MSR] and $10)=$10 Then Inc(value); { read the input
data and update value }
Port[LCR]:=0; { clock line down }
End;
Port[MCR]:=3; { set CS up again }
Read_value:=value; { return the value }
End;

Begin
Initialize_converter; { call initialization routine }
Repeat
Writeln(Read_value); { call reading routine and print
the value }
Until KeyPressed; { repeat until any key is pressed
}
End.

I just want to know what part that specific line plays in reading of
the COM port. I mean if someone coul explain in an algorith kinda way
the whole 'for loop' I would really appreciate it. I have posted this
question before and even emailed ni but seems like no one has been
able to do it so far, is it impossible to rewrite that particular
Pa
scal code in LabVIEW? if so what are the alternatives?

Thanks.

Bupe
0 Kudos
Message 1 of 2
(2,472 Views)
'and' is being used as a bitwise operator, not Boolean. So we are
testing for the single bit at value 16 (0x10). LabVIEW also works the
same way with the AND primitive et al. when you use integers as
arguments.

You should be able to use the Port I/O VIs to do port reading/writing.
0 Kudos
Message 2 of 2
(2,472 Views)