Posts Tagged ‘Arduino’

Refurbishing Robot

Posted by Erin, the RobotGrrl on Wednesday, July 21st, 2010

IMG_8728

The missing parts to the TECHNOROBOT kit that I got at the explOratorium during the Stanford EPGY AI Program in 2008 have been found! This robot has been transformed many times, the first as an idea/prototype for an emotional line following robot, then a snowplow, and now it will be an XBee messenger robot!

Refurbishing it was OK, it only took 4 hours. The only thing that was drastically broken was the drive axel. To fix it, I used some Lego axels. :)

The robot now uses an Arduino, and is powered off of USB. The motor is driven with the Adafruit Motor Shield (I plan to add more motors to the robot someday). The motor is powered from an Adafruit mintyboost.

I broadcasted the refurbishment to the Fat Man and Circuit Girl stream, AND took a photo every 5 seconds! You can see the HD timelapse on Vimeo! :D

The next steps for this robot is rather short:

  • Make a battery pack for the Arduino
  • Attach XBee
  • Mount an ultrasonic sensor, program a simple behaviour
  • Transmit messages, listen to messages

Can’t wait to blog more about it! :D

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Posted in: Projects, Robot.

MANOI’s Antennas and Tidying Up

Posted by Erin, the RobotGrrl on Tuesday, May 18th, 2010

One of the annoying things about MANOI is that there are many things that can break very often. The antennas broke very often, mainly at the plug part, where the wires plug into the Arduino, and thankfully not the difficult part, the leads to the LEDs. The wires connecting the LEDs to the Arduino were way too long and throwing off the center of gravity for the balance. Also, the leads for the LEDs were uncovered. This is not aesthetically pleasing, and it is unsafe.

First step was to remove the wires currently attached to the LED (these were red white green black wires), cut the new wires (red orange yellow brown) to a shorter length. Solder on the new wires, and use green shrink wrap. The green is important, since this colour matches MANOI’s colour scheme ;)

IMG_6460

When all four are done:

IMG_6470

The terminals were where a lot of breaks occurred, so these had to be improved. The previous way this was handled was that I soldered the wires to pins on a 3 pin male header, then placed hot glue around the solder joints. This time, I used shrink wrap instead of the glue.

IMG_6471

It makes sure that it is nice and sturdy. People can actually touch it now, and it won’t break! :P

IMG_6467

The ground bus was also very messy the first time around. This was now fixed, and cannot be seen since it will be within MANOI’s head unit.

IMG_6547

After positioning and hot gluing, it looks great!

IMG_6548

The new antennas really go with the colour theme :)

IMG_6553

Here you can see that the wires are much tidier.

IMG_6559

IMG_6560

IMG_6568

And voila! MANOI looks much happier now.

IMG_6601

As for the rest of tidying up… I made a quick battery caddy out of a watch tin to keep my batteries organized into charged or needs to be charged!

IMG_6718

On MANOI’s other hand with the hockey stick is this adapter that sort of extends the hand from the servo a bit. I figured I might as well add it to the other hand as well. I also fixed the bows with the jingle bells and reattached them to MANOI’s wrists- that’s what the velcro is for in the below picture :)

IMG_6721

Fixed MANOI’s hockey stick plug in adapter wires:

IMG_6723

The next improvement was to the power switch that powers the servos. The switch keeps on breaking, so I wanted to redo it. Since I was redoing it, I figured I might as well use one of the switches that lights up! Since there’s three prongs, and one of them is a Ground, I wanted to be overly careful and make sure I test it first…

IMG_6723

IMG_6726

IMG_6729

The switch works, lights up, and doesn’t blow up! :D It’s rated for 12V, and the battery is 11.1V. Hopefully there is enough wiggle room there. I’m pretty pleased with the way it looks and works in comparison to the broken switch.

IMG_6740

That’s about all that has been accomplished this far. There’s still a lot more to do! On my workdesk now I have two ultrasonic sensors, a gyro and accelerometer, and many photoresistors (LDR). I want to somehow hook up the LDRs to MANOI and make a program where I can shine a light at them, and MANOI would move accordingly. Taking it a step further, I’d attach the light to a Wii Nunchuck where MANOI could number crunch and analyze the accelerations from the nunchuck to do something — maybe make a prediction about where the light will be going. It would sort of be like a game of Simon, only the “Simon” would be MANOI, and would be actively trying to outsmart you. :P

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Posted in: MANOI, Projects, Robot.

Arduino SSC32 Library

Posted by Erin, the RobotGrrl on Tuesday, May 4th, 2010

SSC32

When you google “Arduino SSC32″ my tutorial on Nuvvo is the first to show up, I figured I might as well make a library for the Arduino to help the other users out there get started with their SSC32.

There are three main parts to using this library:

  • Initial positions
  • Frames
  • Set the frame

The initial positions are going to be your home position of all of your servos. For a humanoid, this is usually a standing position that is balanced. Setting the initial positions looks like this (in general):

  1. int HOME0 = 1800;
  2. int HOME1 = 1500;
  3. int HOME2 = 1050; // 1000 for normal, 1050 for gyro
  4. int HOME3 = 1300;
  5. int HOME4 = 800;   // 1300 for hockey, 800 for normal
  6. int HOME5 = 1600;
  7. int HOME6 = 1900;
  8. int HOME16 = 1550;
  9. int HOME17 = 1250;
  10. int HOME18 = 1000;
  11. int HOME19 = 1600;
  12. int HOME20 = 1600;
  13. int HOME21 = 1500;
  14. int HOME22 = 1250;
  15. int HOME23 = 1000;
  16. int HOME24 = 1580;
  17. int HOME25 = 1600;

In animation, the still pictures that make up a movie are called frames. Moving a bunch of servos or a robot according to frames would make sense. Here is an example of a home frame:

  1. int homeFrame[17] = {
  2.       HOME0,
  3.       HOME1,
  4.       HOME2,
  5.       HOME3,
  6.       HOME4,
  7.       HOME5,
  8.       HOME6,
  9.       HOME16,
  10.       HOME17,
  11.       HOME18,
  12.       HOME19,
  13.       HOME20,
  14.       HOME21,
  15.       HOME22,
  16.       HOME23,
  17.       HOME24,
  18.       HOME25
  19. };

Initialize the SSC32 library by setting up the object like this:

  1. SSC32 ssc(true);

The true/false parameter does not effect anything. It has to be there because, for some reason, the library doesn’t compile with no parameters. :P

In the setup() function, the servos have to be enabled. For MANOI, the arms are plugged in to ports 0-6, and the legs from 16-24 and the bad knee is on port 31.

  1. for(int i=0; i<7; i++) {
  2.     ssc.servoMode(i, true);
  3.   }
  4.  
  5.   for(int i=16; i<25; i++) {
  6.     ssc.servoMode(i, true);
  7.   }
  8.  
  9.   ssc.servoMode(31, true);

The last step is pretty simple- just set the frame using this function:

  1. setFrame(int theFrame[], int moveTime, int delayTime);

Example:

  1. ssc.setFrame(homeFrame, 1000, 100);

Delay time is the amount of time you want to delay after the movement. Move time is how long the servos take to go from their current position to the positions in the frame.

Things that you must do in order for the library to work (mainly common sense):

  • The frame references the position of the servos in sequential order. Meaning, it’s servo #0, #1, #2, #3 … #31. You can’t mix the order around, it won’t work.
  • If the servo is in the frame, it has to be enabled. :P If it is not enabled, then everything will be confused.
  • Have the SSC32 connected to the Serial port. If you need it to be Serial1, then you can change it in the library’s cpp file (just do a find+replace) ^_^

The SSC32 library uses the Arduiniana Streaming library. Be sure to download and install it into your sketches/libraries/ folder!

Download the SSC32 library here!

There is an example included. :)

Let me know of any bugs that you find, or how anything can be optimized! :D

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Posted in: Programming, Projects.

Arduino to Matlab – Read in sensor data!

Posted by Erin, the RobotGrrl on Friday, January 15th, 2010

Matlab is by far the best software I have ever seen when it comes to plotting data and showing it in a visual format. I figured it would be awesome if I could get Arduino and Matlab to work together!

Here’s the code that I came up with that works reasonably fast. It doesn’t wait for the buffer to be filled to then store it to a variable. Here, it is asynchronous communication. ^_^

This is a basic screenshot of what you will get, minus the green stars.

matlabscreenshot

Here is the code. Let me know if you use, it would be neat to see what everyone would come up with!
*Note: The code highlighting for Matlab was buggy, so the below is using C code highlighting. Once you paste it into Matlab, it will be fine.

  1. % Basic Arduino and Matlab
  2. % Communication with an external hardware device
  3. % ———————————————-
  4. %
  5. % Erin Kennedy
  6. % Jan. 18, 2010
  7. %
  8.  
  9.  
  10. clear all; clc; close all;
  11.  
  12.  
  13. % Try-catch is to prevent Matlab from crashing when the program is finished
  14. try
  15.  
  16.    
  17. % Initialize serial port
  18. s = serial(‘/dev/tty.usbserial-A4001lVG’);
  19. %set(s, ‘ Terminator’, ‘LF’); % Default terminator is \n
  20. set(s,‘BaudRate’, 9600);
  21. set(s,‘DataBits’, 8);
  22. set(s,‘StopBits’, 1);
  23. fopen(s);
  24. s.ReadAsyncMode = ‘continuous’;
  25.  
  26.  
  27. % Various variables
  28. numberOfDatas = 50;
  29. data = zeros(1, numberOfDatas);
  30. i = 1;
  31.  
  32.  
  33. % Main graph figure
  34. figure(1);
  35. hold on;
  36. title(‘Incomming Data from External Device’);
  37. xlabel(‘Data Number’);
  38. ylabel(‘Analog Voltage (0-1023)’);
  39.  
  40.  
  41. % Start asynchronous reading
  42. readasync(s);
  43.  
  44.  
  45. while(i<=numberOfDatas)  
  46.    
  47.    
  48.     % Get the data from the serial object
  49.     data(i) = fscanf(s, ‘%d’);
  50.    
  51.     % Plot the data
  52.     figure(1);
  53.     plot(i, data(i), ‘m*’);
  54.    
  55.     % Ensure there are always 10 tick marks on the graph
  56.     if(i>10)
  57.        xlim([i-10 i]);
  58.        set(gca,‘xtick’,[i-10 i-9 i-8 i-7 i-6 i-5 i-4 i-3 i-2 i-1 i])
  59.     end
  60.    
  61.     % Draw and flush
  62.     drawnow;
  63.    
  64.     %Increment the counter
  65.     i=i+1;
  66.    
  67.    
  68. end
  69.  
  70.  
  71. % Give the external device some time…
  72. pause(3);
  73.  
  74. return;
  75.  
  76. catch
  77.  
  78. % Some of these crash the program it depends. The serial port is left
  79. % open, which is not good.                                              
  80. stopasync(s);
  81. fclose(s); % bad
  82. %delete(s);
  83. %clear s;
  84.  
  85. fprintf(1, ‘Sorry, you"re going to have to close out of Matlab to close the serial port\n);
  86.  
  87. return
  88.  
  89. end

The code for the Arduino is this:

  1. //
  2. // BubbleBoy -> Matlab
  3. // ——————-
  4. //
  5. // Read LDR data, print them to Serial (where Matlab will receive them)
  6. //
  7.  
  8. int LDRpin = 0;
  9.  
  10. void setup() {
  11.  
  12.   Serial.begin(9600);
  13.   pinMode(LDRpin, INPUT);
  14.  
  15. }
  16.  
  17. void loop() {
  18.  
  19.  int photocellReading = analogRead(LDRpin);
  20.  
  21.  Serial.println(photocellReading, DEC);
  22.  delay(200);
  23.  
  24. }

Enjoy, happy matlabbing!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Posted in: Programming, Projects, School.

Friday Night Robotics – MusicBox!

Posted by Erin, the RobotGrrl on Sunday, October 11th, 2009

This Friday I had the most awesome idea of a weekend project ever! A 21st century MusicBox, using an Arduino and have blinking LEDs!

I had a Sparkfun box lying around, which is an ideal size for an Arduino and a WaveShield.

Friday Night Robotics - MusicBox!

I wanted to have LEDs outlining the box, so I went to work on it:

Friday Night Robotics - MusicBox!

Friday Night Robotics - MusicBox!

Just as a disclaimer- I designed it wrong, so the LEDs don’t work well. If you’re looking to follow my steps, DON’T DO IT! :P

Friday Night Robotics - MusicBox!

Friday Night Robotics - MusicBox!

Then, installing them into the box:

Friday Night Robotics - MusicBox!

It looks nice!

Friday Night Robotics - MusicBox!

Once all of the connections are made, it’s pretty tight in there:

Friday Night Robotics - MusicBox!

The problem though, is that I designed it so that all the LEDs are in series. Since al LEDs aren’t created equally, some suck up more power and therefore can’t share it with the others. This is what happened:

Friday Night Robotics - MusicBox!

It’s pretty sad! :( But, I think that I can fix it because I soldered the resistors together, not the actual LEDs together. :D I was too excited to start this project, so I didn’t bother to plan =) I guess planning would have been better, but it would also have been too boring.

I also worked on a NXT LED blinky thingy. There are these HiTechnic Protoboards that you can get, and basically you attach them to one of the sensor inputs, and you can control power to certain ports and such.

In this case, there’s 6 output pins that you can control. Sounds like an opportunity to use LEDs to me! :D

NXT + LEDs

This is what the setup looks like:

NXT + LEDs

It goes like this: NXT -> HiTechnic ProtoBoard Sensor Adapter -> 6 LEDs

In order to output instructions to the HiTechnic ProtoBoard, you need ‘drivers’, or headers. They’re located here.

Here is the code for the LEDs, in RobotC:

  1. #pragma config(Sensor, S1,     HTPB,                sensorI2CCustom9V)
  2. //*!!Code automatically generated by ‘ROBOTC’ configuration wizard               !!*//
  3.  
  4. /*
  5.   Crazy LEDs!
  6.   Erin K
  7.   Oct. 9th, 2009
  8. */
  9.  
  10. #include "drivers/common.h"
  11. #include "drivers/HTPB-driver.h"
  12.  
  13. byte theLEDs[] = { 0×01, 0×02, 0×04, 0×08, 0×10, 0×20 };
  14.  
  15. task main() {
  16.  
  17.   // Setup all the digital IO ports as outputs (0xFF)
  18.   if (!HTPBsetupIO(HTPB, 0xFF)) StopAllTasks();
  19.   wait1Msec(200);
  20.  
  21.   while(true) {
  22.  
  23.     // The delay time
  24.     int theTime = 50;
  25.  
  26.     // LEDs going up
  27.     for(int i=0; i<6; i++) {
  28.       if (!HTPBwriteIO(HTPB, theLEDs[i])) nxtDisplayTextLine(5, "ERR WRITE");
  29.       wait1Msec(theTime);
  30.     }
  31.  
  32.     // LEDs going down
  33.     for(int i=5; i>=0; i) {
  34.       if (!HTPBwriteIO(HTPB, theLEDs[i])) nxtDisplayTextLine(5, "ERR WRITE");
  35.       wait1Msec(theTime);
  36.     }
  37.  
  38.     alive();
  39.  
  40.   }
  41.  
  42. }

This is what the code does:

To wrap up this Friday Night Robotics, I checked out the Adafruit Ask an Engineer chat. It was pretty cool! I learnt about how LEDs work, and how much it costs to create a Teenyduino! Everyone should check it out, Saturday at 10:00PM EST.

The only things that I didn’t get to do that I wanted to was play with MANOI and the iRobot Create. I’m kinda worried that MANOI’s batteries are drying out as they haven’t been exercised in a while :S EEP!

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit Post to StumbleUpon

Posted in: Art, Programming, Projects, Robot.