Results 1 to 12 of 12

Thread: How can I use VB to interface with an electrical device?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2003
    Posts
    38

    How can I use VB to interface with an electrical device?

    Hello,
    I mean :
    How can i use programming using Visual Basic to interfece with external electrical devices.
    for example ( very smiple ) :
    i have a form in VB that has a button on it. and i also have a light bulb that has to be connected to my pc. after i click on the button i want the light bulb to turn on. is such programming and comunication possible. If so :
    How?
    What type of wire and port (on pc ) should i use to connect the pc and light bulb?
    Do i need batteries, or once the connection is made there will be electricty ?
    thank you very much.

  2. #2

    Thread Starter
    Member
    Join Date
    Apr 2003
    Posts
    38
    buzz

  3. #3
    Fanatic Member
    Join Date
    Feb 2003
    Location
    Los Angeles, CA
    Posts
    681
    first of all - dont connect visual basic directly to the 120V power socket, you may burn it and it will become unusable

    seriously now, everything starts with an electronic device that switches your light bulb on and off. that device will be connected somehow to your computer - say to a serial port, or usb, or something. as you may have figured, your computer doesnt have a light bulb port like your lamp has. check a radio shack store and tell them what you want to do, first you have to choose the device and then come back here.
    there are 2 reasons why i leave my work unfinished:
    (1) i'm getting old.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I suggest either the serial or parallel port. Like Radum said, go to
    raido shack and get the connector to either serial or parallel port.
    Then you are going to need to soder wires to the pin outs on your
    new connectors. To drive the light bulb you are going to need a
    switch and perhaps a driver circuit. The switch will be what your
    output from either the serial or parallel port will trip. Then the
    switch will complete the circuit to power the light bulb. You are
    going to wan to be very careful not to miswire the connections or
    short out your computer. so you will need to place inline fuse also.

    This is not a schol project is it?

    Also, while your at radio shack, ask them for a guide book that
    contains the pinout configurations for the various ports on a
    computer. They are usually pocket sized and not too expensive.

    Why use a light bulb? Why not connect some IC chips and create
    a useful circuit to control a stepper motor or something?
    Last edited by RobDog888; Apr 28th, 2003 at 08:08 PM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Lively Member
    Join Date
    Apr 2003
    Posts
    114
    Since you are a beginner you may want to start with the Basic Stamp, which can be bought at radio shack or check out http://www.parallax.com. You will have direct control over a micro-processor and it's alot of fun.

    It's not real hard to do but you should be careful.
    I can do all things with VB.

  6. #6
    Addicted Member
    Join Date
    Feb 2003
    Posts
    237
    the parallel port is probably the simplest way to go

    the following link has alot of docs for it

    http://www.lvr.com/parport.htm

    in vb you will have to use a 3rd party control,
    there are both freeware and commercial ones
    for win 95/98 try the inpout dll, for win2k the only
    one I could make work was ntport

    parallel ports give you 8bits of data you can send
    at a time and when they are in thier on state they
    are enough to power a LED without driver circuit

    make sure to read up on how to wire it before you
    try it though because you can burn out your parallel port
    if the circuit doesnt have enough resistance

    its advisable to buy a second parallel port on an expansion
    card so if something does go wack it does not hit the
    motherboard, (or buy an old 386 to play with)

    lots of docs on the net, read and experiment is the best way
    to learn
    Free Code, papers, tools, and more

    http://sandsprite.com

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    If you use the parallel port to drive leds then use a 1K resister soldered in series before each led.
    The resister is a brown, black, red, gold - 1K.
    Pin 1 = the Strobe (ground - out).
    Pin 2 - 9 are the 8 led pinouts.
    Pin 10 = acknoweldgement.
    Pin 11 = Busy indicator.
    Pin 12 = Paper end.
    Pin 13 = Select
    Pin 14 = Auto feed.
    Pin 15 = Error.
    Pin 16 = Init.
    Pin 17 = Sel Input.
    Pin 18 - 25 are ground return for 1 - 10 (you can solder them together).
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8
    Addicted Member
    Join Date
    Nov 2002
    Posts
    155
    Lvr, mentioned above is good, but it's also worth a dig around at Boondog

  9. #9
    Member
    Join Date
    Apr 2003
    Posts
    37
    If you insist on playing with line voltage, consider an opto-isolator to protect your computer too.

  10. #10
    Lively Member
    Join Date
    May 2000
    Posts
    74
    If you want to switch low-current sources you could connect directly to a relay-card. Theese cards are very easy to control with Visual basic. There is a number of supplyers and the cards has reasonable pricing. (Look for example at www.advantech.com)
    If you want to control more energy-consuming and high-current devices you must connect the relay-card to a unit (is contactor the english word for it?) that cand handle higher currents.
    Relaycards usually have 8 or more relays built in.
    If you want to measure or control analog inputs such as temperature sensors there is easy-to-use cards also for this.

    In more advanced control applications with a lot of in/outputs it is possible to connect and control with some kind of bus-system such as profibus or interbus. This is a little more tricky, but far from impossible.

    God luck

  11. #11
    Lively Member Bootking's Avatar
    Join Date
    Mar 2003
    Location
    Marquette University
    Posts
    90
    Definately use your printer port. I've seen some really cool things done with printer ports. When you interface a robot with a PC you usually have the robot run off of an independent power source and use PC input for switches. I've seen a doc somewhere about how to wire an N64 controller to a serial or printer port. It's cool stuff. Sorry I don't have any concrete information on the stuff.
    Check out my band's website!
    Walter Walker Band

  12. #12
    Addicted Member
    Join Date
    Feb 2003
    Posts
    237
    that boondog site is great

    thanks for the link
    Free Code, papers, tools, and more

    http://sandsprite.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width