Jump to content
Sign in to follow this  
JustinMeyer

AutoIT & Phidgets, Robotics with AutoIT (How To)

Recommended Posts

JustinMeyer

I am planning on building a "How To - AutoIT & Phidgets" and am looking for direction on how to document it.

Phidgets are "Products for USB Sensing and Control" that can be utilized with AutoIT. They allow physical

interface, functions and events / input and output through COM in the case of AutoIT. Check out the

Phidgets page for more information, and go to Trossen Robotics if you are going to buy (Cheaper and Faster).

The image is a link to the video right after I was able to get

AutoIT and the 1063 Bipolar stepper controllers talking. I

am building a 3-Axis CNC mill.

Posted Image

I Know AutoIT and Phidgets are not the ideal way to go when

building a mill... its a learning experience.

Quick piece together of code used in video above.

#include <GUIConstantsEx.au3>
 
GUICreate("PhidgetStepper Control Test",500,400)$Add_2C_B = GUICtrlCreateButton("Add to Current Position (+10000 1/16)", 5, 5, 490, 30)
$Sub_FC_B = GUICtrlCreateButton("Subtract from Current Position (-10000 1/16)", 5, 40, 490, 30)
$Output_E = GUICtrlCreateEdit("", 5, 335, 490, 60)GUISetState(@SW_SHOW)
;create the phidget object
$oPhidget = ObjCreate("phidget21COM.PhidgetStepper");open the Phidget system
$oPhidget.Open(130664)
$oPhidget.WaitForAttachment(3000)
If NOT $oPhidget.IsAttached Then
MsgBox(0, "Error", "Phidget Device not attached")
Exit
EndIf
;register Phidget events
$oPhidEvents = ObjEvent($oPhidget, "phid1_");Power Stepper Motor, index motor 0
$oPhidget.Engaged(0) = 1
;set Stepper control values
$oPhidget.CurrentLimit(0) = 00.70
$oPhidget.VelocityLimit(0) = 7000.00
$oPhidget.Acceleration(0) = 18100.00;set the current position
$oPhidget.CurrentPosition(0) = 0
;read current position to variable
$Current_P = $oPhidget.CurrentPosition(0)GUICtrlSetData($Output_E, $Current_P)
While 1
$msg = GUIGetMsg()Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0,"Application Alert", "Application Closing")
ExitLoopCase $msg = $Add_2C_B
$Current_P = $oPhidget.CurrentPosition(0)
$oPhidget.TargetPosition(0) = $Current_P +10000
GUICtrlSetData($Output_E, $Current_P)
Case $msg = $Sub_FC_B
$Current_P = $oPhidget.CurrentPosition(0)
$oPhidget.TargetPosition(0) = $Current_P -10000
GUICtrlSetData($Output_E, $Current_P)
EndSelect
WEnd;power off stepper at index 0
$oPhidget.Engaged(0) = 0
;close
$oPhidget.Close();Phidget Event Handlers
Func phid1_OnDetach($Index, $IRValue)
MsgBox(0,"Error", "Phidget detached")
Exit
EndFunc

Sorry its one blob, it keeps coming out like that.

So where should I start a thread or threads, examples or questions, as it will be both and more.

I have a few different Phidgets and will be progressing the capabilities and limitations with the

help of the forum.


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • simonc8
      By simonc8
      I have a script which executes sleep for a couple of hours then carries out instructions. Does the running AutoIt script prevent the computer from entering sleep mode during this time? If not, is there something I can add to the AutoIt script to keep the computer awake?
      Grateful for advice.
    • gahhon
      By gahhon
      Hi,
      I have a program that is read data from the .txt file, since the .txt file is only readable, viewable and editable for the admin user.
      But how could I lock it with password, or some other technique that can helps to achieve this?
      Thanks for the advanced information.
    • gahhon
      By gahhon
      Hi,
      How can I the trigger the another button functions without waiting the previous function to finish execute?
      Any advise?
      I couldn't find any relevant topics via google.
      Thanks a lot.
    • SharpDressedMan
      By SharpDressedMan
      Hi all,
      I need to use ControlMove() on some controls of a hidden GUI window.
      This works properly on a GUI window created with default style, but does not work on a GUI window created with style $WS_OVERLAPPEDWINDOW
      func GUItest($bOverlapped) $m = GUICreate("test", 200, 100, -1, -1, $bOverlapped ? $WS_OVERLAPPEDWINDOW : -1) $g = GUICtrlCreateButton("test", 0, 0) ControlMove($m, "", $g, 30, 30) GUISetState() endfunc GuiTest(false) ; button 'test' properly moved to (30,30) GuiTest(true) ; button 'test' not moved and still sitting at (0,0) Any reason for this unexpected behavior ?
      Any workaround to fix this ?
      Thanks for any help
    • 2Toes
      By 2Toes
      Hi all..
      I'm having slight issue that has be a bit puzzled.
      I have an Input control.. After a certain function runs, it Disables that Input control, and sets it to ReadOnly.
      When running another certain function, it re-Enables that Input control, and sets the style back to Default.
      Which does work, however, when typing into the Input control after re-Enabling it, the text appears as a light gray color, rather than its original black color.
      I'm sure there's a simple solution here.. But what that is, appears to be beyond me.
      Here is a simplified example code:
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 245, 215, 192, 124) Global $disableBTN = GUICtrlCreateButton("Disable", 32, 64, 75, 25) Global $enableBTN = GUICtrlCreateButton("Enable", 128, 64, 75, 25) Global $Input1 = GUICtrlCreateInput("", 32, 120, 169, 21) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $disableBTN disable() Case $enableBTN enable() EndSwitch WEnd Func disable() GUICtrlSetState($Input1, $GUI_DISABLE) GUICtrlSetStyle($Input1, $ES_READONLY) EndFunc Func enable() GUICtrlSetState($Input1, $GUI_ENABLE) GUICtrlSetStyle($Input1, $GUI_SS_DEFAULT_INPUT) EndFunc  
      Any help would be greatly appreciated
      Thank you in advance!
×