trcwm / Newbaztag

New firmware for the first generation Nabaztag wifi bunny
https://www.moseleyinstruments.com
MIT License
5 stars 1 forks source link

Does it work ? #2

Open NabazNoah opened 6 years ago

NabazNoah commented 6 years ago

Hi Niels, What a great project ! Does it work with the ESP ? And if so, how did you connect it or put it all together ?

Your component list was very helpful in my search for information, trying to resurrect my own Nabaztags (version 1). After some searching (a lot of it, actually) I found these schematics on the FCC site: https://fccid.io/TYR-NABAZTAG/Schematics/schematics-630159 On that site ( fccid.io/TYR-NABAZTAG/ ) you can also find a block diagram of the internals of the rabbit. It will fill in some of the blanks in your list...

It is quite difficult to find a way to get the old Nabaztags back to (a) working condition. I am still searching for a solution. My current question is whether it is possible to resurrect them with some extra hardware of that it might be better to give it completely new internals...

Hope you will tell us more about your adventures and please let me know if I can help. Thanks for sharing your project ! Gerrit

trcwm commented 6 years ago

Hoi Gerrit,

At this time the project is very preliminary and I will work on it sporadically.

Thanks for the FCC link, I will check it out!

My aim is not to bring it back to it's old state but rather implement new functionality. It will be easier just to replace the complete firmware. I do believe that there are several variants of the Nabaztag hardware, which will complicate things. If you can take photographs of your Nabaztag's PCB, I can add them to the project for future reference. Any information you have regarding the hardware or plans/features you'd like to see are very welcome!

Regards, Niels.

NabazNoah commented 6 years ago

Hi Niels,

On second (and further) view I see the preliminariness (is that even a word ?) of your project. :)

Years ago, when my wife found me my first Nabaztag V1 (at a flea-market), they still had some functionality. You could quite easily connect them to an alternative server on the internet and get them to move their ears, light up their LEDs and make some sound.

Through the years I have collected some more V1s and also some V2s (Nabaztag:tag) and even Karotz (v3). But they have just been collecting dust on top of a cupboard, for some time now.

Recently my interest in electronics and programming has lit up again and I thought it would be nice to get them up and running again...

The old V1 Nabaztags turn out to be very difficult to even connect to from windows 10, almost impossible (so maybe your wifi card isn't even broken). With an old windows XP notebook it was easier and the settings could be changed. But after a lot of searching on the internet I found out that there are virtually no servers that have support for the V1. So I decided to try and give it a new life with some new technology.

During my search for a solution, I found your github idea and -after contemplating many different ways to get them to work- I totally agree with your decision that writing a new firmware is the best and easiest (???) solution. The old WiFi card is too old to be functional these days and the old firmware is too big and difficult to reprogram.

So I have been busy studying the last few weeks on how to program PIC microcontrollers. Pffff.. difficult stuff ! I have some experience in making things and programming them in Arduino, but this is quite a different ballgame ! Now I understand why Arduino is so popular: it's easy ! And now I understand why no one has written a new firmware for the Nabaztag before: it's a nightmare !

I have collected and assembled some documents and photos for you / the project ( see attachments).

My idea is to first write a simple, basic firmware that can light the LEDs and move the ears and then connect some basic interface, Bluetooth or Wifi to the UART port to send commands. That will be enough to begin with, and I think that will be quite a challenge for me.

Hope you can help me when I get stuck, as this is new terrain for me. I will keep you updated on my progress and share what I find out and (attempt to) program.

Thanks again for sharing your ideas and information. It gave me what I needed to get started and keep the faith that it is possible (some day). :)

Regards,

Gerrit.

Attachments:

trcwm commented 6 years ago

Hi Gerrit,

That is very useful information! I have never seen the blue PCBs. Mine looks the same as your green PCB version. The schematics will make everything so much easier!

I had figured out the ICSP port and I can confirm it also works with a PICKit II.

My initial idea was to program everything in C/C++, but I realise now that it might be beneficial to try and get something like CircuitPython, MicroPython or maybe LUA running on the Nabaztag. That way it would be easier to customize our little rabbits. What do you think?

Regards, Niels.

NabazNoah commented 6 years ago

Hi Niels,

Glad to read that the information is so useful to you, too !

We're making progress !

And thanks for the confirmation that it works with a PicKit II, good to know.

About the programming : As you know there are 2 parts to it :

The first part is programming the PIC inside the Nabaztag, which as far as I found out can only be done in Assembler, C or JAL. It does not need to be a large or complicated program (but programming the PIC is more complicated than I initially thought). I would like to be able to move the ears into certain positions, light the LEDs in different colours and maybe use the head-button for something and access all that functionality through the serial port (UART). The UART port is fast enought for that and the easiest way to connect (no soldering needed).

Regarding sound; I am not sure if the hardware is capable of incorporating that in any easy way, with the OKI chip (I don't think it can handle MP3s) And besides that I am not sure if the UART port is fast enough for handling sound. (Needs some more research)

The second part is programming the WiFi card (most probably some ESP-board) . For that it would indeed be nice if we could get some form of Python or LUA. Great idea ! It needs to connect to the network in some way and pass the commands to the PIC through the UART port (as that is the easiest way to connect them). Maybe there's some prebuilt functionality to be found somewhere, out there...

It might also be easier to connect the speaker (possibly through a small amplifier) to the Wifi board and make the ESP handle the sound (can it handle MP3s ?), but you might know more about that than I do. Any extra functionality is possibly easier to incorporate into an ESP board than into the PIC as they are easier to program (especially in Python!) and more up to date with present demands.

One more restriction to take into consideration is that the Wifi board has to work on 3.3 V, as that is the only voltage that is (easily) accessible on the PCB (from UART port or Programmer port). Other voltages are used on the PCB (8V input, 7V -for ear-motors- and 5.4V -for motor driver and amplifier-) but they are not accessible from any pins or other ports.

This would leave us with only basic functionality to program into the PIC. Can you think of any more ways we could use some of the remaining functions of the PCB (3-way-switch/ Atmel flash chip/ extra PIC functionality/ sound and amplifier) ?

It would be possible to access the second SPI port (the PIC18LF6627 has a second SPI port where the original PIC18LF6525 didn't) by soldering some wires onto the PCMCIA port, but I cannot (yet) think of ways to make that extra effort pay off ... and it would also make it much more difficult for other people to get their rabbits back to life.

These were my thoughts for now,

Regards, Gerrit

trcwm commented 6 years ago

Hi Gerrit,

I have made some progress in the programming. The following is working in a basic form:

The OKI chip cannot do MP3 and it's ADPCM format is rather weird. From the original firmware I have the impression that the PIC does not use interrupts to control the OKI or FLASH and that everything is done using polling.

The OKI chip can play MIDI using it's built-in sample set. Using the ESP to do audio is probably easier indeed. The production PCB has lots of vias or resistors where we can solder wires onto. It's very likely that we can use the internal amplifier for the audio that way.

Too bad that the PIC has <4KB of RAM. Maybe we should use the ESP for sound + scripting engine and use the PIC as a dumb controller just to do the LEDs and motors. The PIC code for that is practically done already! :)

Do you have a recommendation for an ESP board/module?

/Niels.

NabazNoah commented 6 years ago

Hi Niels, WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! WOW !!! You are a genius ! It's incredible, you already programmed basic functionality. I was still struggling with initialisation and assembler on PIC micro-controllers and you already programmed most of what we need. And in C, much more readable than assembler, and understandable, even for me :) ! I LOVE IT ! Already tried it on my Nabaztag and it works ! I have been flabbergasted all day. And too excited to think about programming... You did it ! YOU DID IT ! Still cannot believe it... THANK YOU !!! Regards, Gerrit

trcwm commented 6 years ago

Hi Gerrit,

Glad you like it :)

Yeah, PIC assembler is just awful!

There is still some work to do on the position sensing of the motors. I'm not quite sure how they did that in the original Nabaztag.

I might not bother with the flash chip unless you want to use it. For me it makes more sense to do everything on the ESP board now. Let me know what you think about this.

/Niels.

NabazNoah commented 6 years ago

Hi Niels,

What a great idea to think of the possibility to use the internal amplifier on the PCB by soldering on some wires, I did not think of that ! In the same way, we can also create a 5.4 V output, by soldering on some wires, which widens the scope of boards we can connect !

The OKI chip and it's weird ADPCM format has been a problem from the early days for many developers who tried using the Nabaztag for playing sound ... I dug up some info on it and attached the results (for your information). I still think it will be easier to use an ESP board for sound though ...

I tried to test the motor encoders for the ears and got nothing but some strange readings. But looking in the datasheet, pin RA4 is not just Digital I/O, but also Timer0 external clock input. And pin RC0 is the external clock input for Timer1/Timer3 ! So I guess Timer0 and Timer1 are used as counters for the encoders. Their logic is not apparent to me yet, but I will look into it again. I will attach the output the original firmware gave upon holding the button for more than 10 (or 15) seconds on startup. When you pushed the button after that, one ear would move and the serial port would give these readings. Pressing the button again would start the other ear (plus serial output) and the next button-push would slowly blink (dim and brighten) the LEDs.

So far, for now,so long, Gerrit

Nabaztag-ADPCM-format-links.docx Nabaztag-SerialReadOut--EARS-positions-original-NabaztagFW.docx wav2adp.zip