Results 1 to 17 of 17

Thread: Help: How to control DC Motor using VB Expres 2005

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Exclamation Help: How to control DC Motor using VB Expres 2005

    Hello,

    Im new to VB 2005 and I would like to know how to make the dc motor accelerate when I press the "a" key and decelerate when I press the "d" key and spacebar to make it to stop. Lets say for example I have 3 speed mode(1,2, and 3), if I press the "a" key twice it will go to number 3 speed and if I press the "d" key one, it will go to number 2 speed, pressing "d" again will go back to 1 speed and finally, pressing spacebar will stop the motor. Im using SCR as controller and pin 2-9 of the parallel port to interface with pc.

    Thanks in advance!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help: How to control DC Motor using VB Expres 2005

    Moved to VB.NET

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help: How to control DC Motor using VB Expres 2005

    Sounds like a school project. You should have built the circuit already to drive the motor. So it will be just writting keypress code to increment or decrement some output to the parallel port.
    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

  4. #4
    Member
    Join Date
    Jul 2007
    Location
    Silly Clone Valley CA
    Posts
    47

    Re: Help: How to control DC Motor using VB Expres 2005

    Well I personally would use the serial port just because it is easier to use and what you want to do doesn't require high data transmission speeds. But anyway...

    You need to figure out what commands to send to the controller chip. The VB part of this will be easy because once you define the commands you will just design up some simple controls. I would make an on-screen simulator first. Once that works correctly then you could just add the output.

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    Hi, I have another question. How can I create a counter using LDR as an input? I want my program to count the rpm(rev/min) of the dc motor. Is it possible to use a timer? could you give me any reference code. Thanks.

  6. #6

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    Btw, im using parallel port.

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help: How to control DC Motor using VB Expres 2005

    I dont think anyone is going to do your project assignment for you but if you post what code you have written Im sure we will be able to help guide you along your way.
    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

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    i am using this code below to control the speed of the dc motor when the key is being pressed.


    Code:
        Public Class Form1
    
        Private Sub Form1_KeyPress( ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me .KeyPress
    
        Select Case e.KeyChar
    
        Case "a"
    
        If CInt(labelspeed.Text) < 3 Then
    
        labelspeed.Text = CInt(labelspeed.Text) + 1
    
        End If
    
        Case "d"
    
        If CInt(labelspeed.Text) > 0 Then
    
        labelspeed.Text = CInt(labelspeed.Text) - 1
    
        End If
    
        End Select
    
        End Sub
    
        End Class


    now my problem is that, i don't know how my program will count the rpm of the dc motor using ldr. my classmate said that i should use a timer and use the inp(889) to receive a signal from ldr to my program. but i dont know how to generate a code using that timer. hope you can help me out on my project. thanks.
    Last edited by RobDog888; Aug 30th, 2007 at 11:22 AM.

  9. #9
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Help: How to control DC Motor using VB Expres 2005

    What is an LDR?
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help: How to control DC Motor using VB Expres 2005

    Depending on your DC motor, it may be impossible to get a rpm count, maybe some inaccurate numbers at best.
    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

  11. #11

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    light dependent resistor (LDR) as a sensor.
    can u give me a reference code even if it is counting inaccurately? thanks

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help: How to control DC Motor using VB Expres 2005

    No, as Im not the one in school. It wouldnt be fair to the other students. Plus, it may be dependant upon the motor and circuitry being used.
    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

  13. #13

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    im using ldr to sense the revolution of the motor per minute or per second, pls help im a beginner and still don't know how to program well.

    my program is not working


    dim x as integer
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Label1.Text = Inp(889)
    X = X + 1

    End Sub

    End Sub

  14. #14

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    to be more easier for us both, and not to be unfair for others like what you have said a while ago, lets make the code easier. lets say i have a button tool.
    by clicking the button how will i compute and display the no of times i clicked it per minute?
    Last edited by shounenbat; Aug 30th, 2007 at 12:50 PM.

  15. #15
    Fanatic Member Andy_P's Avatar
    Join Date
    May 2005
    Location
    Dunstable, England
    Posts
    669

    Re: Help: How to control DC Motor using VB Expres 2005

    There are a couple of ways you could work out RPM:

    1. Count pulses and test the count after a set period of time, eg. 1 second.
    2. Detect how much time passes between pulses.

    I would suggest that option number 1 will be easier.

    Take your input and increment a counter with each pulse you get.

    On each timer tick, read the counter value and multiply it by 60. This will give you RPM assuming a tick frequency of 1 second, and also assuming you have one pulse per revolution of your motor. After you have calculated a result for that tick, reset your counter variable.

    Really though, that's mostly just basic maths.

    How you read in the input from the sensor, I have no idea, but I assume you already know that, or it forms part of the study material for you project.

    As has been mentioned, I don't think anyone will write out a whole load of code for you, but that should give you a nudge in the right direction.
    Using Windows XP Home sp3
    Mucking around with C# 2008 Express
    while ( this.deadHorse ) { flog( ); }


  16. #16

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    tanx Andy_P i'll try to work on it.

  17. #17

    Thread Starter
    New Member
    Join Date
    Aug 2007
    Posts
    9

    Re: Help: How to control DC Motor using VB Expres 2005

    Public X As Integer
    Public y As Integer

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    Timer1.Interval = 1000

    X = (X + 1)

    Label1.Text = X ' this show the timer tick every sec

    label2.text=inp(889) 'signal coming from my ldr




    you have said that the count of my signal should be multiplied by 60, then should i declare an integer to show the rpm??

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