Orangutan examples, Simple example – Pololu Simple User Manual
Page 91
Orangutan SVP fully assembled.
smcSerial.write(0xAA); // send baud-indicator byte
setMotorLimit(FORWARD_ACCELERATION, 4);
setMotorLimit(REVERSE_ACCELERATION, 10);
setMotorLimit(DECELERATION, 20);
// clear the safe-start violation and let the motor run
exitSafeStart();
}
void loop()
{
setMotorSpeed(3200); // full-speed forward
// signed variables must be cast to ints:
Serial.println((int)getVariable(TARGET_SPEED));
delay(1000);
setMotorSpeed(-3200); // full-speed reverse
Serial.println((int)getVariable(TARGET_SPEED));
delay(1000);
// write input voltage (in millivolts) to the serial monitor
Serial.print("VIN = ");
Serial.print(getVariable(INPUT_VOLTAGE));
Serial.println(" mV");
// if an error is stopping the motor, write the error status variable
// and try to re-enable the motor
if (digitalRead(errPin) == HIGH)
{
Serial.print("Error Status: 0x");
Serial.println(getVariable(ERROR_STATUS), HEX);
// once all other errors have been fixed,
// this lets the motors run again
exitSafeStart();
}
}
6.7.2. Orangutan Examples
The
feature user-programmable Atmel AVR microcontrollers
interfaced with additional hardware useful for controlling robots. They are
programmable in C or C++ and supported by the
, which makes it easy to use the integrated
hardware and AVR peripherals, such as the UART module. Unlike the
Arduino, the hardware serial lines are completely available on the
Orangutans, so software serial is not necessary when connecting to serial
devices like the Simple Motor Controller.
In the following example programs, we use the OrangutanSerial functions
from the Pololu AVR library to transmit bytes on pin PD1. In the advanced
example, we use the OrangutanSerial functions to receive bytes on pin PD0, and we use the OrangutanLCD functions
to report feedback obtained from the Simple Motor Controller. See the
for more information on these functions.
This code requires the Simple Motor Controller to have automatic baud rate detection enabled or to
have a fixed baud rate set to 115200 bps. It must also be in Binary serial mode with the CRC Mode
set to Disabled.
Simple Example
This example assumes the following connections exist between the Orangutan and the Simple Motor Controller:
• Orangutan pin PD0 to Simple Motor Controller TX
Pololu Simple Motor Controller User's Guide
© 2001–2014 Pololu Corporation
6. Using the Serial Interface
Page 91 of 101