Manual

www.nexusrobot.com Robot Kits manual
47
unsigned int getSpeedMMPS() const
Get the speed (millimeter per second)
This will lie within the range specified at MotorWheel::getspeedCMPM().
See: MotorWheel::getspeedCMPM()
unsigned int setSpeedMMPS(unsigned int mm,bool dir)
Set the speed .
This will lie within the range specified at MotorWheel::setspeedCMPM() and
MotorWheel::getspeedCMPM().
See:
MotorWheel::setspeedCMPM()
MotorWheel::getspeedCMPM()
For example:
#include <PinChangeInt.h>
#include <PinChangeIntConfig.h>
#include <PID_Beta6.h>
#include <MotorWheel.h>
#ifndef MICROS_PER_SEC
#define MICROS_PER_SEC 1000000
#endif
irqISR(irq1,isr1); //This will create a MotorWheel object called Wheel1
MotorWheel wheel1(9,8,6,7,&irq1); // Motor PWM:Pin9, DIR:Pin8, Encoder A:Pin6, B:Pin7
void setup() {
TCCR1B=TCCR1B&0xf8|0x01; // Pin9,Pin10 PWM 31250Hz, Silent PWM
wheel1.setSpeedMMPS(100,DIR_ADVANCE); //Set the pwm speed 100 direction
wheel1.PIDEnable(KC,TAUI,TAUD,10); // used whewl1 to call the PIDEnable
Serial.begin(19200);
}
void loop() {
wheel1.PIDRegulate(); //regulate the PID
if(millis()%500==0) {
Serial.print("speedRPM> ");