View unanswered posts | View active topics It is currently Mon Sep 15, 2014 9:09 pm






Reply to topic  [ 5 posts ] 
Wii Nunchuck Operated, Servo Controlled Lego Zamor Cannon! 
Author Message
Rookie
User avatar

Joined: Tue Aug 11, 2009 11:49 pm
Posts: 38
Location: Tasmania, the Land Down Under, the Land Downunder!
Post Wii Nunchuck Operated, Servo Controlled Lego Zamor Cannon!
This is my Wii Nunchuck Operated, Servo Controlled Zamor Cannon. This is my first project using the Simply Modified Servos Motors that I mentioned in a previous forum post :arrow: . It uses the MindSensor 8 Channel Servo Controller for the NXT, the NXTServo-v2.

The Cannon uses two 9gram Servos for Altitude and rotation, and one 43gram Servo to control firing. A 9gram Servos was capable of controlling the direct drive firing pin, but they were at their very limits, so I used Big Brother instead. Amazing, motion and Not a single Lego motor in sight!

Image
It's Strange to see the NXT Brick with only a single cable attached!

The Servo Controller requires an external 4.5-6 volt power supply to power the Servos. In this project with only the 3 Servos I used 4.5Volts supply. I've found in order to control more than 4 Servos you really need the 6volt supply as they work better and there's less current draw (Remember Mr. Ohm told us that "V=IR").

The Servo Controller is a dream to program and use and the fact you can drive 8 at a time means there are a million possible projects. I'm now trying to come up with a project that I can use all 8 servos, my 2 Mindsensor RCX Motor Multiplexer for NXT controlling 8 Lego Mini Motors as well as the 3 Lego NXT Motors. I also have my own home-brew I2C 8 Touch Switch multiplexer and the MindSensor RCX Sensor multiplexer for NXT, the RXMux for use with 4 RCX Sensors. The only thing holding me back is my Programming abilities and some imagination.

Here's the Source Code for my Wii Nunchuck Operated, Servo Controlled Zamor Cannon for those interested.

Code:
///////////////////////////////////////////////////////////////////////////////////////////////////////
//
//        "Mindsensors Servo Controller & Wii Nunchuck Controlled Zarmor Cannon"
//
//                  Ray McNamara August 2009 - sparra_mc@liliums.org
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

#include "NXTServo-lib.c"   // MindSensor NXT Servo Controller Library
#include "Nunchuk-lib.c"    // Wii Nunchuck Controller Library

//
//  Register Task Vairable Names
//

void initializeCannon();
void fireCannon();
void finalizeCannon();
#pragma fileExtension("rtm")
#pragma platform("NXT")

//
//  Monitor Nunchuck Controller to Position & Fire the Cannon
//

task CannonControl()
{
  while (true)
  {
    NunchukGetParamter(S1, 0x00);               //Set Nunchuk i2c Port
    if (sizeof(outbuf)==6)    {
      nxtDisplayTextLine(6, "NXT   = %dmV", nAvgBatteryLevel);  // Display NXT's Battey Level
      nxtDisplayTextLine(7, "Servo = %dmV", Get_Batt_V());      // Display Servo Controller's Battey Level

      NXTServo_Quick_Servo_Setup(2, (outbuf1[1]-0x1E)+30);      //  Joystick - Up:Down
      NXTServo_Quick_Servo_Setup(3, (outbuf1[0]-0x1E)+50);      //  Joystick - Left:Right

//      NXTServo_Quick_Servo_Setup(2, (outbuf1[3]-0x1E)+30);      //  Use Motion Sensor - Up:Down
//      NXTServo_Quick_Servo_Setup(3, (outbuf1[2]-0x1E)+50);      //  Accelerometer - Left:Right


      if ((outbuf1[5]&0x01)==0) {                               //  Z-Button Pressed
        PlaySoundFile("Watch Out.rso");         // Warning Cannon Firing Message
        fireCannon();
       }
       if ((outbuf1[5]&0x02)==0) {finalizeCannon();}           //  C-Button Pressed
    }
    wait1Msec(100);                             // Don't Hog CPU
  }
}


//
//  Begin the NXT Zamor Cannon Program
//

task main()
{
  PlaySoundFile("Hello.rso");                   // Welcome Audio Message
  nI2CBytesReady[kSc8Port] = 0;                 // Select Sensor Port
  SensorType[kSc8Port] = sensorI2CCustom9V;     // Set Sensor Port Mode
  eraseDisplay();                               // Grab LCD screen and initialize display
  nxtDisplayBigTextLine(1, "ZAMOR");
  nxtDisplayBigTextLine(3, " CANNON");
  initializeCannon();                           // Ready Cannon
  PlaySoundFile("Robot.rso");                   // Cannon is Ready Audio Message
  PlaySoundFile("Start.rso");
  StartTask(CannonControl);                     // Monitor the 'Wii Nunchuck' Cannon Controller
}

//
//  Ready the Cannon for Use
//

void initializeCannon()
{
  NXTServo_Quick_Servo_Setup(1, 250);           // Move Servo to Start Position
  wait10Msec(100);                              // Wait for Servo to Complete Operation
  NXTServo_Quick_Servo_Setup(1, 0);             // Put Servo 1 in Neutral
  NXTServo_Quick_Servo_Setup(2, 150);           // Move Servo to Start Position
  wait10Msec(100);                              // Wait for Servo to Complete Operation
  NXTServo_Quick_Servo_Setup(2, 0);             // Put Servo 2 in Neutral
  NXTServo_Quick_Servo_Setup(3, 150);           // Move Servo to Start Position
  wait10Msec(100);                              // Wait for Servo to Complete Operation
  NXTServo_Quick_Servo_Setup(3, 0);             // Put Servo 3 in Neutral
  return;
}

//
//  Fire the Cannon at Target
//

void fireCannon()
{
  NXTServo_Quick_Servo_Setup(1, 50);            // Fire Cannon Ball
  wait10Msec(100);                              // Wait for Servo to Complete Operation
  NXTServo_Quick_Servo_Setup(1, 250);           // Reset Cannon Ready for Firing
  wait10Msec(100);                              // Wait for Servo to Complete Operation
  NXTServo_Quick_Servo_Setup(1, 0);             // Put Servo 1 in Neutral
  return;
}

//
//  Set Servos to Coast Mode & Terminate Program
//

void finalizeCannon()
{
  NXTServo_Quick_Servo_Setup(1, 0);             // Put Servo 1 in Neutral
  NXTServo_Quick_Servo_Setup(2, 0);             // Put Servo 2 in Neutral
  NXTServo_Quick_Servo_Setup(3, 0);             // Put Servo 3 in Neutral
  PlaySoundFile("Stop.rso");                    // Cannon Shutdown Audio Message
  PlaySoundFile("Goodbye.rso");
  wait10Msec(1000);                             // Wait for Auto Power Off Cancelation
  powerOff();                                   //  Turn Power Off on NXT Brick
}




:breakcomputer: Instructions for modify the Wii Nunchuck controller can be found in the RobotC Forums. It requires 2 X 33kohm 1/8Watt Resistors, a NXT Compatible Male Plug from Mindsensors, a small screw driver, Soldering Iron and 15 minutes of your time. With a little care and patients, it will end up looking like it came with you MindStorms NXT Kit originally.

Image

At this stage it looks like I'll have the Cannon built up for a while as my three+ year old Son won't let me dismantle it. We now have two Zamor Cannons for the same reason. The second one was built using standard NXT Motors. The Servo version is the simplest, easiest to build and most reliable!


Attachments:
File comment: This is the Wii Nunchuck Controller Library file, "Nunchuk-lib.c" which is need to compile the program and to use the Controller.
Nunchuk-lib.c [1.65 KiB]
Downloaded 436 times

_________________
regards

Sparra Mc


Image


Last edited by sparramc on Mon Aug 17, 2009 4:25 am, edited 1 time in total.

Mon Aug 17, 2009 3:06 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3218
Location: Rotterdam, The Netherlands
Post Re: Wii Nunchuck Operated, Servo Controlled Lego Zamor Cannon!
Sparra,

Nice job! Make a small video, host it on YouTube and then mail deepak@mindsensors.com about this. I'm pretty sure it'll be featured on their website.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon Aug 17, 2009 3:39 am
Profile WWW
Rookie
User avatar

Joined: Tue Aug 11, 2009 11:49 pm
Posts: 38
Location: Tasmania, the Land Down Under, the Land Downunder!
Post YouTube Video - For the Servo Controlled Lego Zamor Cannon!
I finally found a camera and time to edit a quick video of my Servo Controlled Lego Zamor Cannon in action and posted it on YouTube.

Visit http://www.youtube.com/v/SCh0CfU-nxE&hl=en&fs=1 to see my Robot in Action without a Single Lego Motor Insight!

_________________
regards

Sparra Mc


Image


Tue Aug 18, 2009 7:05 am
Profile WWW
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: Wii Nunchuck Operated, Servo Controlled Lego Zamor Cannon!
Looks cool. Now all you have to do is put it on wheels and you've got yourself a regular tank.

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Tue Aug 18, 2009 1:54 pm
Profile
Rookie
User avatar

Joined: Tue Aug 11, 2009 11:49 pm
Posts: 38
Location: Tasmania, the Land Down Under, the Land Downunder!
Post Re: Wii Nunchuck Operated, Servo Controlled Lego Zamor Cannon!
I wasn't worried about mobility as it was purely and exercise in understanding the Mindsensor Servo Controller and it's programming.

The follow-up project, the NXT-Ant will have mobility using the Mindsensor Servo Controller with 8 Servos and 3 NXT Motors. At this stage it will be armed with a set of jaws but, I may put a sting in it's tail at a later date! I've posted an image in the discussion area of this Robot-C Forum of NXT-Ant Mark I.

_________________
regards

Sparra Mc


Image


Fri Aug 21, 2009 12:37 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.