Dserial 3axis gyroscope control

Post Reply
Posts: 5
Joined: Thu Jul 09, 2009 6:15 pm

Dserial 3axis gyroscope control

Post by Arnaud » Wed Jul 22, 2009 1:25 am

Hello guys,
I am trying to gather 3 axes gyroscope information from a Wii motion plus, via the Dserial².

But this little device works with I²C synchronous communication.

thus, the wii motion plus has 4 wires to connect: - 3.3V
- Ground
- Clock
- Data

The ground and 3.3V connection on the Dserial are obvious, and I was thinking of an UART pin to read the data from the gyro (do you think the fact that I²C is synchronous can cause me problems? ).

My main problem is the clock, how can I connect the wii motion plus to the Dserial clock?
I saw that Dserial² Microcontroller is working at 24 MHz, but on the wiring diagram of the Dserial², the DS clock (which is 33MHz) is connected to the MCU pin 2.
Can I just get a wire from pin 2 of DS card slot to the wii motion +, or can I program a GPIO pin to give me the Dserial² clock?

A similar project has been done using an arduino to read info from the wii motion plus, I am convinced that Dserial can do it too, then send it to a computer via Wifi, and that's it, the DS becoming a 5axis tracker for unmanned ground applications. But let's focus on the basics, the rest is 100% software.

Some help would be appreciated here. Sorry for my poor English, and Thanks in advance for your help.

Posts: 5
Joined: Thu Jul 09, 2009 6:15 pm

Re: Dserial 3axis gyroscope control

Post by Arnaud » Tue Aug 04, 2009 9:37 am

Little update here :)

Since I don't have a Wii motion plus yet, I did my experiments with a nintendo nunchuck which is the same to interface.

I've been browsing the internet for some solutions to my problem and I found out a method called bit-banging to implement I²C on a 8051 through 2 GPIO lines.

So I made a code that drives SCL and SDA lines high and low to emulate I²C protocol.
I managed to recover some data from the nunchuck, but it was not "stable" at all, like if it was not exactly synchronized. I couldn't use efficiently this data and I couldn't have this code to work properly.

Then, looking for some other method, I read the datasheet of the Dserial MCU and I noticed that it has built-in SMBus support so I decided that it would be way better to do the job.

I am using pins 0.6 for data line and 0.7 for clock line. The Dserial is the only master, and the nunchuck is the only slave.

I used the Silab config tool like I read on the forum, I figured how to skip pins and enable SMB on lines 0.6 & 0.7 but the program generates me a source code and I don't know what to do with it. What am I supposed to do with this code?
I guess I'll have to copy it to firmware.c , compile my own firmware and "install" it on the Dserial, but I'm not sure, I'm a little bit lost with this, am I right?

When the pins will be set the right way (in the firmware i guess), do I need to enable SMB in the XBR0 register in my program source code?

I have another little question:
As a test I tried to use the dseWriteRegister function to write the 0000 0100 byte in the 0xE1 register (XBR0 address to enable SMBus), and print this register right away with dseReadRegister, but the register value is 0, even after the WriteRegister.

Why am I unable to write in this register?

So here I am, trying to figure how to interface the DS and my nunchuck.

I am stuck and this project means a lot for me, I really don't want to have to give up :( .

I would be very (very) grateful if someone could explain me step by step instructions to follow in order to set up an I²C communication with Dserial.

Thanks a lot for reading me.


Posts: 5
Joined: Thu Jul 09, 2009 6:15 pm

Re: Dserial 3axis gyroscope control

Post by Arnaud » Sat Sep 05, 2009 8:54 pm

I'm still stuck with my project, please Natrium help me with this :/

User avatar
Posts: 3
Joined: Mon Jul 20, 2009 11:41 am

Re: Dserial 3axis gyroscope control

Post by karagh » Sun Sep 06, 2009 11:23 pm

I haven't worked i2c on 8051, but I did on PIC.

Probably you don't really need to update the firmware in DSerial, you can use DS-only code for the output pin big-banging. I'm almost sure the DSerial can do the job. A really common problem while working with i2c is clock generation, use the slower speed (10kbps) if possible (check on the Wiimote information). It can be generated by the microprocessor easily. Maybe that's the problem with your software bus code. If you have access to a oscilloscope check it in circuit too.

About the register write problem, probably that one is not implemented in the current firmware, and only a few registers are available. Check registers.c line 99, direction 0xE1, is commented and the firmware won't write to it. Uncomenting it and recompiling should do it. Natrium's help about this is recommended.

The SMBus method is truly the way to go, but then you'll need to write a new firmware. I haven't done it yet, so I can't help you a lot here, but:
1. Don't use silab's tool generated code. Try to understand it and adapt it to the firmware provided in the example file.
2. Compile it with Silab's tool or sdcc. And add it to your devkitpro project.
3. Get sure you don't overwrite the bootloader. This is really important. If you break the bootloader, you'll have a hard time to get your DSerial running again. You can check it comparing bytes before 0x800 in the provided firmware and your own firmware. It shouldn't happen, because it's defined in the firmware source code, but...
4. Run your software, and update the firmware.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests