Segway using a Wii Nunchuk/WM+ for balance

Share your building instructions or ask questions about constructing your robot
inxt-generation
Posts: 290
Joined: 03 Oct 2011, 00:06
Location: Gallifrey
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by inxt-generation »

It seems that none of you can make up your minds... Anyways, I will be testing it soon.
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by mattallen37 »

It was a generic WM+ (because I couldn't find any on eBay that were OEM), so I suppose that could have affected it. I guess I'll need to look some more for an OEM WM+, and test with it.

The scaling math I used was as follows:

Code: Select all

Ydps = (_Y - 8340) / 13.774696296296296296296296296296;
if(!_YS){
  Ydps *= 2000;
  Ydps /=440;
}
8340 is the offset from 0 (the actual number is specific to mine), _Y is the raw Yaw value, _YS is the Yaw slow mode indicator, and Ydps is the final value returned (Yaw Degrees Per Second). This was the only equation I found on the web, and it seems to be really close to the HT Gyro. What equation did you use? and what equations did you find?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
gloomyandy
Posts: 323
Joined: 29 Sep 2010, 05:03

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by gloomyandy »

Hi Mat,
it's a long time ago. I remember seeing the values you have used but couldn't get the results from them to match the output from my HiTechnics gyro. In the end I used divide by 20 when in slow mode and divide by 5 when in fast mode. For me this values gave results that closely matched the output of the HiTechnics gyro, but it may be that this is not particularly accurate. It seems that there are at least two different chips being used in the device. One being the IDG-650:
https://docs.google.com/viewer?url=http ... -00-05.pdf
The other is an earlier version of this chip the IDG-600:
https://docs.google.com/viewer?a=v&q=ca ... 5SzIedjqKA
and this has both a different reference voltage (1.5V v 1.35V) and a different set of ranges (2000&500 v 2000&440) which may explain why I ended up using different scale factors. I must admit I didn't spend very long looking into it. The other source of information I found was for a Quad Copter project (the AeroQuad). This contains the following comment:
// Wii Motion+ has a low range and high range. Scaling is thought to be as follows:
//
// Vref = 1.35 volts
// At 0 rate, reading is approximately 8063 bits
// Scaling is then 1.35/8063, or 0.00016743 volts/bit
//
// Low Range
// 440 degrees per second at 2.7 millivolts/degree (from datasheet)
// degrees per bit = 0.00016743 / 2.7 mVolts = 0.06201166 degrees per second per bit
// = 0.00108231 radians per second per bit
// High Range
// 2000 degrees per second at 0.5 millivolts/degree (from datasheet)
// degrees per bit = 0.00016743 / 0.5 mVolts = 0.33486295 degrees per second per bit
// = 0.00584446 radians per second per bit

Note however that there seems to be an error in the above in that the low range sensitivity should be 2.27 millivolts/degree (at least that is what the data sheet says).


On thing that is interesting from your earlier results is that the IMU seems to give different results to the other two devices. I wonder which one is correct?
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by mattallen37 »

Hmm, interesting.

I want to build a controlled turn-table to measure DPS, and figure out what is actually correct. I would use one NXT connected to the gyros, that is data-logging. The other NXT would be running the turn-table at a very specific speed. I just haven't had time yet.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by hassenplug »

inxt-generation wrote:It seems that none of you can make up your minds... Anyways, I will be testing it soon.
I think I've been consistent. You can't use an acceleration to measure dynamic tilt, only static tilt. You can use a gyro to measure rotation (such as that of a falling-balancing robot)

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
inxt-generation
Posts: 290
Joined: 03 Oct 2011, 00:06
Location: Gallifrey
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by inxt-generation »

I meant about the WM+ working or not working.
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by hassenplug »

inxt-generation wrote:I meant about the WM+ working or not working.
The "plus" should work. It has gyros. JUST a Wii remote would not.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by mattallen37 »

So I have an update. I was able to buy an official WM+, and after adding pullup resistors, it works perfectly. I tested it with the generic WM+, dIMU, and HT Gyro. It turns out that the official WM+ indeed does not have the lag issues that I experienced with the generic one.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
hergipotter
Posts: 48
Joined: 12 Jan 2011, 18:40
Contact:

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by hergipotter »

Last week i built a segway using a nunchuk (for accelerationdata) and a WM+ (for gyrodata) but i've come across two problems.

First, it seems to take about 40ms to read the nunchuk and gyro. That seems too much imo. I can't get the robot to balance perfectly, it just reacts to slowly. It's always the same 40ms, no matter if i use my own code or Matt's NXTchuck lib.

Then, sometimes, my WM+ isnt working. Reading data then doesn't work, i get zero bytes. I can't reproduce the error, it seems to be quite random. But when it works one time then it works for some more...
Are my pull-ups to small? I used 27k ones.

Any ideas? :D
link to my youtube channel under my avatar!
mspall
Posts: 15
Joined: 31 Oct 2011, 19:29

Re: Segway using a Wii Nunchuk/WM+ for balance

Post by mspall »

Reading this:
http://www.sparkfun.com/tutorials/218
I would say trying different pull-ups could be good idea. You might consider trying smaller, 10kOhm
The general rule for condition 2 is to use a pull-up resistor (R1) that is an order of magnitude (1/10th) less than the input impedance (R2) of the input pin. An input pin on a microcontroller has an impedance that varies around 100k-1MOhm. For this discussion, impedance is just a fancy way of saying resistance and is represented by R2 in the picture above. So, when the button is not pressed, a very small amount of current flows from VCC through R1 and into the input pin. The pull-up resistor R1 and input pin impedance R2 divides the voltage, and this voltage needs to be high enough for the input pin to read a high state.
Another thing to point out is that the larger the resistance for the pull-up, the slower the pin is to respond to voltage changes. This is because the system that feeds the input pin is essentially a capacitor coupled with the pull-up resistor, thus forming a RC filter. And RC filters take some time to charge and discharge. If you have a really fast changing signal (like USB), a large pull-up can limit the speed at which the pin can reliably change state.
Although the expert, mattallen37, did this:
https://sourceforge.net/apps/phpbb/mind ... =wii#p5832
I bought two non-OEM nunchucks to try to interface with the NXT. However, so for no go. I removed the pullups, and have 47k pullups (on the NXT end of the cable). I also have diodes to drop the voltage (Xander, I measured before connecting this one :P). I am trying to get this program to work:
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest