Mótar Servo#

Réamhrá#

Úsáidtear an rang servo servo chun Mótar Servo 3-Sreang V5 a rialú agus a chumrú. Soláthraíonn an Mótar Servo 3-Sreang V5 rialú bunaithe ar shuíomh laistigh de raon gluaiseachta socraithe.

An Mótar Servo 3-Sreang VEX

Tógálaithe Ranga#

servo( triport::port& port );

Scriostóir Ranga#

Scriosann sé an réad servo agus scaoileann sé acmhainní gaolmhara.

~servo();

Paraiméadair#

Paraiméadar

Cineál

Cur síos

port

triport::port&

An Port 3-Sreang a bhfuil an Mótar Servo ceangailte leis, scríofa mar Brain.ThreeWirePort.X nó ExpanderName.X, áit a seasann X do litir an phoirt (mar shampla, Brain.ThreeWirePort.A nó Expander1.A).

Nótaí#

  • Ní mór Brain nó Leathnaitheoir 3-Sreang a chruthú ar dtús sula bhféadfar iad a úsáid chun réad a chruthú leis an tógálaí ranga servo.

Sampla#

// Create the servo instance on 3-Wire Port A
servo myServo = servo(Brain.ThreeWirePort.A);

Feidhmeanna na mBall#

Áirítear leis an rang servo na feidhmeanna ball seo a leanas:

  • setPosition — Bogann sé an mótar servo go suíomh sonraithe.

Sula nglaotar ar aon fheidhmeanna servo , ní mór sampla servo a chruthú, mar a thaispeántar thíos:

/* This constructor is required when using VS Code.
Servo configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create the servo instance on 3-Wire Port A
servo myServo = servo(Brain.ThreeWirePort.A);

setPosition#

Bogann sé an mótar servo go suíomh sonraithe.

Léaráid de mhótar servo a thaispeánann na céimeanna is féidir leis a rothlú, ó 100 ar chlé go 50 sa lár, go 0 ar dheis.

Available Functions

1 — Socraíonn sé suíomh an servo ag baint úsáide as luach céatadáin.

void setPosition(
 int32_t value,
 percentUnits units );

2 — Socraíonn sé suíomh an servo ag baint úsáide as aonaid rothlaithe.

void setPosition(
 double value,
 rotationUnits units );

Parameters

Paraiméadar

Cineál

Cur síos

value

int32_t

Luach suíomh an servo agus aonaid chéatadáin in úsáid.

value

double

Luach suíomh an servo agus aonaid rothlaithe á n-úsáid.

units

percentUnits

An t-aonad suímh: percent / pct — faoin gcéad

units

rotationUnits

An t-aonad suímh:

  • deg / degrees — céimeanna
  • turns / rev — réabhlóidí

Return Values

Ní thugann an fheidhm seo luach ar ais.

Notes
  • Agus aonaid chéatadáin in úsáid, is é an raon bailí ná 0 – 100%.

  • Tosaíonn servo gach tionscadal trína lárú go huathoibríoch ag 50 céim sula gcríochnaíonn sé aon ghluaiseachtaí.

  • Agus aonaid rothlaithe á n-úsáid, bogfaidh an servo go dtí an suíomh absalóideach atá sonraithe.

Examples
// Set the servo position to 10 percent
myServo.setPosition(10, percent);

// Set the servo position to 45.5 degrees
myServo.setPosition(45.5, degrees);

// Set the servo position to 90 degrees
myServo.setPosition(90, degrees);