Tuesday, September 11, 2012

Pan & Tilt preview

The head can pan and tilt, this movement is ensured by two servos.



In this image you can see the study plans of preliminary mechanical parts.
The final draft envisages the creation of a single sheet of acrylic co parts made of laser cut and related joints.

Monday, September 10, 2012

The Modbus library

The head source uses a lib for modbus slave protocol.

The source is here:
https://sites.google.com/site/jpmzometa/Home

Using the new IDE 1.0.1 there are two error:

1) in file ModbusSlave.h the line
#include "WProgram.h" 
must change with
#include "Arduino.h"

2) in file ModbusSlave.cpp the line 250
Serial.print(query[i], BYTE);
must change with
Serial.write(query[i]);

see you soon...



Friday, September 7, 2012

A tail?

Many people say to me "a cat without a tail is not a cat"...

Mmmm a very big problem... :)

Thursday, September 6, 2012

The head - firmware beta release

This is the beta version of the firmware insde the Head-Arduino

[code]
 /*
P.R.U. Personal Robotic Unit
A robot with cat's personality
------------------------------
Head firmware:
Head Pan & tilt
2 ears servo rotating
2 eyes 4 led

*/
#include <Servo.h>
#include <ModbusSlave.h>

/* First step MBS: create an instance */
ModbusSlave mbs;
Servo EarLeft;
Servo EarRight;
Servo Pan;
Servo Tilt;

/* slave registers */
enum {      
        MB_PAN,    
        MB_TILT,
        MB_R_EYE,
        MB_L_EYE,
        MB_R_EAR,
        MB_L_EAR,
        MB_REGS /* total number of registers on slave */
};

int regs[MB_REGS];
unsigned long wdog = 0;         /* watchdog */
unsigned long tprev = 0;         /* previous time*/

void set_eye(char eye, boolean l1, boolean l2, boolean l3, boolean l4);

void setup()
{
  /* the Modbus slave configuration parameters */
  const unsigned char SLAVE = 10;
  const long BAUD = 19200;
  const char PARITY = 'e';
  const char TXENPIN = 7;

  /* Second step MBS: configure */
  mbs.configure(SLAVE,BAUD,PARITY,TXENPIN);

  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(A4, OUTPUT);
  pinMode(A5, OUTPUT);

  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);

  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);

  Pan.attach(9);
  Tilt.attach(10);
  EarLeft.attach(A4);
  EarRight.attach(A5);
}

void loop()
{
  /* Third and las step MBS: update in loop*/
  if(mbs.update(regs, MB_REGS))
    wdog = millis();

  if ((millis() - wdog) > 5000)  {      /* no comms in 5 sec */
    // to do
  }      

  /* the values in regs are set by the modbus master */
  // Test Pan
  if(regs[MB_PAN] != Pan.read())
    Pan.write(regs[MB_PAN]);

  // Test Tilt
  if(regs[MB_TILT] != Tilt.read())
    Tilt.write(regs[MB_TILT]);

  // Test Ear Left
  if(regs[MB_L_EAR] != EarLeft.read())
    EarLeft.write(regs[MB_L_EAR]);

  // Test Ear Right
  if(regs[MB_R_EAR] != EarRight.read())
    EarRight.write(regs[MB_R_EAR]);
 
  // Test Left Eye
  switch(regs[MB_L_EYE]) {
    case 0: // Ronf
      set_eye(1, LOW, LOW, LOW, LOW);
      break;
    case 10: // Mmmmmaaaoooo
      set_eye(1, LOW, HIGH, HIGH, LOW);
      break;
    case 11: // Look R
      set_eye(1, LOW, HIGH, LOW, LOW);
      break;
    case 12: // Look R
      set_eye(1, LOW, LOW, HIGH, LOW);
      break;
    case 13: // Look Up
      set_eye(1, HIGH, LOW, LOW, LOW);
      break;
    case 14: // Looh D
      set_eye(1, LOW, LOW, LOW, HIGH);
      break;
    case 15: // OMG
      set_eye(1, HIGH, HIGH, HIGH, HIGH);
      break;
  }

  // Test Right Eye
  switch(regs[MB_R_EYE]) {
    case 0: // Ronf
      set_eye(0, LOW, LOW, LOW, LOW);
      break;
    case 10: // Mmmmmaaaoooo
      set_eye(0, LOW, HIGH, HIGH, LOW);
      break;
    case 11: // Look R
      set_eye(0, LOW, HIGH, LOW, LOW);
      break;
    case 12: // Look R
      set_eye(0, LOW, LOW, HIGH, LOW);
      break;
    case 13: // Look Up
      set_eye(0, HIGH, LOW, LOW, LOW);
      break;
    case 14: // Looh D
      set_eye(0, LOW, LOW, LOW, HIGH);
      break;
    case 15: // OMG
      set_eye(0, HIGH, HIGH, HIGH, HIGH);
      break;
  }
}

void set_eye(char eye, boolean l1, boolean l2, boolean l3, boolean l4)
{
  if (eye==0) {
      digitalWrite(A0, l1);
      digitalWrite(A1, l2);
      digitalWrite(A2, l3);
      digitalWrite(A3, l4);
  }
  if (eye==1) {
      digitalWrite(2, l1);
      digitalWrite(3, l2);
      digitalWrite(4, l3);
      digitalWrite(5, l4);
  }
}
[/code]

Wednesday, September 5, 2012

The head inside

The PRU's head is very complex.
The electronic hearth is a board arduino-like, the source code is open.
You can add new features and share with the community.






8 led for two eyes, may expressions, funny element.
A hypothesis protocol provides several commands to the various expressions like:
@EL1F# (Eye Left (led 1) (maximum brightness))

Another possibility is uil Modbus protocol and the various registers to control eyes


4 servos (2 for ears and 2 for pan & tilt)
Same hypothesis for the pan & tilt control protocol.

simple or modbus?




Big question... :)

Monday, September 3, 2012

The philosophy

PRU is an Open Source and Open Hardware project











Do you like it?

Saturday, September 1, 2012

C'mon to the locomotion

There are many methods of locomotion for a robot: legs, wheels and tracks.
PRU is a very simple robot, designed for home use, so I decided to use just two wheels and a ball caster.

The motor are simple gearmotor and the wheels have silicone tires and measure 60 mm (2.36") in diameter.