Saturday, September 22, 2012

The head - part 2

Hi guy!

Now you can see the PRU's head with eyes and ears...

All servo are mounted, now I need a neck...


Something like that.


Do you like it?

Wednesday, September 19, 2012

The head - prototype

Hey guy!
This is the first step of prototype for the PRU's head.
You can see the Pan & Tilt system and the led eyes.

Soon as possible a video!

Monday, September 17, 2012

Why only two wheels?


When this project was born, I immediately asked me what kind of traction.
A real cat would have four legs, but implement them properly, ensuring proper locomotion, would require a very careful construction and a considerable difficulty in achieving movements.
But since I wanted to make it work and I did not want to stop by excessive technical problems, I decided to reduce everything to a system with two wheels and a jockey wheel.

After all, my sources of inspiration were two:
My cat "Ciccio" and K9, the faithful and robotic friend of Doctor Who.

Make It Simple, Stupid!

:)

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]