Sign in to follow this  
Followers 0
JustinMeyer

AutoIT & Phidgets, Robotics with AutoIT (How To)

1 post in this topic

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  
Followers 0

  • Similar Content

    • Earthshine
      By Earthshine
      This is pretty useful to me at least, I hope to others. Whenever you need to poke a button or such on a GUI, you can just make calls to this UDF and instruct it how long to wait, 0 is forever, anyway, let the code to the explaining. Feel free to help expand this UDF. I plan to create new ones as I go along that support all the Win32 and .NET Controls. Ultimately, I would like to be able to fully control any type of control, this works well with most. Just an example of what you can do.
       
      The test installs and can uninstall 7-Zip 15.14 (x64) Setup.exe
      NOTE: Logger Author(s) .....: Michael Mims (zorphnog)
      ;                    the logging script can be obtained here
      ;                   https://www.autoitscript.com/forum/topic/156196-log4a-a-logging-udf/
       
       
      install_7zip_test.au3
      WaitForControls.au3
    • sree161
      By sree161
      Hi,
      i have a code which generates two numeric outputs.i have to save them in excel.
      Is there any way to export them to specific cells in excel???
    • TotalAuto
      By TotalAuto
      Howdy All
      I've gone around and around in circles wasting hours trying to fix this problem to no avail so I thought I would try posting for help given there are some real smart people in this forum.
      Background
      I have 5 separate .au3 scripts that all do different basic tasks. For example:
      1.au3 = opens Chrome browser to obtain information from a specific website then closes
      2.au3 = opens an Excel workbook to run a macro then saves and closes
      3.au3 = Open two seperate workbooks and transfers data from one to the other then saves and closes
      4.au3 = .......etc
      5.au3 = .......etc
      These 5 separate scripts, doing completely different tasks, need to each run once per day at 5 different designated times within a day and then close. For example:
      1.au3 = 10am
      2.au3 = 12pm
      3.au3 = 2pm
      4.au3 = 4pm
      5.au3 = 5pm
      Problem
      I can not get these different scripts to reliably run at their designated times. When I manually run these scripts individually by using 'Go F5' they work perfectly. If I convert these scripts to an .exe and manually run each one they work about 98% of time.
      How can I schedule these different .au3 files or associated .exe files to reliably run each day at different times?
      Attempts To Fix The Issue
      1. I have tried converting each .au3 script into their own .exe file and use Window's Task Scheduler to run these .exe files at their designated time but the success rate  of running each .exe in full, to completion, without error is very low at about 30%. Things that commonly go wrong include a browser not opening but movement still continues on the desk top. Other times things just do not happen at all.
      2. I have Windows 7 64 bit and have tried creating and running both (x86) and (x64) .exe files but again reliability problems exist;
      3. I have also tried moving each .exe file to the My Documents folder as I read someone that keeping your files on your desktop ties your files to individual Windows user profiles which can cause AutoIt operating errors. Not sure if this is correct but thought I would try it anyway. It did not fix my issue.
      4. I installed a program called AlwaysUp which supposedly always reliably runs in the background and will reliably execute your AutoIt script or .exe files. Still have significant reliability issues.
      Therefore, can someone please provide advice on how I can get my 5 different .au3 files to run at 5 designated times through the day, every day, without fail? Overtime I will be creating more and more different .au3 files to run certain tasks throughout the day and do not want to create one large AutoIt file that continually runs and attempts to do all the different tasks itself.
      Any help is very appreciated.
      Thanks
      Dan
       
       
    • hugomito
      By hugomito
      Hi all,
      I built an AutoIt application that interacts with several other applications/software. Now, it's turn to interfact with Visual Studio Team Services (VSTS).
      Does anyone has a blog, demo, script to share?
      Thanks!
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning everyone
      I worked a bit on a little project of mine, and I managed to do what I was trying to do, or, automate a quiz in AutoIt.
      Now, everything works fine but, in order to achieve what I'm trying to achive, I'd like to make this script run faster.
      I'll attach a portion of the code in order to let you understand what my script does.
      $objIE_h1 = _IETagNameGetCollection($objIE, "h1") ; Take the text of the answer If @error Then ConsoleWrite("Errore durante la lettura degli h1 nella pagina. - Errore: " & @error & @CRLF) Else For $objElement In $objIE_h1 $strInnerText = $objElement.innerText Next Select Case StringInStr($strInnerText, "QUESTION") ; Here is the question ; PS4 PRO $objSpans = _IETagNameGetCollection($objIE, "span") ; Answers are stored here For $objElement In $objSpans If $i >= 4 Then $strAnswer = $objElement.innerText ; Take the text of the answer n° 0, 1, 2, 3 If StringInStr($strAnswer, "CORRECT ANSWER") Then ; If I match the correct answer, then, I have to click on the input with answer id = answer_i $j = $i - 4 $objInput = _IEGetObjById($objIE, "answer_" & $j) If @error Then ConsoleWrite("Errore durante la lettura della risposta #" & $i & " - Errore: " & @error & @CRLF) Else _IEAction($objInput, "click") If @error Then ConsoleWrite("Errore durante il click sull'elemento. - Errore: " & @error) Else ConsoleWrite($j & ") Risposta: " & $strAnswer & @CRLF) ExitLoop EndIf EndIf EndIf $i+=1 Else $i+=1 EndIf Next $i = 0 $j = 0 This is what my script does.
      Questions are 20, in which I have 15 multiple choice question, 2 images ( on which I use _IEImgClick() ), and 3 text inputs ( a simple send with the text I have to enter ).
      How can I make all of these, faster?
      If I reach this goal, I've probably done one of my best goals in life, and I'd like to share my happiness with you, giving a huge donation to this fantastic community!
      Thanks for your help