Jump to content

Code for two stepper bricks does not work. Can anybody help?


Harry88

Recommended Posts

Following is a VB code for 2 stepper bricklets.  The hardware works with the example shown on the Tinkerforge homepage.  Can anybody tell me why this my code does not work and what I have to change? The 3 error messages from Visual Basic are shown at the end of the code.

 

The code is for a two axis measuring tool to move the table.

 

Thank you!

 

Best,

Harry

 

Code for Reed Measuring Device

OUTLINE

​Module MeasureReed

Reset device position​

WaitForStart() 

For x = 35 to 71 by 1

  ​For y = -9 to 9 by 1

​​MoveDeviceTo(x,y)

​    ​MeasureReed()

        ​Output measurement

​Next y

​​Move Excel cursor back up and to right

Next x

​End Module

 

Visual Basic Code

Imports System

Imports Tinkerforge

 

Module MeasureAltoReed

  Const HOST As String = "localhost"

  Const PORT As Integer = 4223

  Const UIDx As String = "5W5E6E"    ' Change XXYYZZ to the UID of your x direction Stepper Brick

  Const UIDy As String = "67PGPm "    ' Change XXYYZZ to the UID of your y direction Stepper Brick

 

  Sub Main()

      Dim ipconx As New IPConnection()                        ' Create IP connection for x

​ Dim ipcony As New IPConnection()                        ' Create IP connection for y

      Dim stepperx As New BrickStepper(UIDx, ipconx)  ' Create device object for x direction stepper

      Dim steppery As New BrickStepper(UIDy, ipcony)  ' Create device object for y direction stepper

 

      ipcon.Connect(HOST, PORT) ' Connect to brickd Don't use device before ipcon is connected

 

      stepperx.SetSpeedRamping(30000, 30000)    '    Set stepper x values

      stepperx.SetMexVelocity(5000)

      stepperx.StepDecay(50000)

      stepperx.Enable()                                              '  Enable x motor power

      stepperx.SetStepMode(4)

 

      steppery.SetSpeedRamping(30000, 30000)    '    Set stepper y values

      steppery.SetMexVelocity(5000)

      steppery.StepDecay(50000)

      steppery.Enable()                                              '  Enable y motor power

      steppery.SetStepMode(4)

 

      Console.WriteLine("Press key to start")

      Console.ReadLine()

 

      Dim currentxpos As Integer = 0

      Dim currentypos As Integer = 82

      Dim distancexaway As Integer

      Dim distanceyaway As Integer

 

​ distancexaway = -9 – currentxpos      ​‘ Move to (-9,35) from start (0,82)

stepperx.SetSteps(distancexaway*800)    ‘ 800 steps = 1 mm

currentxpos = currentxpos + distancexaway

 

distanceyaway = 35 – currentypos

steppery.SetSteps(distanceyaway*800)

​ currentypos = currentypos + distanceyaway

 

      For x As Integer = -9 To 9

          distancexaway = x - currentxpos

          stepperx.SetSteps(distancexaway*800)

    currentxpos = currentxpos + distancexaway

 

          For y As Integer = 35 To 73

              distanceyaway = y - currentypos

          ​  steppery.SetSteps(distanceyaway*800)

        currentypos = currentypos + distanceyaway

 

              Console.WriteLine("Current position ( x , y ) (" + x.ToString() + ", " + y.ToString() + ")")

 

              ' Get reed measurement and output

          Next y

      Next x

 

      stepperx.Disable()

      steppery.Disable()

      ipcon.Disconnect()

  End Sub

End Module

 

 

Severity

 

Code

 

Description

 

Project

 

File

 

Line

 

Suppression State

 

Error

 

BC30002

 

Type 'IPConnection' is not defined.

 

MeasuringTollCorr.4

 

c:\users\boss\documents\visual studio 2015\Projects\MeasuringTollCorr.4\MeasuringTollCorr.4\Module1.vb

 

13

 

Active

 

Error

 

BC30002

 

Type 'BrickStepper' is not defined.

 

MeasuringTollCorr.4

 

c:\users\boss\documents\visual studio 2015\Projects\MeasuringTollCorr.4\MeasuringTollCorr.4\Module1.vb

 

14

 

Active

 

Error

 

BC30002

 

Type 'BrickStepper' is not defined.

 

MeasuringTollCorr.4

 

c:\users\boss\documents\visual studio 2015\Projects\MeasuringTollCorr.4\MeasuringTollCorr.4\Module1.vb

 

15

 

Active

 

 

ReplyQuoteNotify

 

Link zu diesem Kommentar
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gast
Reply to this topic...

×   Du hast formatierten Text eingefügt.   Formatierung jetzt entfernen

  Only 75 emoji are allowed.

×   Dein Link wurde automatisch eingebettet.   Einbetten rückgängig machen und als Link darstellen

×   Dein vorheriger Inhalt wurde wiederhergestellt.   Clear editor

×   Du kannst Bilder nicht direkt einfügen. Lade Bilder hoch oder lade sie von einer URL.

×
×
  • Neu erstellen...