The Applescript examples aren't working for me

Supporting 10.7 and up
dgdg
Phidgetsian
Posts: 10
Joined: Wed Apr 09, 2014 5:44 pm
Contact:

The Applescript examples aren't working for me

Postby dgdg » Wed Apr 09, 2014 5:58 pm

I just installed my new Phidgets 1061 model servo. I'm using Mac OS X 10.9.2 on a Macbook Air. I installed the Phidgets software. I have given the Phidgets board 12V of power. I connected a single servo to it (my WRB order is correct). I connected it to my Mac. The Phidgets icon appears in my System Preferences. When I double click on it I can see the device. When I double click on the device name I get a window that lets me control the servo. All this works fine. 100%. Now I'm trying to run the Phidgets Applescript examples. Since I have a servo I'm trying the servo examples. All I get is an error, specifically, here are the events I get. Notice the "get attached" command always fails...

Code: Select all

tell application "PhidgetsOSA"
   get library version
      --> "Phidget21 - Version 2.1.8 - Built Mar 19 2014 14:11:19"
end tell
tell current application
   path to current application
      --> alias "Macintosh HD:Users:home:Downloads:AppleScript:PhidgetServo.scpt"
end tell
tell application "PhidgetsOSA"
   exists phidget servo 1
      --> true
   get phidget servo 1
      --> phidget id "PHID-3849-13"
   get attached of phidget id "PHID-3849-13"
      --> false
   (*Couldn't attach to PhidgetServo*)
   display dialog "Couldn't attach to PhidgetServo"
      --> {button returned:"OK"}
end tell
Result:
{button returned:"OK"}


I have no other apps accessing the Phidgets device at this point. I even closed the dialog box that showed up when I opened the device in the system preferences. I would greatly appreciate assistance. I build robots with servos and I already have well over 20,000 lines of code written (not in Applescript yet, I'm waiting to see if I can get Phidgets to work before I convert my code) - I just need to get this interesting new device to work.

User avatar
mparadis
Site Admin
Posts: 653
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: The Applescript examples aren't working for me

Postby mparadis » Thu Apr 10, 2014 7:34 am

When using the 1061, you must use "PhidgetAdvancedServo.scpt", which uses a different software object than "PhidgetServo.scpt". The latter is for our older, discontinued servo controller.

dgdg
Phidgetsian
Posts: 10
Joined: Wed Apr 09, 2014 5:44 pm
Contact:

Re: The Applescript examples aren't working for me

Postby dgdg » Sun Apr 13, 2014 2:40 pm

mparadis wrote:When using the 1061, you must use "PhidgetAdvancedServo.scpt", which uses a different software object than "PhidgetServo.scpt". The latter is for our older, discontinued servo controller.

Well that's *slightly* better (life is complicated). Now the script at least loads and starts the motor rotating. But the rotation doesn't at all match the commands that are issued. I may have figured out why. I have two models of servos "DGServo S04NF STD" and "S08NF STD". While one of these appears to be the correct type of servo (i.e., not continual rotation), the specs seem to indicate it wants 5v. But the Phidgets board says it requires 9 to 30 volts DC. So does this mean my servos are incompatible with this board? I've tried searching the web for servos that require 9-30v. All I can find are servos that require 5-6v. How am I supposed to use this Phidgets board if there are no servos for sale that support 9-30v? I apologize in advance for my lack of understanding.

User avatar
mparadis
Site Admin
Posts: 653
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: The Applescript examples aren't working for me

Postby mparadis » Mon Apr 14, 2014 7:47 am

While the PhidgetAdvancedServo board requires a supply voltage of 6-15V, its output voltage is 5V. (I'm not sure where you're seeing the 9-30V specification, though). This is because the servo controller must provide power to several 5V servos at once.

dgdg
Phidgetsian
Posts: 10
Joined: Wed Apr 09, 2014 5:44 pm
Contact:

Re: The Applescript examples aren't working for me

Postby dgdg » Mon Apr 14, 2014 6:54 pm

Ok, thanks for the advice. but if I'm doing everything right, why doesn't it work? The sample servo program probably should turn the servo as follows: (this is the Applescript event output)

(*Moving the position to 40*)
set position of advanced servo motor 1 of phidget id "PHID-3518-1" to 40
(*Moving the position to 50*)
set position of advanced servo motor 1 of phidget id "PHID-3518-1" to 50
(*Moving the position to 100*)
set position of advanced servo motor 1 of phidget id "PHID-3518-1" to 100
(*Moving the position to 200*)
set position of advanced servo motor 1 of phidget id "PHID-3518-1" to 200
(*Moving the position to 70*)
set position of advanced servo motor 1 of phidget id "PHID-3518-1" to 70
get stopped of advanced servo motor 1 of phidget id "PHID-3518-1"


When it reaches the first line, the servo rams itself in the counterclockwise position. Then when the program ends, indeed well AFTER it ends, the servo turns back into the middle position. Why would the servo move at all after the program ends? And why would the servo not move to various positions as indicated by this example program? What exactly is this example supposed to do? It doesn't do what the code suggests to me.

User avatar
mparadis
Site Admin
Posts: 653
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: The Applescript examples aren't working for me

Postby mparadis » Tue Apr 15, 2014 7:51 am

When you use a third party servo, you need to calibrate it; the controller has no way of knowing the maximum and minimum allowable pulse width of the servo unless you tell it. You can view the calibration guide here. Since you're using OS X, you'll use the Phidget Preference Pane instead of the Phidget Control Panel, but the process should be the same.

dgdg
Phidgetsian
Posts: 10
Joined: Wed Apr 09, 2014 5:44 pm
Contact:

Re: The Applescript examples aren't working for me

Postby dgdg » Wed Apr 16, 2014 11:11 am

Oh. That seems logical. I'll try it when I get home and post my results. Thanks. I really look forward to getting this nice, small, language-friendly Phidgets device to work for me. I have big plans for it.

dgdg
Phidgetsian
Posts: 10
Joined: Wed Apr 09, 2014 5:44 pm
Contact:

Re: The Applescript examples aren't working for me

Postby dgdg » Sun Apr 20, 2014 12:21 am

mparadis wrote:When you use a third party servo, you need to calibrate it; the controller has no way of knowing the maximum and minimum allowable pulse width of the servo unless you tell it. You can view the calibration guide here. Since you're using OS X, you'll use the Phidget Preference Pane instead of the Phidget Control Panel, but the process should be the same.


Those instructions are for Windows. I'm on a Mac. The dialog box I get on a Mac when I double click on "Phidgets Advanced Servo Controller 8-motor" is completely different with nothing equivalent to the Windows dialog box. All I get is the name, serial number and version number of the device, plus a bunch of bars and buttons that let me move my servos. I am still completely unable to get this product to work. Sorry to be negative. I appreciate your attempts to help.

User avatar
mparadis
Site Admin
Posts: 653
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: The Applescript examples aren't working for me

Postby mparadis » Mon Apr 21, 2014 9:59 am

I just checked the preference pane example and you're right, there is no text box that displays the value of the position. If your servo came with a datasheet, they may list the four parameters you need. If not, they can be determined experimentally. We only recommend the control panel example for convenience. What I'm about to describe is essentially the same thing, just with your own program.

Open up your program and set the servo to RAW_us_MODE. Then set the position to a low value. If the servo reaches its lower limit, set it to a higher value. If not, keep going lower. After trying a few positions you should be able to get the lower limit value. Then repeat this process for the higher value. Once you have the minimum and maximum values, you can measure the range of motion as described in the calibration guide. The maximum velocity parameter is usually on the servo's data sheet, but even if you can't find it, this parameter isn't as important as the others. Just keep increasing it until the servo doesn't seem to move any faster.

Sorry for the inconvenience of all of this. Luckily, calibration is just a one-time thing, so once you've figured out your parameters you can hard-code them into your program.

dgdg
Phidgetsian
Posts: 10
Joined: Wed Apr 09, 2014 5:44 pm
Contact:

Re: The Applescript examples aren't working for me

Postby dgdg » Mon Apr 21, 2014 11:49 am

You are a kind person. Thanks. What you may not know is that I've never written a program for a Phidgets device before, so when you say "open your program" I have to look for an example program first. The only example in the Phidgets library that I have to work with is PhidgetAdvancedServo.scpt. That's the only "program" I have. I've been studying that program for hours. The program seems to do exactly what you are asking me to do! The program says, for example, "set the first advanced servo motor's position to 40", then 50, etc., which means it is trying to set the position to a variety of values. So essentially this program does exactly what you are asking me to do. What is it that you want me to do differently from the example program?


Return to “macOS”

Who is online

Users browsing this forum: No registered users and 1 guest