Shop OBEX P1 Docs P2 Docs Learn Events
BS2 and Nunchuck — Parallax Forums

BS2 and Nunchuck

drakedrake Posts: 7
edited 2010-06-12 01:42 in BASIC Stamp
So about a month and a half ago I received a wiichuck breakout board for the nunchuck.

I began working on some code on my BS2 to pull data from the nunchuck but so far I have been unsuccessful.

First some known facts:
The nunchuck communicates via I2C
The nunchucks address is 0x52
to start communications you must send 0x40 0x00 to the nunchuck
data is returned in a 6 byte array
after you read data you must send 0x00 to start reading more data
BS2 does not have i2c built in but can be bit bashed via shiftin and shift out (nuts and volts #85)

What I have tried so far:
use the code from the nuts and volts to send data directly
use other versions of other peoples code modified for my needs
use a version of code that does EVERYTHING by hand (no shiftin or shift out)

Each attempt has yielded the same results
When the first packet is sent 0xa4 0x40 0x00 i get an ack from ONLY the 0xa4. the 0x40 and 0x00 nack
all the data retrieved ends up being 0xFF

Any ideas on what I can be doing wrong?
Has anyone actually interfaced a BS2 with a nunchuck?

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-06-04 14:48
    If nobody responds here there is some code for the arduino you may be able to get some ideas from.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-06-04 16:16
    I'd think the BS2 would be WAY too slow to deal with the Nunchuck. The Arduino is programmed in compiled 'C', (and I believe even supports interrupts) so would be a more appropriate solution. Somewhat more difficult to program and test than a BS2, but with much shorter reaction times.
  • drakedrake Posts: 7
    edited 2010-06-04 17:01
    The information I retrieved was from reverse engineering the example arduino code.
    Figured Id give it a whirl with the bs2 seeing that I already had it.

    The end result of this project will be a larger robot with a netbook as the brains. I wanted a uC as the processor of the sensor information seeing that the netbooks don't have serial or parallel ports.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-06-04 19:29
    The BS2p model of BASIC Stamps has I2C commands built-in. Also, are you sure of the hardware interface? Most I2C interfaces require 4.7K resistors on the SDA / SCL lines. Also, if the device is 3.3V you'd be better off using the Propeller, because 5V may damage a 3.3V device.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • drakedrake Posts: 7
    edited 2010-06-05 02:51
    the resistors were in place. The nunchuck uses 3.3v so the appropiate resistors were put in place to drop the voltage. Im assuming that because i was getting an ack that the voltage was high enough for the stamp to read.
  • metron9metron9 Posts: 1,100
    edited 2010-06-05 03:07
    Perhaps 3.3V zener diodes would do the trick? No?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • drakedrake Posts: 7
    edited 2010-06-05 14:27
    according to another source it can also accepts 5v. Tried it (while holding my breath) same result.
  • ercoerco Posts: 20,256
    edited 2010-06-05 15:21
    Wii Nunchuck on sale for $7.79, free ship today: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=230476578091

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • drakedrake Posts: 7
    edited 2010-06-07 01:11
    I took the plunge and ordered an arduino lmao. thought the day would never come
  • FranklinFranklin Posts: 4,747
    edited 2010-06-07 02:48
    You buy what works best for your project and knowledge. There should be no reason to stick with a product that does not work well in a project you are designing. Good luck.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • drakedrake Posts: 7
    edited 2010-06-10 04:27
    I think the support will be better as well. Its more redaly readible from linux which is at the bare core of the robot.
  • allanlane5allanlane5 Posts: 3,815
    edited 2010-06-10 12:42
    No, I would think the Arduino community would be much smaller than the Parallax community -- it doesn't really matter how many people support Linux, if what you want is Linux tools on Arduino.

    But whatever, give it a try.
  • drakedrake Posts: 7
    edited 2010-06-12 01:42
    I think were misreading each other. The community may be smaller but the hardware and the software are open source. It can be read, modified, and whatnot. Also if someone develops a library for the Arduino it can be used by anyone if they distribute it.

    As far as the linux support. The arduino environment is setup in java and because java is cross platform including linux its supported with the proper drivers. Also being in java its easier to access and modify what I want back from it.

    A good portion of my robot will be Java. In fact a layer of communications is already written in java. I will not be using the stamp or arduino for the main motor controllers instead I have 2 (and room for more) TI Jaguars which are in themselves microcontrollers. They have the ability to control voltage, current, speed or position in closed or open loop control modes. They also have built in limit switch and encoder readings.

    I can and probably will still use the stamp for a different part of the project. Maybe I will use the stamp to run a program to move a pair of cameras to generate a psudo 3D map.
Sign In or Register to comment.