update servo from GC (User Feature)

1 view
Skip to first unread message

Flora Salim

unread,
Jun 17, 2010, 3:26:40 AM6/17/10
to ubi...@googlegroups.com, SG PPI
FYI - feature to update servo from GC.

---------- Forwarded message ----------
From: Flora Salim
Date: Thu, Jun 17, 2010 at 4:22 PM
Subject: update servo
To: Stig Nielsen 


I have attached the dll that you can use directly in GC as well as the sample dgn file and the arduino file for two servo motors.

You need to first load the assembly, such as follows:

transaction script 'Add assemblies'
{
    AddAssemblySearchDirectory("D:\\flo\\MyC#\\UbiMash_v3.0\\src\\UpdateServo\\bin\\Release");       --> PLEASE CHANGE THIS TO THE LOCATION OF THE DLL IN YOUR COMPUTER AND DON'T FORGET THE \\ DOUBLE SLASH
    LoadAssembly("UpdateServo.dll");
}

Then add graph variables:

transaction graphChange 'Add graphVars servos'
{
    feature User.Objects.servo1angle Bentley.GC.Features.GraphVariable
    {
        Value                     = 45;
        LimitValueToRange         = true;
        RangeMaximum              = 180;
    }
    feature User.Objects.servo2angle Bentley.GC.Features.GraphVariable
    {
        Value                     = 10;
        LimitValueToRange         = true;
        RangeMaximum              = 180;
    }
}


Then add the feature UpdateServo:

transaction graphChange 'Add updateServo01'
{
    feature User.Objects.updateServo01 Bentley.GC.Features.UpdateServo
    {
        cs                        = baseCS;
        PortName                  = "COM18";   --> THE VALUE OF YOUR SERIAL PORT NAME CONNECTED TO ARDUINO
        servoAngle                = servo1angle; --> NAME OF THE GRAPH VARIABLE
        servoNo                   = 1; --> STARTS FROM 1, THE SEQUENCE NUMBERING OF YOUR SERVO
    }
}

transaction graphChange 'Add updateServo02'
{
    feature User.Objects.updateServo02 Bentley.GC.Features.UpdateServo
    {
        cs                        = baseCS;
        PortName                  = "COM18";
        servoAngle                = servo2angle;
        servoNo                   = 2;
    }
}

Modify the graph variables and see the reactions of the servo

transaction graphChange 'Change servo1angle'
{
    feature User.Objects.servo1angle Bentley.GC.Features.GraphVariable
    {
        Value                     = 169;
    }
}

transaction graphChange 'Change servo2angle'
{
    feature User.Objects.servo2angle Bentley.GC.Features.GraphVariable
    {
        Value                     = 130;
    }
}

The arduino pde is attached. And you can modify it as required. Note that I use pin no 9 for servo no 1, pin 10 for servo 2, and so on. And you need to change the variables of the number of servo. This is defined in the .pde

#define ROBOT_COUNT  2
#define FIRST_ROBOT_PIN 9

Hope it's useful. Let me know how it goes.

Cheers,
Flora

UpdateServo.dll
updateServos.pde
testUpdateServos_Name.dgn

Przemek Jaworski

unread,
Jun 17, 2010, 5:17:17 AM6/17/10
to ubi...@googlegroups.com, SG PPI
wow, fantastic, thanks! I'll try to give it a go this weekend... I am
building robotic arm for drawing curvilinear geometry, I hope this can work
smoothly with 3 servos instead of two.
cheers!
Przemek

On Thu, 17 Jun 2010 17:26:40 +1000, Flora Salim <flora...@gmail.com>
wrote:


> FYI - feature to update servo from GC.
>
> ---------- Forwarded message ----------
> From: FLORA SALIM
> Date: Thu, Jun 17, 2010 at 4:22 PM
> Subject: update servo
> To: Stig Nielsen 
>
> I have attached the dll that you can use directly in GC as well as the
> sample dgn file and the arduino file for two servo motors.

> YOU NEED TO FIRST LOAD THE ASSEMBLY, SUCH AS FOLLOWS:

> transaction script 'Add assemblies'{  
>
 AddAssemblySearchDirectory("D:\flo\MyC#\UbiMash_v3.0\src\UpdateServo\bin\Release");
>       --> PLEASE CHANGE THIS TO THE LOCATION OF THE DLL IN YOUR
> COMPUTER AND DON'T FORGET THE \ DOUBLE SLASH   
>  LoadAssembly("UpdateServo.dll");}
> Then add graph variables:
> transaction graphChange 'Add graphVars servos'{    feature
> User.Objects.servo1angle Bentley.GC.Features.GraphVariable     {  
>      Value                     = 45;      
>  LimitValueToRange         = true;        RangeMaximum      
>        = 180;    }    feature User.Objects.servo2angle
> Bentley.GC.Features.GraphVariable     {        Value        
>             = 10;        LimitValueToRange         =
> true;        RangeMaximum              = 180;    }}
>

> THEN ADD THE FEATURE UPDATESERVO:


> transaction graphChange 'Add updateServo01'{    feature
> User.Objects.updateServo01 Bentley.GC.Features.UpdateServo     {  
>      cs                        = baseCS;      
>  PortName                  = "COM18";   --> THE VALUE OF YOUR
> SERIAL PORT NAME CONNECTED TO ARDUINO        servoAngle        
>        = servo1angle; --> NAME OF THE GRAPH VARIABLE       
>  servoNo                   = 1; --> STARTS FROM 1, THE SEQUENCE
> NUMBERING OF YOUR SERVO    }}
> transaction graphChange 'Add updateServo02'{     feature
> User.Objects.updateServo02 Bentley.GC.Features.UpdateServo    {    
>    cs                        = baseCS;        PortName
>                  = "COM18";         servoAngle        
>        = servo2angle;        servoNo                  
> = 2;    }}

> MODIFY THE GRAPH VARIABLES AND SEE THE REACTIONS OF THE SERVO

> transaction graphChange 'Change servo1angle'{    feature
> User.Objects.servo1angle Bentley.GC.Features.GraphVariable    {    
>    Value                     = 169;     }}
> transaction graphChange 'Change servo2angle'{    feature
> User.Objects.servo2angle Bentley.GC.Features.GraphVariable    {   
>      Value                     = 130;     }}

> THE ARDUINO PDE IS ATTACHED. AND YOU CAN MODIFY IT AS REQUIRED. NOTE
THAT
> I USE PIN NO 9 FOR SERVO NO 1, PIN 10 FOR SERVO 2, AND SO ON. AND YOU
> NEED TO CHANGE THE VARIABLES OF THE NUMBER OF SERVO. THIS IS DEFINED IN
> THE .PDE
> #define ROBOT_COUNT  2#define FIRST_ROBOT_PIN 9

Hugo Mulder

unread,
Jun 17, 2010, 11:53:32 AM6/17/10
to sg-ppi-...@googlegroups.com, ubi...@googlegroups.com
if you're using the cheap servo's I alway s use, you might want to give them a bit of slack, instead of driving them to 0 or 180, use 2 and 178 as the boundaries...

2010/6/17 Przemek Jaworski <ja...@jawordesign.com>

Flora Salim

unread,
Jun 18, 2010, 1:10:45 AM6/18/10
to ubi...@googlegroups.com, sg-ppi-...@googlegroups.com
You can easily change it to 3 servos by modifying the COUNT variable in the arduino pde.

Flora
Reply all
Reply to author
Forward
0 new messages