RS232 Direct I/O under Win10x64 with Lazarus

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值