1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Development Serial Port + Buttons.

Discussion in 'Software' started by SweMOD, 18 Dec 2003.

  1. SweMOD

    SweMOD What's a Dremel?

    Joined:
    16 Nov 2003
    Posts:
    57
    Likes Received:
    0
    Hey all !!

    I've made a controlpad like one you can find schematics to on
    this page; http://diba.hotbox.ru/comctrl/index.html

    and I've tried that software on the page also...


    I would like to ask all of you who I know can help.
    Is there anyone who got programming code for use with these buttons...
    for VISUAL BASIC up to 6.0.

    I looked around at www.pscode.com and found some ****ty codes...
    But I guess you elit peeps here can help me right??

    I thought of something that takes a look on the serial port for shortout,
    it should be something like that when buttons are pressed right?
    (my bad english :p)

    well anyway, and it check for certain combinations and then make
    the correct action for each button...

    anyone who understand me??
    anyone who could help??

    please do :D
    thank you BT peeps!!
     
  2. djengiz

    djengiz Pointless.

    Joined:
    16 Aug 2002
    Posts:
    1,129
    Likes Received:
    0
    I have done some programming on serial ports. What do you want to know?
     
  3. SweMOD

    SweMOD What's a Dremel?

    Joined:
    16 Nov 2003
    Posts:
    57
    Likes Received:
    0
    I need a program or source that can read out the serial port
    to see if I press a button...

    I will connect 15 buttons like the scheme on this site;
    http://diba.hotbox.ru/comctrl/index.html

    and then it will do a different action for each button...
    if you understand?
     
  4. djengiz

    djengiz Pointless.

    Joined:
    16 Aug 2002
    Posts:
    1,129
    Likes Received:
    0
    You want it in VB?
     
  5. djengiz

    djengiz Pointless.

    Joined:
    16 Aug 2002
    Posts:
    1,129
    Likes Received:
    0
    Add the MSCOMM component to you project. Drag a timer and an MSCOMM component to you form. Add a command button and a textbox to your form.

    Change the caption of the command button to "Start"
    Set the enable property of the timer to enabled=false and set the interval to 1
    Set the multiline property of the text box to true and the scrollbar property to both

    Then add following code to your command button
    Code:
    Private Sub command1_Click()
      If command1.Caption = "Start" Then
        If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
        timer1.Enabled = True
        command1.Caption = "Stop"
      Else
        command1.Caption = "Start"
        timer1.Enabled = False
      End If
    End sub
    
    Add the following code to the timer
    Code:
    Private Sub Timer1_Timer()
      Dim s As String
      If MSComm1.PortOpen = False Then MSComm1.PortOpen = True
      s = MSComm1.Input
      text1.Text = text1.Text & s
    End Sub
    
    This code will display your cominput in a textbox. Just check the input messages and then update your code to incorporate the messages!
     
  6. SweMOD

    SweMOD What's a Dremel?

    Joined:
    16 Nov 2003
    Posts:
    57
    Likes Received:
    0
    oh damn... I love you mate :D
    and on Xmas also... I hope you have the greatest Christmas!! :)

    Merry Christmas and a Happy New Year to ya!! :) :rock:
     
  7. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    just had a looksie at the schematic on the link you gave
    [​IMG]
    Now without even checking the PIN numbers i can tell you thats using the rs-232 port, but its not sending the data in serial manner.

    Your using the status lines (its ok) for the data.
    This means the code above won't work, because the data isn't been sent as serial.

    What your doing, is when a button is pressed, setting the
    Data Set Ready
    Carrier Detect
    Clear to Send
    Ring Indicator
    pin high.

    As such the comm object won't ever think any data has been recived (or when u poll it manually?)

    This means that you can't use the MSComm1.DataRecived (or what ever vb wants too call it) event to tell when data has been recived. As such there is going to be a hudge CPU overhead, as you will have to poll the ports :(. Yukie...


    Anyway this yukie yukie yukie way, which i feal dirty typing.
    According to my MSDN these are 3 properties that will tell you if that respective input
    CTSHolding // pin 8
    CDHolding // pin 1
    DTRHolding // pin 6
    As for Ring Indicator, well, i don't know!, i can't find a RIHolding property on the MSDN for this object, if there isn't you can get it the grown up way from GetCommModemStatus.

    If no one can find out how u get the Ring Indicator property, thats what you will have to do.
     
  8. SweMOD

    SweMOD What's a Dremel?

    Joined:
    16 Nov 2003
    Posts:
    57
    Likes Received:
    0
    well...
    that is not the schematic that I use...
    it's the 15 button schematic I use...

    but I guess that one is like the same?
     
  9. acrimonious

    acrimonious Custom User Title:

    Joined:
    8 Nov 2002
    Posts:
    4,060
    Likes Received:
    3
    I wrote a guide for a mag on this a while back, didn't get round to writing my own software though. I did look into a lil' dll though that will be very helpful to you "port.dll", i'm sure you should be able to find it on the web somehwere along with info on how to use it.

    These are the lines you need...

    If CTS() = 1 Then 'whatever
    If DSR() = 1 Then 'whatever
    If DCD() = 1 Then 'whatever
    If RI() = 1 Then 'whatever
     
  10. SweMOD

    SweMOD What's a Dremel?

    Joined:
    16 Nov 2003
    Posts:
    57
    Likes Received:
    0
    thank you there!
    I'll look for the file and see if I can find it... :)
     
  11. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    tbh i can't see the need for a dll! it would be more effort registering the function call backs.

    The "propper" way of doing this, would be to create a new thread with an algo' like this:

    WaitForCommEvent (win32 api call, blocks until theres a comm event)
    GetCommModemStatus (&structure)
    now you just react.

    I was thinking of designing a system service for a rotary encoder, for which i would make the code available for.

    It realy is that simple
     
  12. SweMOD

    SweMOD What's a Dremel?

    Joined:
    16 Nov 2003
    Posts:
    57
    Likes Received:
    0
    ok...

    but did you understand what kind of control I had which I connect to the serial port??

    do you got any source for vb to use? :)
     
  13. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    If you just directly link the schematic u used it would speed things up :)
     
  14. SweMOD

    SweMOD What's a Dremel?

    Joined:
    16 Nov 2003
    Posts:
    57
    Likes Received:
    0
    ya it could... if I got the scematic ;)
    well... I can see what I can do...

    be back in a few hours I hope...
     
  15. no-return

    no-return What's a Dremel?

    Joined:
    19 May 2004
    Posts:
    2
    Likes Received:
    0
    Just to let you know the 15 button schematic is:

    [​IMG]

    Would this work with 'TheAnimus' code?

    Mike
     
  16. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    should do, u see how their using diodes to force binary on the control lines.

    they use the diodes because u don't want to allow the high voltage from one handshaking line to goto another.

    so each of the handshaking lines gets pulled to the Request To Send line.
     

Share This Page