1 / 15

Robotics and Mechatronics

Robotics and Mechatronics. Motor Encoder Usage. nMotorEncoder. What does nMotorEncoder do? What are the steps to using nMotorEncoder?. Using nMotorEncoderTarget. 1. Reset Encoders. nMotorEncoder [motorB] = 0;. 2. Specify Target. nMotorEncoderTarget [motorB] = 720;.

Download Presentation

Robotics and Mechatronics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Robotics and Mechatronics Motor Encoder Usage

  2. nMotorEncoder • What does nMotorEncoder do? • What are the steps to using nMotorEncoder?

  3. Using nMotorEncoderTarget 1. Reset Encoders nMotorEncoder[motorB]= 0; 2. Specify Target nMotorEncoderTarget[motorB] = 720; 3. Turn Motors on Forward motor[motorB] = 50; 4. Watch the motor run state. while(nMotorRunState[motorB] != runStateIdle) { }

  4. nMotorRunState nMotorRunState – Watches the Motor’s “state” (is it on or off?) nMotorRunState[motorD] = runStateRunning; nMotorRunState[motorD] = runStateHoldPosition; nMotorRunState[motorD] = runStateIdle; "nMotorRunState“ is a special function that allows us to watch the state of the motor so that we know when it is running, when it is slowing down and when it is stopped. while(nMotorRunState[motorB] != runStateIdle){}

  5. Idle loop while(nMotorRunState[motorB] != runStateIdle){} What is an idle loop?

  6. nMotorTargetEncoder

  7. Variables

  8. Variables

  9. Variables

  10. Variable Types

  11. Variable Names

  12. Variable Rules

  13. Variable Examples

  14. Lets Use a Variable in a Program How many encoder counts does a motor moving at • Quarter power in two seconds count? • Half power in two seconds count? • Three quarter power in two seconds count? • Full power in two seconds count? • Is there a proportional relationship? • Declare the following variables: • encodercount; • motorpower = 50; • motortime = 2000; Hints: In order to continually increment encodercount you will need to place it in a loop. You will need to use a timer. While Make sure that your debugger is set to continuous. You will need to add time at the end of the program to be able to see the value of encodercount… So what will that mean to your motors. (next slide)

  15. Pseudocode for variable problem • Declare variables • Assign value to variables • Zero out the encoders • Reset the timer • Place condition in a loop • While timer < motortime • Don’t forget to increment encodercount inside the loop!

More Related