Class: Phidgets::MotorControl::MotorControlMotors
- Inherits:
-
Object
- Object
- Phidgets::MotorControl::MotorControlMotors
- Defined in:
- lib/phidgets-ffi/motor_control.rb
Overview
This class represents a motor for a PhidgetMotorControl. All the properties of a motor are stored and modified in this class.
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetMotorControl
Instance Method Summary collapse
-
#acceleration ⇒ Float
Returns the acceleration of a motor, or raises an error.
-
#acceleration=(new_acceleration) ⇒ Float
Sets the acceleration of a motor, or raises an error.
-
#acceleration_max ⇒ Float
Returns the largest acceleration value that the motor will accept, or raises an error.
-
#acceleration_min ⇒ Float
Returns the smallest acceleration value that the motor will accept, or raises an error.
-
#back_emf ⇒ Float
Returns the back EMF value of a motor, in volts, or raises an error.
-
#back_emf_sensing ⇒ Boolean
Returns the back EMF sensing state of a motor, or raises an error.
-
#back_emf_sensing=(new_back_emf_sensing) ⇒ Boolean
Sets the back EMF sensing state of a motor, or raises an error.
-
#braking ⇒ Float
Returns the braking value of a motor, or raises an error.
-
#braking=(new_braking) ⇒ Float
Sets the braking value of a motor, or raises an error.
-
#current ⇒ Float
Returns the current consumption of a motor, in Amps, or raises an error.
-
#index ⇒ Integer
Returns the index of the motor, or raises an error.
-
#inspect ⇒ Object
Displays data for the motor.
-
#velocity ⇒ Float
Returns the velocity of a motor, or raises an error.
-
#velocity=(new_velocity) ⇒ Float
Sets the velocity of a motor, or raises an error.
Instance Method Details
#acceleration ⇒ Float
Returns the acceleration of a motor, or raises an error.
232 233 234 235 236 |
# File 'lib/phidgets-ffi/motor_control.rb', line 232 def acceleration ptr = ::FFI::MemoryPointer.new(:double) Klass.getAcceleration(@handle, @index, ptr) ptr.get_double(0) end |
#acceleration=(new_acceleration) ⇒ Float
Sets the acceleration of a motor, or raises an error.
241 242 243 244 |
# File 'lib/phidgets-ffi/motor_control.rb', line 241 def acceleration=(new_acceleration) Klass.setAcceleration(@handle, @index, new_acceleration.to_f) new_acceleration end |
#acceleration_max ⇒ Float
Returns the largest acceleration value that the motor will accept, or raises an error.
247 248 249 250 251 |
# File 'lib/phidgets-ffi/motor_control.rb', line 247 def acceleration_max ptr = ::FFI::MemoryPointer.new(:double) Klass.getAccelerationMax(@handle, @index, ptr) ptr.get_double(0) end |
#acceleration_min ⇒ Float
Returns the smallest acceleration value that the motor will accept, or raises an error.
254 255 256 257 258 |
# File 'lib/phidgets-ffi/motor_control.rb', line 254 def acceleration_min ptr = ::FFI::MemoryPointer.new(:double) Klass.getAccelerationMin(@handle, @index, ptr) ptr.get_double(0) end |
#back_emf ⇒ Float
Returns the back EMF value of a motor, in volts, or raises an error.
284 285 286 287 288 |
# File 'lib/phidgets-ffi/motor_control.rb', line 284 def back_emf ptr = ::FFI::MemoryPointer.new(:double) Klass.getBackEMF(@handle, @index, ptr) ptr.get_double(0) end |
#back_emf_sensing ⇒ Boolean
Returns the back EMF sensing state of a motor, or raises an error.
277 278 279 280 281 |
# File 'lib/phidgets-ffi/motor_control.rb', line 277 def back_emf_sensing ptr = ::FFI::MemoryPointer.new(:int) Klass.getBackEMFSensingState(@handle, @index, ptr) (ptr.get_int(0) == 0) ? false : true end |
#back_emf_sensing=(new_back_emf_sensing) ⇒ Boolean
Sets the back EMF sensing state of a motor, or raises an error.
270 271 272 273 274 |
# File 'lib/phidgets-ffi/motor_control.rb', line 270 def back_emf_sensing=(new_back_emf_sensing) tmp = new_back_emf_sensing ? 1 : 0 Klass.setBackEMFSensingState(@handle, @index, tmp) new_back_emf_sensing end |
#braking ⇒ Float
Returns the braking value of a motor, or raises an error.
306 307 308 309 310 |
# File 'lib/phidgets-ffi/motor_control.rb', line 306 def braking ptr = ::FFI::MemoryPointer.new(:double) Klass.getBraking(@handle, @index, ptr) ptr.get_double(0) end |
#braking=(new_braking) ⇒ Float
Sets the braking value of a motor, or raises an error. The value can be between 0-100%
315 316 317 318 |
# File 'lib/phidgets-ffi/motor_control.rb', line 315 def braking=(new_braking) Klass.setBraking(@handle, @index, new_braking.to_f) new_braking end |
#current ⇒ Float
Returns the current consumption of a motor, in Amps, or raises an error.
261 262 263 264 265 |
# File 'lib/phidgets-ffi/motor_control.rb', line 261 def current ptr = ::FFI::MemoryPointer.new(:double) Klass.getCurrent(@handle, @index, ptr) ptr.get_double(0) end |
#index ⇒ Integer
Returns the index of the motor, or raises an error.
227 228 229 |
# File 'lib/phidgets-ffi/motor_control.rb', line 227 def index @index end |
#inspect ⇒ Object
Displays data for the motor.
222 223 224 |
# File 'lib/phidgets-ffi/motor_control.rb', line 222 def inspect "#<#{self.class} @index=#{index}, @acceleration=#{acceleration}, @acceleration_min=#{acceleration_min}, @acceleration_max=#{acceleration_max}, @velocity=#{velocity}>" end |
#velocity ⇒ Float
Returns the velocity of a motor, or raises an error.
291 292 293 294 295 |
# File 'lib/phidgets-ffi/motor_control.rb', line 291 def velocity ptr = ::FFI::MemoryPointer.new(:double) Klass.getVelocity(@handle, @index, ptr) ptr.get_double(0) end |
#velocity=(new_velocity) ⇒ Float
Sets the velocity of a motor, or raises an error.
300 301 302 303 |
# File 'lib/phidgets-ffi/motor_control.rb', line 300 def velocity=(new_velocity) Klass.setVelocity(@handle, @index, new_velocity.to_f) new_velocity end |