Preface
Direct I/O is a simply way to get connected with external world for PC programmers, and Lazarus, a cross platform free development suite, is now possible to assit programmers in achievement of such simple I/O operations for DI, DO, ADC and DAC, without any painstaking extras in DRIVER creation.
Functions Spec.
Put 2 Edits namely Edit1 and Edit2, and put a Timer, LazSerial, and 2 Buttons namely Button1 and Button2.
1. Realtime show the states of COMPORT serial RS232 pins 1, 6, 8 and pin9 in Edit1
Edit1.Text := LazSerial1.GetCarrier.ToString + LazSerial1.GetDSR.ToString + LazSerial1.GetCTS.ToString + LazSerial1.GetRing.ToString;
2. Change pin4 and pin7 state of COMPORT serial RS232 as per value in Edit2.txt
val(Edit2.Text, iEdit1Value, iTEdit1Value);
if iEdit1Value >0 then
begin
LazSerial1.SetDTR(True);
LazSerial1.SetRTS(True);
end
else
begin
LazSerial1.SetDTR(false);
LazSerial1.SetRTS(false);
end
In this way, simplely 4 channel input and 2 channel output can be done with RS232 serial port.
Steps in General
1. When Form_Load, open LazSerial port, no matter 2400 or 9600 etc.
2. When Form_CloseQuery, Close LazSerial port, which is just before application terminates.
3. Use Get_Carrier, Get_DSR, Get_CTS, Get_Ring readin pins of 1,6,8,9
4. Use Set_DTR and Set_RTS to set pins 4 and 7
A simple driverless, multi-channel ADC and DIO functional testing board with a USB-B connector for running on Win10x64 and Win10x32 etc.
Question 1: How to expand 2 Digital out of pin4 and pin7 to more channels
Answer: Use PCF8574 I2C serial_in parallel_out IC chip to expand to 8 Digital out channel.
Question 2: How to expand more then 8 channels
Answer: Use PCF8574 I2C serial_in parallel_out IC to control more PCF8574 ICs
Question 3: How to acquire Analog signals
Answer: TI 4545 is a serial 16bit 200KSPS ADC chip, which can be simplely controled with Direct serial I/O
Question 4: How to implement DAC function
Answer: Use serial DAC chips
With Direct I/O capability provided by Lazarus LazSerial component, and with aid of expansion chips and serial ADC and DAC chips, driverless data acuisition can be simplely achieved, moreover, it is also simple to control solenoid or solidstate relays via transistor or driver chips.