Electronics control parallel port in vb

Discussion in 'Modding' started by c.cam108, 31 May 2004.

  1. c.cam108

    c.cam108 Minimodder

    Joined:
    14 Feb 2004
    Posts:
    907
    Likes Received:
    3
    i dont know if this is the correct forum for this, but i need to be able to control motors from a comp parallel port and have it all controlled by vb.

    does anyone know how to do this?

    i need to be able to control 2 motors, each forward and backward

    thanks for your help
     
  2. XDude

    XDude What's a Dremel?

    Joined:
    11 Nov 2003
    Posts:
    21
    Likes Received:
    0
  3. Smilodon

    Smilodon The Antagonist

    Joined:
    25 Mar 2003
    Posts:
    6,244
    Likes Received:
    102
    this is pretty simple... you could use 2 relays... one for each motor, or a "H bridge"... (i think it's called that... basicly 4 transistors)

    just write a number to the port for each direction... and use the lines dirctly to controll the relays...
     
  4. c.cam108

    c.cam108 Minimodder

    Joined:
    14 Feb 2004
    Posts:
    907
    Likes Received:
    3
    thanks for the replies

    @ xdude

    i dont want to actually write data to the port, just turn the lines on and off

    @ smilodon

    what is an H-bridge?

    it sounds intriuging
     
  5. BjD

    BjD What's a Dremel?

    Joined:
    10 Apr 2003
    Posts:
    935
    Likes Received:
    0
    This is the simplest circuit i could find quickly :D You wouldnt have to use MOSFETS, but the general layout of it is the same. A few more here if you scroll down.

    Basically you use a pair of NPN and PNP transistors to connect each end of the motor to either +12 or ground. You could drive each transistor from the parallel port directly, better would be to use some discreet logic so you use just the 2 lines ie one line 'on' for clockwise, other 'on' for anti clockwise, and motor off if theyre both the same. One thing to watch is that both transistors on the same 'side' of the motor arent turned on at the same time, otherwise you short the +12 to ground through both transistors, which they wont like.

    Sorry if thats a bit rushed but its been one of those days...:D
     
  6. c.cam108

    c.cam108 Minimodder

    Joined:
    14 Feb 2004
    Posts:
    907
    Likes Received:
    3
    those circuits are perfect, thank you! :rock:

    now i just need someone to tell me the code in vb that says "data line 1 on parallel port 1 on" :D
     
  7. BjD

    BjD What's a Dremel?

    Joined:
    10 Apr 2003
    Posts:
    935
    Likes Received:
    0
    Ohohoh forgot to add to my other post, but im sure i have some example code for that around here somehwere :D You need a 3rd party driver under 2k/XP because they dont like random programs using the parallel port.

    /me searches hard drive.....

    EDIT: found the names, search for DLPortIO or WinIO in google, both have the replacemnt drivers and VB source :thumb:
     
  8. Evilbob

    Evilbob What's a Dremel?

    Joined:
    28 Apr 2001
    Posts:
    550
    Likes Received:
    0
    This is the same thing as writing data to the lines... on the parallel port u have 8 output lines and to turn them on or off u write an eight bit number to the parrallel port which is the sum of all the bits you want on from at least what i learnt in my electronics class.
     
  9. c.cam108

    c.cam108 Minimodder

    Joined:
    14 Feb 2004
    Posts:
    907
    Likes Received:
    3
    so what youre saying is that the lines will stay on untill i send a different set of 8 bits?
     
  10. Evilbob

    Evilbob What's a Dremel?

    Joined:
    28 Apr 2001
    Posts:
    550
    Likes Received:
    0
    Yeah they stay at whatever you set them at untill you or some other program changes them
     
  11. Hazer

    Hazer In time,you too will be relixalated

    Joined:
    14 Apr 2003
    Posts:
    957
    Likes Received:
    2
    Another tip for utrning on/off individual lines:

    Say you already have lines 2 and 3 on, the rest off. The 8 bit data on the PPort would then be b'00000110'. Now you want to turn on line 7. If you dont want to constantly remember which lines are on or off, simply OR b'01000000' to your current output. The result will be b'01000110'.

    And now you want to turn off line 3. Simply AND b'11111011' to the current output and it will turn off line 3.
     
  12. c.cam108

    c.cam108 Minimodder

    Joined:
    14 Feb 2004
    Posts:
    907
    Likes Received:
    3
    what do you mean, simply OR b'01000000'

    and why the b in front of the nums, is it because its binary?

    sorry for all the n00b questions!
     
  13. Hazer

    Hazer In time,you too will be relixalated

    Joined:
    14 Apr 2003
    Posts:
    957
    Likes Received:
    2
    OR and AND are Boolean terms. I would imagine that some who knows Basic or C++ would know how to use them.

    The b'XXXXXXXX' is how to represent binary numbers.
     
  14. c.cam108

    c.cam108 Minimodder

    Joined:
    14 Feb 2004
    Posts:
    907
    Likes Received:
    3
    i know what OR and AND are!

    i just wondered how that would work, or are the lines flipflopped? eg when you write 00000001 then 00000001 again, line 1 would go on and back off again?
     
  15. BjD

    BjD What's a Dremel?

    Joined:
    10 Apr 2003
    Posts:
    935
    Likes Received:
    0
    No. I think he means that you read the current output first (if you can do that?) or keep track of the current output in a variable.
     
  16. c.cam108

    c.cam108 Minimodder

    Joined:
    14 Feb 2004
    Posts:
    907
    Likes Received:
    3
    well, it doesnt matter anyway, i will only need one line on at a time anyway!
     

Share This Page