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: 

serial port 8 bit adc program

I have some Pascal code writen for an 8bit Serial ADC circuit. I had a look at the Pascal code and I made an attemp at implementing it in labVIEW but obviously it didnt work. 

The Pascal code writes/reads to the DTR, RTS and CTS lines which I was able to do with little success, I used the property node and chose 'DTR/RTS State' which gave me the options to write to the lines i mentioned above. But I am not able to read the CTS output. how can I do that in LabVIEW because LABVIEW VISA follows the RS232 protocol . I tried using the IN/Out port vi But it does not work for windows Vista & later .Can anyone help by telling me where to start from? Below is the Pascal code. I have attached my current vi which does not work.

the circuit diagram for the 8bit adc can be found here... 
http://www.epanorama.net/circuits/ad_serial.html

Pascal Code........

Program serial_adc;

Uses Crt;

Const
combase=$3f8; { 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 times }
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 }
Delay(1200);
Until KeyPressed; { repeat until any key is pressed }
End.

Download All
0 Kudos
Message 1 of 2
(2,018 Views)

It has been too many decades since I used Pascal to be sure what your code does.

 

It seems that you are asserting DSR to provide power through the port to the external device and that you have that working.

 

Are you using RTS/CTS as standard handshaking? If so, just select RTS/CTS as the value for the Flow Control input on the VISA Configure Serial Port.vi.  Then there is no need to deal with those line explicitly in the LV code.

 

Note on your code: The 1 ms Wait in the sequence frame with the RTS Asserted may run before or after the property node. If you need the delay before asserting RTS, put the Wait in a frame which runs before the property node.

 

If you are using USB to RS-232 adapters, verify whether the DTR line stays asserted. I have seen some adapters which think they are smarter than you are and turn off the control lines after a short idle time.

 

Lynn

0 Kudos
Message 2 of 2
(1,994 Views)