Control the Activity Board Arlo with Serial Messages

Control the Activity Board Arlo with Serial Messages

This example uses serial messages to demonstrate how your program can issue the same commands from Control Arlo with the SimpleIDE Terminal with the help of the arlodrive library’s dhb10_com function, this call allows your program to pass a text string to the Arlo’s DHB-10 motor controller, and returns the address of a string that contains the DHB-10’s reply.  Remember, for a full list of serial commands you can use, check the DHB-10 Motor Controller Firmware Guide.

  • Put the Arlo up on a stand so it’s wheels can’t make it move.
  • Set power like this: MAIN (on), MOTORS (on), Activity Board (position-2)
  • Load Serial through arlodrive into the Propeller using SimpleIDE’s Run with Terminal button.
  • Watch the serial message exchanges as the Arlo does its maneuver and reports its distance traveled.
/*
  Arlo - Serial through arlodrive.c
*/

#include "simpletools.h"                      // Include simple tools
#include "arlodrive.h"

char *reply;

int main()                                    // Main function
{
  print("SPEED & DISTANCE\n\n");
  print("To DHB-10         From DHB-10\n");
  print("-------------     ----------------\n");

  print("RST\\r             ");
  reply = dhb10_com("RST\r");
  if(*reply == '\r') print("\\r\n");
  else print("%s", reply);

  print("gospd 32 32\\r     ");
  reply = dhb10_com("gospd 32 32\r");
  if(*reply == '\r') print("\\r\n");
  else print("%s", reply);

  pause(2000);

  print("gospd 0 0\\r       ");
  reply = dhb10_com("gospd 0 0\r");
  if(*reply == '\r') print("\\r\n");
  else print("%s", reply);

  // Display distance reply as text
  print("dist\\r            ");
  reply = dhb10_com("dist\r");
  if(*reply == '\r') print("\\r\n");
  else print("%s", reply);

  print("-------------     ----------------\n");

  // Convert distance reply text to numeric values to use in
  // calculations, and display the results stored by int variables.
  int countLeft, countRight;
  print("\nVARIABLE VALUES\n", reply);
  sscan(reply, "%d%d", &countLeft, &countRight);
  print("countLeft = %d, countright = %d\n", countLeft, countRight);
}