Wednesday, April 25, 2012

the end :)

So I spent my whole weekend on writing my instructable. I didn't work on any other class's work because this took so long. You dont realize how many steps went into it til you sit and try to write it out. But it took me more time than it would have because I drew some diagrams in photoshop for steps that I didnt have good pictures for and I linked videos on youtube on how to solder and how a breadboard works so when people like me, or like I was before this class, can do it easily. I published it late Monday night.

I was pretty excited to see that I had 43 views the next morning, so you can imagine how psyched I was when I got an email that my instructable was chosen by the editor to be featured!!! Then I got another email saying the it would be on the homepage! THE HOMEPAGE! Wicked Awesomeness!

I'm so glad its all said and done, but I had a blast! This is my favorite class of my college career :)

Thursday, April 19, 2012

instructables update 4/19

Took the doll to the mall today. Went to show it to all the employees at all the stores that asked for me to come show them when it was done but most of them werent at work today so i will have to go back. I had fun though. I was holding the doll as I walked through the mall and as i passed by people I had the doll turn and look them. I got a few reactions but not many. The fun part came when my kids and I stopped at the food court to eat lunch and i sat the doll on a table a little distance away and followed people as they walked by. That Was GREAT FUN! People walking by in singles barely glanced at it, but people in groups had great reactions. Some jumped, some stopped dead in their tracks and stared. i tried to get a video but everytime i recorded, nothing good happened and when I stopped, there was a great reaction, go figure.

When we passed by a jewerly store some employees noticed the doll and asked me to come show them. They were great and made my day. They loved it and had never ending streams of compliments to give. :)

instructables update 4/17

So i spent all day saturday and most of the day sunday at my parents' house working on this project. My step dad graciously agreed to help me put everything in the doll. He didn't like me taking pictures though so that was a battle, but I got some. It took forever and lots of trial and error but we got it working. It doesnt work to my expectations and Im kida disappointed but no way am I going to fool with it and chance messing it up.

The head only turns from side to side and that motion is limited, it doesnt have the full 180 degree range I was hoping for, but it does move so good enough.












Saturday, April 7, 2012

wireless kama chuk code


#include <Wire.h>
#include <string.h>
#include <stdio.h>
uint8_t outbuf[6];
int cnt = 0;
int ledPin = 13;
int servoPin = 5;
int servoPin2 = 6;
int pulseWidth = 0;
int pulseWidth2 = 0;
long lastPulse = 0;
long lastPulse2 = 0;
int z_button = 0;
int c_button = 0;
int refreshTime = 20;
int minPulse = 1000;
int minPulse2 = 500;
int dtime=10;
#define pwbuffsize 10
long pwbuff[pwbuffsize];
long pwbuffpos = 0;
long pwbuff2[pwbuffsize];
long pwbuffpos2 = 0;
void setup()
{
    Serial.begin (19200);
    Wire.begin ();
    nunchuck_init ();
    pinMode(servoPin, OUTPUT);
    pinMode(servoPin2, OUTPUT);
    pulseWidth = minPulse;
    pulseWidth2 = minPulse2;
    Serial.print ("Finished setup\n");
}
void nunchuck_init()
{
    Wire.beginTransmission (0x52);
    Wire.send (0xF0);
    Wire.send (0x55); 
    Wire.endTransmission ();
    delay(30);
   
    Wire.beginTransmission(0x52);
    Wire.send (0xFA);
    Wire.endTransmission();
    delay(30);
 
    Wire.requestFrom(0x52, 6);
    delay(30);
}
void send_zero()
{
    Wire.beginTransmission (0x52);
    Wire.send (0x00);
    Wire.endTransmission ();
}
int t = 0;
void loop()
{
    t++;
    long last = millis();
    if( t == 1) {
        t = 0;
        Wire.requestFrom (0x52, 6);
        while (Wire.available ()) {
            outbuf[cnt] = nunchuk_decode_byte (Wire.receive ());
            digitalWrite (ledPin, HIGH);
            cnt++;
        }
        if (cnt >= 5) {
            //            printNunchuckData();
            int z_button = 0;
            int c_button = 0;
            if ((outbuf[5] >> 0) & 1)
                z_button = 1;
            if ((outbuf[5] >> 1) & 1)
                c_button = 1;
            switch (c_button) {
            case 1:
                switch (z_button) {
                case 0:
                    break;
                case 1:
                    muovi();
                    break;
                }
                break;
            case 0:
                switch (z_button) {
                case 0:
                    delay(10000);
                    break;
                case 1:
                    delay(3000);
                    break;
                }
                break;
            }
        }
        cnt = 0;
        send_zero();
    } // if(t==)
    updateServo();
    delay(dtime);
}

void updateServo() {
    if (millis() - lastPulse >= refreshTime) {
        digitalWrite(servoPin, HIGH);
        delayMicroseconds(pulseWidth);
        digitalWrite(servoPin, LOW);
        digitalWrite(servoPin2, HIGH);
        delayMicroseconds(pulseWidth2);
        digitalWrite(servoPin2, LOW);
        lastPulse = millis();
    }
}
int i=0;
void printNunchuckData()
{
    int joy_x_axis = outbuf[0];
    int joy_y_axis = outbuf[1];
    int accel_x_axis = outbuf[2]*2*2; // * 2 * 2;
    int accel_y_axis = outbuf[3]*2*2; // * 2 * 2;
    int accel_z_axis = outbuf[4]*2*2; // * 2 * 2;
    int z_button = 0;
    int c_button = 0;
    if ((outbuf[5] >> 0) & 1)
        z_button = 1;
    if ((outbuf[5] >> 1) & 1)
        c_button = 1;
    if ((outbuf[5] >> 2) & 1)
        accel_x_axis += 2;
    if ((outbuf[5] >> 3) & 1)
        accel_x_axis += 1;
    if ((outbuf[5] >> 4) & 1)
        accel_y_axis += 2;
    if ((outbuf[5] >> 5) & 1)
        accel_y_axis += 1;
    if ((outbuf[5] >> 6) & 1)
        accel_z_axis += 2;
    if ((outbuf[5] >> 7) & 1)
        accel_z_axis += 1;
    Serial.print (i,DEC);
    Serial.print ("\t");
    Serial.print ("X: ");
    Serial.print (joy_x_axis, DEC);
    Serial.print ("\t");
    Serial.print ("Y: ");
    Serial.print (joy_y_axis, DEC);
    Serial.print ("\t");
    Serial.print ("AccX: ");
    Serial.print (accel_x_axis, DEC);
    Serial.print ("\t");
    Serial.print ("AccY: ");
    Serial.print (accel_y_axis, DEC);
    Serial.print ("\t");
    Serial.print ("AccZ: ");
    Serial.print (accel_z_axis, DEC);
    Serial.print ("\t");
    Serial.print (z_button, DEC);
    Serial.print (" ");
    Serial.print (c_button, DEC);
    Serial.print ("\r\n");
    i++;
}
char nunchuk_decode_byte (char x)
{
    x = (x ^ 0x17) + 0x17;
    return x;
}
void muovi (){
    float tilt = (700 - outbuf[3]*2*2);
    float tilt2 = outbuf[2]*2*2;
    tilt = (tilt);
    pulseWidth = (tilt * 5) + minPulse;
    tilt2 = (tilt2-288);
    pulseWidth2 = (tilt2 * 5) + minPulse2;
    pwbuff[pwbuffpos] = pulseWidth;
    pwbuff2[pwbuffpos2] = pulseWidth2;
   
    if( ++pwbuffpos == pwbuffsize ) pwbuffpos = 0;
    if( ++pwbuffpos2 == pwbuffsize ) pwbuffpos2 = 0;

    pulseWidth=0;
    pulseWidth2=0;
    for( int p=0; p<pwbuffsize; p++ ){
        pulseWidth += pwbuff[p];
        pulseWidth2 += pwbuff2[p];
    }
    pulseWidth /= pwbuffsize;
    pulseWidth2 /= pwbuffsize;
}

solder plan

instructables update April 5

So I played around the code again and again and I got it working for the forth time. I wasnt getting my hopes up though since the other 3 times it worked, it stopped. After loading different code and reloading the working code it still worked and after powering down and back up it still worked!!! FINALLY! So Willie drew out a solder plan and I helped him solder wires to the breadboard. When it was test time....... it didnt work. We checked all the wiring and it was fine and we reset the arduino and still it didnt work. I was about to give up on this code again when Willie figured it out. When he held down the reset button and connected the wireless nunchuk before releasing the reset button it worked just fine. So, the nunchuk must be initiated before the program starts running.

With this information, its clear that I need a momentary push button switch for a reset button and a toggle switch for an on/off button. I also need something to make the doll more rigid to mount the servo.

Next step is to get the new materials I need and start puting the hardware in the doll.

instructables catch up April 3

Worked the whole class with Thomas and Willie trying to figure out the problem with the code. Nothing we tried would work and we were all feeling frustrated and miffed so we stopped for the day.

Monday, April 2, 2012

instructables update April 2

Within seconds of having it working, It just stopped. Kaiden moved one wire and now, nothing.

instructables update April 2



The code from Saturday refused to work when i tried to hook it all up to get a video. I have no idea why, nothing had changed. I tweaked the code a bit and it started working so I quickly got video footage because this thing is obviously tempermental.

blah!

obviously not..... I'll have to get a new video

instructables update March 31

I went to radio shack and picked up the connector for the battery this morning.

So, I was telling the LeBlancs, a family that is a close friend of mine, about this project friday night when I was picking up my kids from them after work. Megan, the oldest child mentioned that her dad is good with electronics and that he might be able to help. When I told him what I was trying to do, throwing out words like arduino, servo, wireless nunchuk and code, he had a blank look on his face like he had no idea what I was talking about but he agreed to try to help. On Saturday we went over to their house and I showed him the two working codes. He rigged the big remote control car battery to the breadboard for a power source for the servo so that we didnt keep draining 9 volts in minutes. After only copying a pasting a short bit of code from one to the other and changing the baud rate from 19200 to 115200, we have working code for a wireless chuk!!! I was soooooo excited!! The servo was moving soooo fast and I wanted to try to slow it down, so he changed the baud rate back to 19200 and it stopped working. We changed it back and it still wouldnt work! Why? That's all that was changed but it wont work. Why didn't I get a video???? Why? Darn!


After dinner, we got back to work. We tried all kinds of things to get it working again. We were looking at sections of each of the 2 codes, comparing them. We noticed that the read delay was different and I suggested changing the read delay to match. So we changed it from 10 to 30 and it worked!!! YES!!!!!! I got the video first thing and we didnt try to tweak code again for fear of it stopping again.

I got the video on my phone and saved it to my computer. Just tried to play it and it wont play all the way through. I dont know what happened, maybe it didnt save right but i already deleted it from my phone so I dont have a video after all. it will play a few seconds before it messes up so I will try to upload it so at least a little proof is there.




instructables update March 30

I went to the advanced auto parts store on the way to work to get a connector for the battery but they didnt have one. Going to radio shack tomorrow.

instructables catch up blog March 29

March 29th

Thanks to Thomas for giving me the code from his shoulder cam project. Now I at least have a working code for a wired nunchuk.


We, Thomas and I, also found out that one of the codes I found is a working code, it just isnt written to control a servo. I could stop here now that I have a working code, but if I am going to use a wired chuck I want to slow it down. With this code the nunchuk moves so fast and is very sensitive and jittery. I want to slow it down and I'd like to make it so that holding the c button allows you to control just the y axis and holding the Z button controls just the x axis so that you can move left and right independently from up and down. I would still rather have a wireless chuk instead of a wired one for the plan I have for this project. Since I now have a working wired and a working wireless code, if I can somehow combine the two I might get what I want.

instructables catch up blog March 22

March 22

I've been trying and trying to get the wireless nunchuk to work. I found several more versions of code, some of which are written just for the Nyco Kama chuk which is the brand I have. I've read the forum discussions on this topic and have discovered that not only is there a different code for a wired than for a wireless, but there is also a different code for each brand of wireless chuk. Luckily the main 2 brands discussed are the madcatz  and the Nyco Kama, so at least I have the right nunchuk.

After trying all these codes with no success I decided to try to at least get it working with a wired chuk because, after all, it will get the job done, just not how I'd like it. I loaded the code that Willie used in his project and tried it with a wired chuk. No luck.

instructables catch up blogs March 8

March 8th

Found out that at least the nunchuk extender cable wires are plugged in to the correct places on the arduino. I loaded up the sweep sketch from the arduino program and connected a wired nunchuk to test it since the wireless one isnt working.

instructables catch up blogs March 4th

I'm behind on posting so I'm going to post a series of entries by date of occurance to catch up to my current progress.

This is the video I got my 5 year old to help me do to show how to use the multimeter to find out which wires in the extender cable are which.


and here are some photos as well