Author Topic: How did you attach the rs232 wires?  (Read 4969 times)

0 Members and 1 Guest are viewing this topic.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
How did you attach the rs232 wires?
« on: January 30, 2012, 07:28:24 pm »
To all those who succeeded at using the dock connector for sound or rs232: What did you do that the wires don't slip out (don't know if that's the right word)?
Because I'm trying but it doesn't work.

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: How did you attach the rs232 wires?
« Reply #1 on: January 30, 2012, 10:02:49 pm »
I guess you have to sandwich the wires between the dock connector and the thing you have to press to reveal said connector.

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: How did you attach the rs232 wires?
« Reply #2 on: January 31, 2012, 02:17:22 am »
Something like that. I usually first push the protection up, place my wires and then let it go back down.
This way its stuck. You could also check Levak's home made dock system (somewhere here on the forums).

Another you can do (but I don't recommend that, is to solder to it ;D I did that with my touchpad :P
(But I'm never going to do that with my CX)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: How did you attach the rs232 wires?
« Reply #3 on: January 31, 2012, 03:14:53 am »
Sound no longer works in OS 3.1.0, though, right? (in Lua at least)

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: How did you attach the rs232 wires?
« Reply #4 on: January 31, 2012, 03:04:45 pm »
Sadly enough not. But you could easily do it with C (Ndless).
I think you could get better quality too :)

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: How did you attach the rs232 wires?
« Reply #5 on: January 31, 2012, 03:07:28 pm »
how would you get sound to only go through the TX pin, or does it already do that if you use the printf function?
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: How did you attach the rs232 wires?
« Reply #6 on: February 01, 2012, 02:37:31 pm »
Ok, now I have glued the wires to a piece of wood and I'm able to get some noise with C-programs.
But unfortunately I don't know anything about how a speaker works, and because I don't know Lua I don't understand jimbauwens' program... Can someone please explain me how this works?

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: How did you attach the rs232 wires?
« Reply #7 on: February 01, 2012, 02:46:21 pm »
a speaker is just a wire in a coil. Because a headphone output is just a current that gets sent through that wire, a magnetic field is made around the wire.
This wire is held between the two pole of a round magnet (one pole in the coil, the other one around it). This makes that the magnetic field made by the current makes the coil want to move. This coil is attached to that surfcae you can see (a thin film of plastic or something else, cone in the image). Because the coil starts moving, the film moves too, and this makes the air to move, and sound is moving air, so you hear sound.. that's it



in lua, the print() function sends data through the serial port. This data is just a current too, so you can make that current hearable by attaching a loudspeaker to it. In fact every current can be heard (unless it's DC with a continuos current, then you will only hear one click when you attach the loudspeaker)
« Last Edit: February 01, 2012, 02:49:14 pm by Nick »

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: How did you attach the rs232 wires?
« Reply #8 on: February 01, 2012, 03:03:24 pm »
So what you hear is how often the current gets interrupted?

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: How did you attach the rs232 wires?
« Reply #9 on: February 01, 2012, 05:02:52 pm »
yep, but not interrupted, it could be that the current just lowers, so the magnetic field created is less powerful, so the cone gets back a little, and then you hear noise too.. so it's not especially interrupted, but just changing

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: How did you attach the rs232 wires?
« Reply #10 on: February 02, 2012, 04:24:09 am »
Try not to focus on how the speaker works, but on sound.
Sound is a waveform, with different frequencies and some other stuff.
Our goal is to simulate a wave by output 1's and 0's since this will make the speaker move and create the wave.
But since we only got 1 and 0 we can not have a perfect smooth wave and won't have uber quality sound.
But you will have sound :)

What you need to focus on is creating the wave. You will need to know some details of the serial port in order to be able to create the frequencies you want.
The serial speed is 115200 baud, which is changes/sec. Its like bits/s, but not really.

So, how do we create our wave with 'x' Hz and playing 't' long?
First of all you need to know that Hz is cycles/second. To put this simple that means 500ms of 0's and 500ms of 1's.
Now lets first calculate how many bits we need to send to create one wave of 'x' Hz.
115200/x
That means we need 57600/x bits of 0 and 57600/x bits of 1.
Lets create some pseudo code for that
Code: [Select]
function wave(x){
  am = 57600/x;
  sendBits(0, am);
  sendBits(1, am);
}
Imagine that sendBits(bit, amount) sends 'bit' 'amount' times to the port.


Now, this is only one wave. To play it 't' long we need to repeat it x*t times
Code: [Select]
function wave(x, t){
  am = 57600/x;
  for (i=0; i<x*t;i++){
    sendBits(0, am);
    sendBits(1, am);
  }
}

But, actually we only can send bytes to the serial port.
Now its important to know that 1 byte is actually 10 because of some extra flag bits in the protocol.
Lets change the code for bytes
Code: [Select]
function wave(x, t){
  am = (57600/x)/10;
  for (i=0; i<x*t;i++){
    sendBytes(\x00, am);
    sendBytes(\xFF, am);
  }
}
I use \x00 as 0 and \xFF as 1.
Now, this should be enough to understand it (I hope) :D
« Last Edit: February 02, 2012, 04:27:14 am by jimbauwens »

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: How did you attach the rs232 wires?
« Reply #11 on: February 02, 2012, 09:18:16 am »
I'll try to implement and understand it.
Before I read this I tried it with a program that writes a byte to the port, then waits some milliseconds and repeats this again and again. With the amount of milliseconds to wait I could control the pitch.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: How did you attach the rs232 wires?
« Reply #12 on: February 02, 2012, 10:57:15 am »
You could do that too, instead of sending 0's. (Probably better quality)
I forgot you were in C :P

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: How did you attach the rs232 wires?
« Reply #13 on: February 02, 2012, 03:26:51 pm »
I understand your idea and I can implement it, but you can't make every note because there are more notes than different amounts of bytes?

Edit: Are the 2 additional flag bits you mentioned the same as the other bits?
« Last Edit: February 02, 2012, 06:09:07 pm by lkj »