Show Posts
Pages: [1] 2
1  Community / Exhibition / Gallery / 16-legged walking creature on: March 05, 2014, 12:39:47 pm
My daughters and I built a 16-legged walking creature. We machined custom aluminum linkages. This robot uses an Arduino Nano. See the details, photos, and a video here:http://beatty-robotics.com/aluminalis/

2  Community / Exhibition / Gallery / Re: Arduino Mars Rover on: May 03, 2013, 08:20:37 am
Thanks for the wonderful feedback everyone. It's very encouraging.  smiley

Yes, it's the New York Hall of Science, which is here: http://www.nysci.org/

We are tentatively planning on installing the new robot sometime in June to do some initial testing. I don't have a date yet for the official launch. When it goes on line in the museum, I'll post it here so everyone knows. By the way, the NYSCI is also the location of the New York MakerFaire in the fall.
3  Community / Exhibition / Gallery / Re: Arduino Mars Rover on: May 02, 2013, 04:23:55 pm
Thank you, guys. I really appreciate it. It's great to be able to finally share it with the Arduino world and see what everyone thinks. We wanted to do a good job on it, but we weren't certain how it would all turn out. @Mario: We've been working on it about 7 weeks so far. The robot itself is pretty much done and now we're working on the Control Station software.
4  Community / Exhibition / Gallery / Arduino Mars Rover on: May 02, 2013, 03:56:11 pm
My daughters and I make Arduino-based robots for fun. Recently, we were asked by the New York Hall of Science (the hands-on science museum in New York) to build them a functional Mars Rover for their permanent Mars exhibit. The robot includes an Arduino Mega as the main controller, an xbee radio, six steering servos, six motors, a custom-built NASA-style rocker-bogie suspension system, eight Maxbotix sonars for object avoidance, a high-resolution wifi webcam with infrared detection, a thermopile array thermal sensor, a targeting laser, a pan servo, and so on. When it is installed in a couple of months, kids and other visitors to the museum will be able drive the Mars Rover remotely using a special Control Station. Their mission will be to roam around the exhibit and use the infrared camera to find special infrared-emitting rocks that provide one of the clues to finding evidence of past life on Mars. Lots of pictures, a couple of videos, and the build log are here: http://beatty-robotics.com/tag/mars-rover

   
5  Community / Exhibition / Gallery / Re: Arduino-based Mechatronic Tank with Mecacnum Wheels on: September 12, 2011, 06:16:05 am
Wow. Freaking epic. Where can I buy those wheels?

Thanks, Una Clocker. I've provided a list of the equipment used to make Mechatron at the bottom of the page here:
http://beatty-robotics.com/?p=434

If you haven't already, be sure to watch the video on this page.
6  Community / Exhibition / Gallery / Arduino-based Solar Powered Mars Rover on: September 11, 2011, 12:11:15 pm
My young daughters (9 and 11) and I have built a new robot we call "Spirit II Mars Rover" in honor of the rovers that are on Mars. The most interesting thing about this robot is its unique suspension system and how it turns, so be sure to watch the video on this robot's page: http://beatty-robotics.com/?p=525. My daughters and I have built more than ten Arduino-based robots so far, which you can see here: www.beatty-robotics.com




7  Community / Exhibition / Gallery / Arduino-based Mechatronic Tank with Mecanum Wheels on: September 11, 2011, 12:05:22 pm
My young daughters and I make Arduino-based robots for fun. Here is our latest project, an Arduino-based mechatronic tank we call "Mechatron". Be sure to watch the video and visit the page (http://beatty-robotics.com/?p=434) on our website www.beatty-robotics.com that explains the details of our robot.







8  Using Arduino / Programming Questions / Trouble with Wire I2C when connecting two Arduinos on: July 17, 2011, 04:50:19 pm
I have connected an Arduino Mega 2560 and an Arduino Nano through I2C. The Mega, which is the main controller on my robot, will be controlling (sending data to) the Nano, which will handle some of the complex lighting on the robot. As per the documentation for the respective boards, I have the Mega pin 20 (SDA) connected to the Nano Analog Pin 4 (SDA) and the Mega pin 21 (SCL) connected to the Nano Analog Pin 5 (SCL). I am using some of the example master/slave sketch that comes with the Arduino IDE. 

The Mega-based robot runs perfectly unless I try to send an I2C message. If I send a message through I2C, my motor controllers (which are on Serial 1 and Serial 2 of the mega and should be unrelated to I2C which is on different pins) go crazy and start running on their own. So, it appears that I2C is interfering with Serial 1 and/or 2 on the Mega.

Here's a simplified version of my I2C code on the Mega:

Code:
#include <Wire.h>

void setup()
{
  Wire.begin();
  Serial1.begin(9600);   Motor Controller #1
  Serial2.begin(9600);  Motor Controller #2

}

void loop():
{
 
 // lots of unrelated code up here

  Wire.beginTransmission(4);   // transmit data to device #4 (which is the Nano)
  Wire.send('g');   // send the "g" command, which will tell the Nano code what to do
  Wire.endTransmission();  // stop transmitting

  //  lots of motor controller code is down here, such as Serial1.print(rear_left_motor_signal,BYTE);

}

If the Wire lines are commented out, then the motor controllers behave properly.
Even though they are unrelated, if the Wire lines are there, then the motor controllers behave erratically.
It's as if the pins or the Wire library are somehow using the same timing or interrupt or otherwise interfering with Serial 1 and Serial 2.

If anyone could help me, I would appreciate it.
9  Using Arduino / Programming Questions / Re: Software Serial question on: July 09, 2011, 11:54:59 pm
>>>Maybe try the NewSoft Serial library

Thank you for the suggestion, Crossroads. I changed over to NewSoftSerial and everything started working perfectly. That solved my problem. smiley
10  Using Arduino / Programming Questions / Software Serial question on: July 09, 2011, 11:14:53 pm
I am setting up the SparkFun mp3 Trigger board  (http://www.sparkfun.com/products/9715) on my Arduino mega. I have done it before on other projects using this snippet of code:

Code:
 

  Serial1.begin(38400);   // initialize serial port 1 on the Arduino Mega

  Serial1.write('t');   // play track #1 on the mp3 board
  Serial1.write(1); 


On this new project, all my hardware serial ports are used, so I need to put the mp3 board on Software Serial. I've set it up on the Mega's digital pins 4 and 5. I've also set the firmware on the mp3 board to 9600 baud so that it will work with Arduino's Software Serial.

Code:

// Setup Software Serial for MP3 board
#include <SoftwareSerial.h>
#define txPin 4
#define rxPin 5
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup(void) 
{

  pinMode(txPin, OUTPUT);
  pinMode(rxPin, INPUT);

  mySerial.begin(9600);

  mySerial.print('t',BYTE);
  mySerial.print(1,BYTE);

}


Unfortunately, this code isn't working. The MP3 board is just ignoring the command, like it's not receiving the instruction "T1" to play track one. I've tried removing the "BYTE" option. That doesn't work either.

I have a feeling that maybe I'm not using Software Serial properly. This is my first time with it. Note that I'm using a Serial.write in first set of code, but I'm using the mySerial.print in the second set of code. Can anyone give me any tips for using SoftwareSerial to replicate what I'm doing in the first set of code? Does it look like I'm doing it properly?

--Robert
11  Using Arduino / Programming Questions / Re: Sketch works on Duemilanove but not Mega2560 on: July 04, 2011, 12:30:20 am
And there was much rejoicing! smiley

It works perfectly! Thank you.
12  Using Arduino / Programming Questions / Re: Sketch works on Duemilanove but not Mega2560 on: July 04, 2011, 12:11:09 am
Crossroads and Retroleft:

It seems like we're on the right track, but I don't have a clear understanding of ports, pins, and their relationship to the source code. I've tried a couple of things that I thought would work, but they did not, which means I don't understand it yet. I have an open Mega2560 so I'm flexible with pin placement. With your understanding of this subject, could you recommend the pins I should use and the corresponding changes to the source code so that I use the right pins and match them up properly in the source code? I would greatly appreciate it.
13  Using Arduino / Programming Questions / Sketch works on Duemilanove but not Mega2560 on: July 03, 2011, 11:17:05 pm
I have a sketch that works perfectly on the Duemilanove, but does not work on a Mega2560. It's the same sketch and the same pins are used. So, the question is, how is the Mega2560 different in such a way that it would cause this sketch not to work?

The project involves interfacing with a little breakout board called the Rotary Encoder LED Ring. This is a little board with a rotary switch on it that lights up different LEDs depending on the position of the knob. The device is here: http://mayhewlabs.com/products/rotary-encoder-led-ring

I am using their example sketch and wiring it exactly the way they say to. Works great on my Duemilanove, but when I set it up in an identical fashion, using the same pins, on my Mega2560 (which is where I really need it for this project), the LEDs in the ring do not light up. The sketch compiles and downloads to the Mega2560 with out error, and the one LED below the switch does come on, but none of the LEDs in the ring come on. I'm stumped why I can't get it to work on the Mega2560. I assume there must be some difference in the two boards but I can't figure out what it is. Mayhew Labs didn't know, but they said that perhaps the pins "have different names" (not sure what that means) or "use a different port." The code references pins 2, 3, 4, 8, 9, and 10 are used (which are the pins I've plugged the wires into). And it appears that 8,9,10 correspond to "PINB" in the sketch, but I don't know if the Mega2560 uses that same port or not.

Here is the example code I'm using, which was provided by the company:
Code:
/*
          Rotary_Encoder_LED_Ring_Example
          www.mayhewlabs.com/products/rotary-encoder-led-ring
          Copyright (c) 2011 Mayhew Labs.
          Written by Mark Mayhew
         
This example shows 3 sequences that are possible on the ring of LEDs around the encoder based on rotation of an encoder.  The 3 sequences are
selected by entering 1, 2, or 3 in the serial command prompt.  The serial window shows the current rotary encoder count.  As the encoder is turned,
the serial display shows a raw count of the rotary encoder's value and the LEDs show a scaled version of the value.  If the button on the rotary
encoder is pushed, the bottom LED will come on.  Each section of code below discusses the process required to do this.

A note on setting the output sequence:
Think of each LED as a single bit in a 16-bit long binary string.  If a bit is 1, the LED is on, if a bit is 0, the LED is off. 
By making a string of ones and zeros, we choose which LEDs to have on and off, and then send this string to the shift register to display it.
For example 1000000000000001 binary (0x8001 in hex) will have the fist and last LEDs on, the rest off. 

CREDIT:
Reading the rotary encoder is performed with Oleg's example code:a
http://www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino
*/

//These are the pins that will talk to the shift register through SPI
#define SDI    2   //Data 2
#define CLK    3    //Clock 3
#define LE     4    //Latch 4

//These are the rotary encoder pins A, B, and switch
#define ENC_A    8  // 8
#define ENC_B    9  //9
#define ENC_SW   10  // 10
#define ENC_PORT PINB  //The port that the rotary encoder is on (see http://www.arduino.cc/en/Reference/PortManipulation)

// Global variables
int scaledCounter = 0;  //The LED output is based on a scaled veryson of the rotary encoder counter
int sequenceNumber=0;   //The output sequence for the LEDs
int incomingByte = 0;   //Serial input to select LED output sequence


/*This is a 2 dimensional array with 3 LED sequences.  The outer array is the sequence;
  the inner arrays are the values to output at each step of each sequence.  The output values
  are 16 bit hex values (hex math is actually easier here!).  An LED will be on if its
  corresponding binary bit is a one, for example: 0x7 = 0000000000000111 and the first 3 LEDs
  will be on.
 
  The data type must be 'unsigned int' if the sequence uses the bottom LED since it's value is 0x8000 (out of range for signed int).
*/
unsigned int sequence[3][16] = {{0x0,0x1,0x2,0x4,0x8,0x10,0x20,0x40,0x80,0x100,0x200,0x400,0x800,0x1000,0x2000,0x4000},
                                {0x0,0x1,0x3,0x7,0xf,0x1f,0x3f,0x7f,0xff,0x1ff,0x3ff,0x7ff,0xfff,0x1fff,0x3fff,0x7fff},
                                {0x0,0x7fff,0x3ffe,0x1ffc,0xff8,0x7f0,0x3e0,0x1c0,0x80,0x1c0,0x3e0,0x7f0,0xff8,0x1ffC,0x3ffe,0x7fff},
                               };

void setup()
{
  //Set SPI pins to output
  pinMode(SDI, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(LE,OUTPUT);
  //Set encoder pins to input, turn internal pull-ups on
  pinMode(ENC_A, INPUT);
  digitalWrite(ENC_A, HIGH);
  pinMode(ENC_B, INPUT);
  digitalWrite(ENC_B, HIGH);
  pinMode(ENC_SW, INPUT);
  digitalWrite(ENC_SW, HIGH);
  //Set serial rate, prompt for desired sequence
  Serial.begin(115200);
  Serial.println("Enter 1, 2, or 3 to change the LED sequence");
}


void loop()
{
  //Local Variables
  static uint8_t counter = 0;      //this variable will be changed by encoder input
  int8_t tmpdata;
 
  //Get any serial input
  if (Serial.available() > 0)
  {
    incomingByte = Serial.read();
  }
 
  //if the serial input is valid, set the LED output sequence appropriately
  if (incomingByte == '1')
    sequenceNumber=0;
  if (incomingByte == '2')
    sequenceNumber=1;
  if (incomingByte == '3')
    sequenceNumber=2;
   
  //Call read_encoder() function   
  tmpdata = read_encoder();
 
  //if the encoder has moved
  if(tmpdata)
    {
      //Print out the counter value
      //Serial.print("Counter value: ");
      //Serial.println(counter, DEC);
      //Set the new counter value of the encoder
     
      counter += tmpdata;     
     
     // if (counter==64) {counter = 0;}  // This will cause it to always show only one light
     if (counter==128) {counter = 0;}  // This will cause it to always show only one light
     if (counter==255) {counter = 127;}
     
     
      //Scale the counter value for referencing the LED sequence
      //***NOTE: Change the map() function to suit the limits of your rotary encoder application.
      //         The first two numbers are the lower, upper limit of the rotary encoder, the
      //         second two numbers 0 and 14 are limits of LED sequence arrays.  This is done
      //         so that the LEDs can use a different scaling than the encoder value.


      scaledCounter = map(counter,0,100,0,25);  // provides one for one match up

      Serial.print(counter,DEC);
      Serial.print("  ");     
      Serial.println(scaledCounter, DEC);
     
      //scaledCounter = map(counter,0,100,0,15); original
     
      //Send the LED output to the shift register
      digitalWrite(LE,LOW);
      shiftOut(SDI,CLK,MSBFIRST,(sequence[sequenceNumber][scaledCounter] >> 8));    //High byte first
      shiftOut(SDI,CLK,MSBFIRST,sequence[sequenceNumber][scaledCounter]);           //Low byte second
      digitalWrite(LE,HIGH);
    }
 
  //If the encoder switch is pushed, this will turn on the bottom LED.  The bottom LED is turned
  //on by 'OR-ing' the current display with 0x8000 (1000000000000000 in binary)
  if (!digitalRead(ENC_SW))
  {
    digitalWrite(LE,LOW); 
    shiftOut(SDI,CLK,MSBFIRST,((sequence[sequenceNumber][scaledCounter]|0x8000) >> 8));
    shiftOut(SDI,CLK,MSBFIRST,sequence[sequenceNumber][scaledCounter]);             
    digitalWrite(LE,HIGH);   
  }
}



/*************************************************************************
*    read_encoder() function as provided by Oleg:                        *
*    http://www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino *
*                                                                        *
*    Returns change in encoder state (-1,0,1)                            *
************************************************************************ */
int8_t read_encoder()
{
  int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
  static uint8_t old_AB = 0;
  /**/
  old_AB <<= 2;                   //remember previous state
  old_AB |= ( ENC_PORT & 0x03 );  //add current state
  return ( enc_states[( old_AB & 0x0f )]);
}
14  Forum 2005-2010 (read only) / Syntax & Programs / Need help with serial communication / substrings on: January 21, 2011, 12:03:08 am
I would really appreciate some help. I am building a robot. The robot receives movement commands in the form of ascii text coming in through the arduino's serial port. So, for example, the commands are "move_straight", "move_right", and so on.
The problem is that the command strings aren't terminated with any sort of special character (such as ASCII 13) separating one command from another. It's just a flow of text that runs together one after the other.
I've written other sketches that read in serial data, look for ASCII 13 or whatever, know that it's the end of the string, and then act accordingly. In this case, I don't have that option because there is no separator between the commands.
Could someone write me a little example sketch to point me in the right direction?
One method I was playing with was to read the characters into a char buffer variable one by one. After each character is read, I was going to see if the buffer contained a substring that matched one of my known commands. If it did, then I was going to act upon the command, clear the buffer, and then continue reading characters. The problem is I don't know how to use Arduino C to check whether a char string contains a substring. And I don't have any familiarity with using String objects with respect to serial communication.
15  Forum 2005-2010 (read only) / Interfacing / Re: xbee dropping characters on: August 31, 2010, 02:53:04 pm
PaulS,

You're awesome! Thank you. That instantly solved my problem. I can't believe I've been staring at that code all this time and didn't see that problem. I eliminated that extra line that you identified and everything is working perfectly now. Thank you. I really appreciate it.

-rb451
Pages: [1] 2