Omnimaga
Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: Vogtinator on February 28, 2013, 02:26:08 pm
-
WARNING: Two people destroyed their touchpads by accidentially shorting some pins, so be VERY careful!
Read the thread here (http://ourl.ca/18458)
Some days ago I found out (with diags) there are some GPIOs connected to the dock connector.
We also have one relatively fast timer we could use for pwm and one for loading new data from the buffer, so here ya go:
Dock connector (connected to pins 5 + 6):
(http://i.imgur.com/Hz5Uf8Cl.jpg)
There are still a few bugs/improvements that need to be done:
-Only 10 kHz sampling rate, more is possible
-Crashes on exit
-Loads file twice
-Max file size 2000000 Bytes (2MB)
-Only works on CX
-Only loads "/documents/ndless/monsta.raw.tns" for now
-Haven't got a name, any suggestions?
I'll publish the source code after it works completely.
Possible features:
-WAV loading
-Volume control
-Stereo :-)
BTW: Don't plug your speaker in before "Playing!" or you'll short 3,6 V (While playing, you only short ~1,8V)! Unplug them before exiting, the GPIO becomes high on reset! Don't use your amplifier, you may blow it!
Edit: Updated video
Newest version: here (http://ourl.ca/18438/340399)
-
WOW this is freaking amazing! O_O Even at 10kHz that sound sounded... soundtastic. I do wonder, why no rickroll :P
-
Very nice hack :D
-
BTW: Don't plug your speaker in before "Playing!" or you'll short 3,6 V (While playing, you only short ~1,8V)! Unplug them before exiting, the GPIO becomes high on reset! Don't use your amplifier, you may blow it!
Do you know how the GPIO port is driven? If it uses a pull-up resistor (this is what all the TI-8x and TI-9x calculators use in their link port hardware), shorting the port to ground will not harm the calculator (the pull-up resistor is between the 3.6V source and the GPIO pin).
-
Nope, I don't. I haven't got the right screwdriver, but if it really uses a pull-up, it'd be great!
BTW: I'll make a new video tomorrow, this one isn't the greatest.
-
Very glad to see there is finally an audio solution for Ndless programs and some progress on the TI-Nspire Dock Connector! :)
And very glad to see that somebody has allready updated Hackspire:
http://hackspire.unsads.com/wiki/index.php/Hardware#Connector_J01_-_Dock_connector
Let's go on: we still have a little more than 20 pins to identify! ;)
-
And very glad to see that somebody has allready updated Hackspire:
That somebody was me, some days ago :D
Let's go on: we still have a little more than 20 pins to identify!
The long pins are GND, now we only have 19 more D: (3 of them SPI, 8(?, don't remember exactly) GPIOs)
They shouldn't be a problem with diags and SLED tests
-
Awesome! Make it for clickpads too :D.
PS: Can you please update hackspire ( http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#90000000_-_General_Purpose_I.2FO_.28GPIO.29 ) ? (not now, but when you think you've found enough and have some time :) ).
-
Nope, I don't. I haven't got the right screwdriver, but if it really uses a pull-up, it'd be great!
Sorry, I didn't mean to imply that there would be a visible, discrete resistor on the board. More likely than not the pull-up resistor (if there is one) is inside an ASIC that controls the GPIO hardware, so you wouldn't be able to see it without an electron microscope or something. :)
-
Awesome
Though I had problems when I just tried it
First. I did not solder, I just used scotch tape, and I may not have done it correctly (I did red wire 6 from the left, and the black wire of my speakers 5 from the left), nor do I know if I took apart my speakers very well. And one of the wires was thin
Also, I took a random song, changed it to 10 seconds long, used a converter to change it to .raw (where do you find those?) then saved as the monsta file
Anyway, I ran it and got a bunch of fuzz and high pitch sounds, instead of classical accordion
So I got something, which is good
(Also, was that Peter Fox? He is one of the few german singers I have listened to, so idk)
-
Okay update on the problem. I got a rough form of the audio to play, but it still has way to much squeaky sound to be good. I used this (http://www.nch.com.au/switch/index.html) to convert it, and converted an mp3 to a mono 8000 raw file
It still is fuzzy and squeaky though, so I don’t know if it is my file or my speaker.
-
I used audacity, change project rate to 10000 (after import), convert it to mono
and export it as raw data (unsigned 8-bit pcm).
-
/me wonders if this could be used in games
/me thinks VVVVVV
-
PWM only uses 60 cpu cycles every pwm cycle (128 kHz) so you can still use 124 MHz.
-
Needs more amp.
-
I used audacity, change project rate to 10000 (after import), convert it to mono
and export it as raw data (unsigned 8-bit pcm).
I did that and it is much better, though it is really slow for some reason, even with nover
-
even with nover
With nover you can only decrease the pwm speed. I don't know how (and whether) you can change the speed of the second timer (~31 kHz) which is used for setting the pwm output value.
-
Though mine is very slow, like 50%-80%, and vocals sound ridiculous, while your's seem just fine
-
Is the length reported correct? It should be the exact (rounded) duration in seconds
-
We have to add sound support in gbcnspire, gpSP and nDoom ! ;)
Except that I'll probably won't have any time to work on nDoom in the next few months.
-
We have to add sound support in gbcnspire, gpSP and nDoom ! ;)
Except that I'll probably won't have any time to work on nDoom in the next few months.
And nspire movie player most of all!
Is the length reported correct? It should be the exact (rounded) duration in seconds
It is 181s for 2000000 bytes, like yours was, because I accidentally went over
It is slow, and I think the scratchy noise just might be my bad speakers.
But I send the mp3 files to audacity change it to 8000, export it as Other compressed files with Raw (header-less) and unsigned 8 bit PCM selected in the options
Maybe you could post one of your files for me to see?
-
But I send the mp3 files to audacity change it to 8000,
8000, that should be too fast ???. 10000 is correct (you can type in any value you want)
Maybe you could post one of your files for me to see?
If it doesn't work with this version, I'll post some free stuff here.
We have to add sound support in gbcnspire, gpSP and nDoom ! ;)
Except that I'll probably won't have any time to work on nDoom in the next few months.
And nspire movie player most of all!
All of them :) But I think it might get a bit complicated with tone generation :-\
I made a newer version, resolved some bugs and copied nTxt/hoffa's file browser:
-24000 samples per seconds (second timer is only 24 kHz >:( )
-Doesn't crash anymore
-Loads file only once (Limit is now at 5 MB)
-Works with ndless.cfg.tns
-Source code (Not very well commented - yet :-[ )
16 bit pwm is not possible, 500 Hz is a bit too slow >:(
A higher samplerate would only be possible with a lower pwm frequency as I would have to abuse the fiq handler for pwm, but I think we don't need 64000 samples per second ::)
I also made a few tests with nover, it plays fine (even at the right speed) with 162/81/40 MHz.. Does the second timer have a seperate clock source?
-
Thank you
This is much faster, but for some reason this still isn’t fast enough for vocals.
I also like that I don’t have to keep changing the name of the file to monsta.raw.tns :)
-
Wow, that is looking pretty awesome!
And *yay* german :D/me isn't alone anymore
I just like how much stuff is made for the nspire, that makes me wish I had one >.<
-
This is much faster, but for some reason this still isn’t fast enough for vocals.
Whoops, now I see.. :banghead: It's really just 16000, I swapped the files.. sorry :-[
16000 is indeed a bit low, I'll search for a better way to load it (Fast timer No.2 maybe?)
And *yay* german
* Sorunome isn't alone anymore
Ich bin hier doch schon 'ne ganze Weile xD
I just like how much stuff is made for the nspire, that makes me wish I had one >.<
Wishing alone doesn't work (except for christmas), you may have to buy one :P
Edit:
Newer version:
-WAV support (mono, 8-bit pcm)
-samplerate up to 33 MHz xD
-fixed small bug with GPIOs
-Max file size = free ram
-
Okay, I went to audacity selected stereo to mono, changed it to 10000 saved it as other compressed file, unsigned 8 bit wav, and sent it to my calculator.
The player just stays at zero seconds now, and doesn't play the song.
And *yay* german
* Sorunome isn't alone anymore
Ich bin hier doch schon 'ne ganze Weile xD
Und ich spreche kleine Deutsch :)
-
Okay, I went to audacity selected stereo to mono, changed it to 10000 saved it as other compressed file, unsigned 8 bit wav, and sent it to my calculator.
The player just stays at zero seconds now.
Hmm, theres a bug: You have to start it twice after rebooting..
-
When I do that it still stays at 0 seconds, but I get a constant buzz sound.
-
Strange, does escape still work?
I made a reset on my calc, opened a wav in pwmtest, pressed escape, opened it again an it plays as it should.
-
Escape works, but what you said doesn’t work.
-
Ok, it seems to not work with 10000, could you try it with 32000? I'll try to find the bug :D
Edit: Found: Try to delete the author, title, track information.. My wav decoder tries to interpret it as the file length
-
How would I delete those things?
-
Audacity should ask you after the file save dialog. There's a delete (or remove or similiar) button on the bottom right
Edit: Bug resolved
-
Whooo!
Thank you!
It is the correct speed!
-
Great! BTW: Try it with 32000 nevertheless, it sounds SO MUCH better ;)
-
What does that new file do? Does it just bypass the titles and such? I haven't yet tried it.
-
yes, it jumps over every chunk until it finds "data".
-
Though just wondering, would it be possible to change the volume coming out? Because I connected a headphone jack and my headphones, and it is way to loud
-
Though just wonderinjg, would it be possible to change the volume coming out? Because I connected a headphone jack and my headphones, and it is way to loud
Yes, by making the pwm off period longer. I'll try it and upload when ready :)
Edit: Nope, pwm gets too slow if too quiet.. You can hear it as a high-pitch squarewave then (annoying as hell)
-
This seems very cool. :) What would be great in the future is an USB mode (for those who got USB speakers with a mini-USB adapter) since it would be easier to do the connections and might prevent some calculator horror stories (http://ourl.ca/18458).
-
How did you discover this? (How do things like this even get discovered in the first place.) I've alwasy wanted to mess around with my nspire to do stuff like this, but never had (and still have) no clue how or where to start.
-
How did you discover this?
From the first post:
Some days ago I found out (with diags) there are some GPIOs connected to the dock connector.
Running, and then disassembling, diags software :)
-
Running, and then disassembling, diags software :)
Only running :)
I curiously explored the menus and tried to touch the ports on the back and noticed it recognized my fingers. There is MOSI, MISO, too (SPI).
Somewhere there's even SD-Cart support (D0, D1, D2, GND?)
-
How do you generate the PWM signal? Do you just set the output high or low at each clock interrupt, and what is the clock rate of that interrupt?
I'm just wondering if you could alternate the output signal (pulses) more frequently, as in multiple times per WAV sample, in order to push the pulses into the inaudible frequency range, or at least into a range that can be filtered out with a low-pass filter. I would think that this can be done fairly easily with delta-sigma modulation (http://en.wikipedia.org/wiki/Pulse-density_modulation#Algorithm).
-
Wait, to what extent is the SD support useful?
-
Everytime the (fast)timer fires an fiq, I toggle gpio 4 and set the timer value.
For instance, if pwm=40, I set the timer to 40, after toggling I set the timer to (256-40).
So I get a pwm freq of about 33000000/256 Hz, but for whatever reason I have to shift the timef value one left. If pwm is updated while the gpio is on, the off period is already computed with the new value, so it should atleast feel faster :)
SD card support might be good for nspire-linux, the usb port is slow as hell.
-
Just wondered... wouldn't it be possible to have a stereo-signal coming out? As far as I know there are other pins at the dock-connector that could be used for something like that.
-
Yes it would be possible, but we only have two 33 MHz timers (for pwm), we would have to use the 33 kHz timer as sample update.
That would mean wav loading is impossible (if they're not 33kHz) or it'd sound weird. Mono is noisy enough (8 bit).
But one thing is interesting, with some resistors and two GPIOs it's possible to do 16 bit pwm, but that would destroy the simplicity :-/
-
Isn't it possible to set the pwm-values for both the left and the right channel using the same timer, thereby enabling wav-loading even though it's stereo (by using the faster timer)?
-
How would you do that? You're only able to execute 132/33=4 cpu cycles each timer interrupt (and the JMP already needs 5)
-
Too bad; using the same timer for both channels apparently isn't a solution. :(
-
Exactly, the calc is too slow..
But it would work on the older (non-cx) models, they actually have 6 33MHz timers Second timer (http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#900D0000_-_Second_timer), but I don't have one :-(
-
I have a Ti-nspire CAS non-CX.I try to modify your code to make it work on my Ti-nspire.But It always resets when it registers FIQ handler.
-
If you posted the changes you made it would probably help. Also which OS are you running ?
-
I just deleted the part to check OS.It doesn't works on 3.1 or 3.6.
-
The non-cx hardware is entirely different, so you'd need to rewrite the asm code and the timer setup code in audio.c almost completely.
It shouldn't be too hard, though, as only the bit positions, register layout and clock speeds changed.
-
It's too hard to me to rewrite the asm code.I even don't know its meaning.Could you help me?
-
When i delete asm code in interrupt.c it has some problem,but it doesn't reset again.
-
Don't double post, the "edit" button has a meaning ;)
It's too hard to me to rewrite the asm code.I even don't know its meaning.Could you help me?
I literally commented every instruction.. Except for some basic blocks. BTW: You can replace the "unaligned read at r9" by a simple "ldrb r9, [r9]".
But you definitely need to understand it well enough to make such a rewrite.
When i delete asm code in interrupt.c it has some problem,but it doesn't reset again.
Which asm code in interrupt.c?
-
I try to modify memory-mapped in interrupt.c.Then there is not error in log window.But it still resets. :banghead:
-
Without your changes nobody can help you..
-
How to set the timer to 32bit?
http://hackspire.unsads.com/wiki/index.php/Memory-mapped_I/O_ports#900D0000_-_Second_timer
It says Set to 32 by the OS.but how?
-
It doesn't mean 32bit, it means that the timer load value is "32".
You can simply write it to the port (32 bit write)
-
Vogtinator,
I am fairly new to programming , and the only languages that I've had experience with are Java and the Arduino's language. I managed to make a capacitive-sensor piano with the Arduino, but it is rather clunky. I realized that the Ti-inspire calculator already has a built-in keypad and that I might be able to play tones with the nspire. I was wondering if you have any directions, tips, or references that would help me with this project. Also, should I be using Assembly or Lua? I would also like to mention that in the future, I would like to add a synthesizer as well, where I might be able to use waveform equations to creates the timbre and/or the ability to draw the wave. Any information that you could give me would be helpful!
Sincerely,
InvX
-
Hi InvX,
"pwmtest" is written in ARM assembler and C ("the Arduino's language"), so you have to learn them to fully understand and work with pwmtest.
You have to setup your calc as usual (solder to a dock pin or connect to it in a different way) before you can try pwmtest.
There is a fairly high-level API exposed by audio.c you can use to play your synthesized tones.
-
Thanks, this helps me out a lot! ;D
One more thing; would it be possible to remove the static from the audio? Maybe with some kind of low-pass filter?
-
One more thing; would it be possible to remove the static from the audio? Maybe with some kind of low-pass filter?
Some part of it, yes. It only has 8 bit resolution (I tried 9 and even 10 bit, didn't work out well) so you won't get rid of the resulting inaccuracies.
-
Where do your common.h and os.h libraries come from?
-
common.h and os.h used to be in the SDK. After the Newlib transition, they are no longer used, although there is an os.h for compatibility. You'll have to figure out what to replace them with, I personally haven't looked at this code.
-
Awesome!
A suggestion. You might want to use a capacitor to couple the audio from the pin. Then, a low impedance load won't adversely affect the calculators' operation.
Try a 0.1 uf ceramic capacitor. 50 volt rating is fine. You can use a poly cap too.
The signal might be low, but a small amp (LM386) would bring the level up and allow you to drive a speaker.
I hope this helps.