LB Booster
« Using modem control outputs to drive a relay »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:31am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Using modem control outputs to drive a relay  (Read 61 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Using modem control outputs to drive a relay
« Thread started on: Dec 15th, 2017, 3:54pm »

In response to a query at the LB Yahoo! group, here's a simple program to demonstrate driving the DTR and RTS Modem Control outputs from a standard serial port (internal or USB serial adaptor). On a DB9 connector DTR is on pin 4 and RTS is on pin 7. The code as shown is LBB-specific:

Code:
    ' change COM port number to suit
    open "com3:9600,n,8,1" for random as #com
    hcom = hwnd(#com)
    button #w, " Set DTR ", [setdtr], UL, 20, 20
    button #w, "Clear DTR", [clrdtr], UL, 20, 60
    button #w, " Set RTS ", [setrts], UL, 20, 100
    button #w, "Clear RTS", [clrrts], UL, 20, 140
    open "Modem Control test" for window as #w
    #w "trapclose [quit]"
    wait
    
[setdtr]
    calldll #kernel32, "EscapeCommFunction", hcom as ulong, _SETDTR as long, r as void
    wait

[clrdtr]
    calldll #kernel32, "EscapeCommFunction", hcom as ulong, _CLRDTR as long, r as void
    wait

[setrts]
    calldll #kernel32, "EscapeCommFunction", hcom as ulong, _SETRTS as long, r as void
    wait

[clrrts]
    calldll #kernel32, "EscapeCommFunction", hcom as ulong, _CLRRTS as long, r as void
    wait

[quit]
    close #com
    close #w
    end 

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls