|
-
Aug 28th, 2007, 02:28 AM
#1
Thread Starter
New Member
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!
-
Aug 28th, 2007, 05:57 AM
#2
Re: Help: How to control DC Motor using VB Expres 2005
-
Aug 28th, 2007, 11:34 AM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 28th, 2007, 08:09 PM
#4
Member
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.
-
Aug 29th, 2007, 03:46 AM
#5
Thread Starter
New Member
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.
-
Aug 29th, 2007, 03:47 AM
#6
Thread Starter
New Member
Re: Help: How to control DC Motor using VB Expres 2005
Btw, im using parallel port.
-
Aug 29th, 2007, 12:04 PM
#7
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 30th, 2007, 11:18 AM
#8
Thread Starter
New Member
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.
-
Aug 30th, 2007, 11:21 AM
#9
Re: Help: How to control DC Motor using VB Expres 2005
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
-
Aug 30th, 2007, 11:24 AM
#10
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 30th, 2007, 12:03 PM
#11
Thread Starter
New Member
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
-
Aug 30th, 2007, 12:05 PM
#12
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Aug 30th, 2007, 12:19 PM
#13
Thread Starter
New Member
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
-
Aug 30th, 2007, 12:38 PM
#14
Thread Starter
New Member
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.
-
Aug 30th, 2007, 02:17 PM
#15
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.
-
Aug 30th, 2007, 02:49 PM
#16
Thread Starter
New Member
Re: Help: How to control DC Motor using VB Expres 2005
tanx Andy_P i'll try to work on it.
-
Aug 31st, 2007, 12:52 AM
#17
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|