Stepper Full code - multiple motors

Supporting Visual Studio on Windows
kayaker
Phidgetly
Posts: 35
Joined: Thu Jan 03, 2013 3:58 pm
Contact:

Stepper Full code - multiple motors

Postby kayaker » Mon Jan 28, 2013 10:29 am

Can someone provide me some guidance on how I go about modifying the "Stepper - Full" code to accommodate a second motor simultaneously. Right now, just to do the same thing as the first. Obviously I will have to duplicate the form objects, but I've tried to tried to set up for 2 motors, but only get one going.

Here is how I started:
.................................................
Public Class frmMain
'
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
' Set STEPPER constants
Public Const myLinearControllerSerialR = 270000 'serial number of controller board 1
Public Const myLinearControllerSerialL = 270001 'serial number of controller board 2

' Add the stepper object to the project
Dim WithEvents stepperR As Phidgets.Stepper
Dim WithEvents stepperL As Phidgets.Stepper


Private Sub frmMain_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed

'Close stepper
stepperR.close()
stepperL.close()

' Destroy the object we created in the Open
stepperR = Nothing
stepperL = Nothing

End Sub

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' Declare a NEW Phidgets stepper object
stepperR = New Phidgets.Stepper
stepperL = New Phidgets.Stepper

' Attach the stepper with serial number ... #270000 <<< my number motor 1


' Generic open available stepper controller
stepperR.open(myLinearControllerSerialR)
stepperL.open(myLinearControllerSerialL)

End Sub
..........................................................................................

Then I changed all the "stepper." to "stepperR." for the first motor. Obviously it failed, and at this point I don't see the need to post the messages as I need help with how to do it "philosophically" and what I am doing wrong right out of the gate "philosophically".

Hope I'm not asking for way too much guidance here. I don't even see the stepper info in the top of the "Stepper - Full" form when I "start debugging"

I'm really hurting on this one and just looking how to get started.
Take Care,

Jim. . .

fraser
Engineering
Posts: 268
Joined: Thu Nov 19, 2009 4:41 pm
Contact:

Re: Stepper Full code - multiple motors

Postby fraser » Tue Jan 29, 2013 10:02 am

Rather than trying to copy the form object across and modify it for a second motor, i would suggest you try to build from the ground up. This way you will better understand each portion of your code and what it is doing; this is the best philosophical approach to the problem. Creating new code is typically easier than modifying existing code


Return to “VB .NET”

Who is online

Users browsing this forum: No registered users and 3 guests