Omnimaga

General Discussion => Technology and Development => Other => Topic started by: MGOS on December 04, 2013, 09:23:33 am

Title: Calc + TV remote = ???
Post by: MGOS on December 04, 2013, 09:23:33 am
I was working an a completely different project, an infrared light barrier for outside and I needed some way to filter out the IR light of the LED from the sunlight. A common way to do this is modulation. Instead of just having a LED constantly on, you flash it really fast, e.g. with 33 kHz. The receiver filters out all other frequencies and gives a steady signal. We had a TSOP31233 (datasheet (http://pdf1.alldatasheet.com/datasheet-pdf/view/252280/VISHAY/TSOP31233.html)) lying around. This one connects the output pin over a transistor to ground when a 33 kHz signal is applied. The modulation worked fantastically, but the receiver is that sensitive that you cannot simply block the light with a simply object, you have to completely cover the receiver with a black box. That isn't really surprising, since those receivers where made for IR control systems and have to work under every condition. So I took the TV remote and looked what I can get out of it. Strangely enough it works with the same frequency, and it also uses a really simple protocol.

Schematic:
(http://www.mirari.fr/IFa6)
As you can see, there are no other electronic components needed!

I hooked up the sensor to my trusty 83+ and made a simple program that plots the state of the sensor over time. I figured out that the protocol starts with a rather long HIGH pulse, then a short LOW. The bits are coded in the length of the HIGH pulses (long pulse = 1, short one = 0), the LOW pulses are all the same time; the LSB arrives first, then a sequence of up to 15 bits. On this Sony remote, newer functions have more bits (such as enable surround sound or the Bravia sync system) where as functions that have been there forever (numbers, volume, power) have only 8 bits. I figured I only need the lower 8 bits so the following code ignores the upper bits. The program is written in pure Axe:
Code: [Select]
Lbl READ
While 1
EndIf port    //wait for the start bit to end
For(r1,0,7)
  If EAT()  //return if Stop bit reached or abort
    Goto END
  End
  GET()->{L1+r1}   //buffer the input
End
Lbl END
0->r2     //result
For(r1,0,7)
  r2*2->r2   //shift left
  {7-r1+L1}+r2->r2   //reverse and "or" together
End
r2
Return

Lbl EAT   //"eats" the Low state
For(r3,0,100)
  For(20):End  //some delay
End!If port  //wait until HIGH again
r3>100  // time out exceeded = Stop bit
Return

Lbl GET   //measures the length of a HIGH pulse and returns the result as a bit
For(r3,0,100)
  For(25):End
EndIf port   //wait until LOW again
r3 > 8    //8 seemed to be the threshold that worked best
Return

You can now write programs which use this function. For example move a sprite around the screen:
Code: [Select]
[3C7EFFFFFFFF7E3C]->Pic1
FnOff  //disable the nasty OS interrupts
44->X
28->Y
While 1
  !If port   //check for a keypress
    READ()->K
    K-244??Y--   //up
    K-245??Y++   //down
    K-180??X--   //left
    K-179??X++   //right
    Pt-On(X,Y,Pic1)
    DispGraphClrDraw
  End
EndIf getKey(15)
LnReg   //turn interrupts back on
Return

--- Subroutines from above ---

The video is probably the thing you are interested in the most:



Currently it works at around 10 key presses per second and I haven't got much hope that this will increase, since the speed is defined by the remote control, so I guess real time games are quite hard to accomplish.



Going further

What I have shown you is only a proof of concept. You can include remote control to any Axe or Asm program.

What you then could do is place the routine into a link port hook (IIRC there is one to transmit programs "silently") which enables when a key code is incoming. The code is then translated to "real" TI 83+ keycodes via a LUT and then given to the OS as a regular keypress - making it possible to enter your calculations with a freakin' TV remote....

The question one might ask is "What's the point of this?".
I'll ask instead:
Where will this lead?
Title: Re: Calc + TV remote = ???
Post by: Keoni29 on December 04, 2013, 10:32:04 am
Cool that you were able to interface that IC with the calculator. I have never heard of it before. Maybe you can use this for things like a wireless link to a laptop or phone.
Title: Re: Calc + TV remote = ???
Post by: ClrDraw on December 04, 2013, 10:55:45 am
WOAH DOOD  *.* How do I build this???
Title: Re: Calc + TV remote = ???
Post by: MGOS on December 04, 2013, 11:22:05 am
WOAH DOOD  *.* How do I build this???
The receivers cost about a dollar each and a 2.5 mm jack everyone has lying around somewhere - and that's all you need.

I just wanted to show that it can be done, and probably adapted easily to work with any TV remote.

Maybe you can use this for things like a wireless link to a laptop or phone.
Probably not, since those types of communication are two-way. But If you invent your own one-way protocol, it might work.
I might try to add an IR LED to send something, but I think I will have trouble to get a frequency that high. 33 kHz is quite a lot for a 6 MHz *damn inefficient* z80.
Title: Re: Calc + TV remote = ???
Post by: Juju on December 04, 2013, 11:24:17 am
That's cool :D
Title: Re: Calc + TV remote = ???
Post by: Streetwalrus on December 04, 2013, 11:31:41 am
The OP explains how to do it. You just need a bit of experience with electronics, but really not much. That said, it quite a nice find here. :D If you add an emitter to it you can make an universal remote control. :D A small circuit can do the modulation for the calc.
Edit : ninja'd
Title: Re: Calc + TV remote = ???
Post by: MGOS on December 04, 2013, 11:41:06 am
If you add an emitter to it you can make an universal remote control. :D A small circuit can do the modulation for the calc.

That's a nice idea - you could then program each key by recording the sequence with the receiver.
I don't really want to use another circuit to do modulation - when you use e.g. an ATtiny (which I love by the way!) everything is possible and often much simpler. But the beauty of this project is, that it doesn't use any other hardware than the receiver, which is only one little IC with three leads.

When you let the micro controller do all the work for you you don't even need to program the calc anymore, since the OS has already a key emulation function built in!
Title: Re: Calc + TV remote = ???
Post by: Juju on December 04, 2013, 01:42:12 pm
That's a good idea, you could effectively create a TI-Keyboard with a TV remote.
Title: Re: Calc + TV remote = ???
Post by: willrandship on December 04, 2013, 01:51:38 pm
MGOS, 33 KHz isn't that fast for a 6 MHz processor. You can do port writes at least 1 MHz, assuming you have what you need to transmit.
Title: Re: Calc + TV remote = ???
Post by: Keoni29 on December 04, 2013, 02:11:36 pm
The IC demodulates the data, so it´s not 33kHz anymore. It´s just the carrier that is 33kHz.
Title: Re: Calc + TV remote = ???
Post by: MGOS on December 04, 2013, 02:15:15 pm
MGOS, 33 KHz isn't that fast for a 6 MHz processor. You can do port writes at least 1 MHz, assuming you have what you need to transmit.
Yeah, I misestimated... 33 kHz should work, but 1 MHz isn't doable for the z80: OUT(C),r takes 12 T states, meaning at 6 MHz you can achieve at maximum 500 kHz by putting dozens of OUT instructions after each other - and you need to divide that by two to make up a whole period (high -> low -> high). Having a loop and a nice ending condition and a duty cycle of 10% (which is better than 50% for these applications) you probably come close to the limits even in straight asm.

The IC demodulates the data, so it´s not 33kHz anymore. It´s just the carrier that is 33kHz.
For the receiver yes, but were talking about a sending LED here!
Title: Re: Calc + TV remote = ???
Post by: Keoni29 on December 04, 2013, 03:13:23 pm
Oh I see. Well there are transceiver modules available.
Title: Re: Calc + TV remote = ???
Post by: Sorunome on December 04, 2013, 04:08:41 pm
What is this dark magic? O.O
Title: Re: Calc + TV remote = ???
Post by: willrandship on December 04, 2013, 05:08:37 pm
Sorry, assumed for some reason that the z80 in the calcs is modern (silly idea) and had the better cycle rates. Then I remembered I was basing my guess on ez8/ez80 datasheets. :P
Title: Re: Calc + TV remote = ???
Post by: Spenceboy98 on December 04, 2013, 08:52:20 pm
When I read the title, I expected you to have made a remote out of a calc by creating some sort of plug attachment. But this is cool too. :)
Title: Re: Calc + TV remote = ???
Post by: ClrDraw on December 05, 2013, 10:46:08 am
True me too. That would be awesome  XD I would so prank people with that!
Title: Re: Calc + TV remote = ???
Post by: Dapianokid on December 05, 2013, 05:44:47 pm
I can see this being somewhat fun to tinker with using a Ti-83+, but why don't we just use a Casio Prizm or a TI Nspire and find out something epic to use this for?
Title: Re: Calc + TV remote = ???
Post by: willrandship on December 06, 2013, 12:03:29 am
If you want something epic to use it for, why not a proper computer? It's not as if the nspire isn't also an extremely limited platform.

Edit: \sarcasm
Title: Re: Calc + TV remote = ???
Post by: MGOS on December 06, 2013, 01:01:35 am
I only have an 83+, that's why I only post these projects for this platform. And isn't it the tinkering with a limited platform what we enjoy and doesn't the fun come from the challenge?
Title: Re: Calc + TV remote = ???
Post by: willrandship on December 06, 2013, 01:06:56 am
That was my point, yes. If we really wanted to do these kinds of projects in a practical way, there are much better alternatives. Working with the resources we have on hand is part of the challenge, in my opinion.
Title: Re: Calc + TV remote = ???
Post by: Hexatron on December 06, 2013, 01:29:38 am
Woah, cool!
Now you got me thinking about a calculator controlled microwave
*Hexatron runs
Title: Re: Calc + TV remote = ???
Post by: willrandship on December 06, 2013, 01:32:32 am
That's totally feasible. Just get a few relays, or rip the controls out of an existing microwave.
Title: Re: Calc + TV remote = ???
Post by: TIfanx1999 on December 06, 2013, 09:26:02 am
When I read the title, I expected you to have made a remote out of a calc by creating some sort of plug attachment. But this is cool too. :)

This is what I expected as well. However, I have to say that I was not disappointed. This is quite awesome! :D
Title: Re: Calc + TV remote = ???
Post by: ClrDraw on December 06, 2013, 10:45:52 am
Quote
Now you got me thinking about a calculator controlled microwave

Code: [Select]
:.MICROPRGM
:Full
:GetCalc("foodCheesburger",Y1)
:GetCalc("applianceMicrowave",Y2)
:Send(Y1,Y2,{Y1-2}r)
:setTime(30)
:"seconds"->TInterval
:startTmr

lol  XD
Title: Re: Calc + TV remote = ???
Post by: MGOS on December 06, 2013, 11:42:40 am
Now you got me thinking about a calculator controlled microwave
*Hexatron runs
I'd love that! :D


I was actually thinking of something more versatile, kinda an Axe-to-Arduino interface - giving you all the major Arduino functions (pinMode, digitalRead/Write, analogRead/Write, Serial interface, etc) in the axiom and a slave program running on the arduino/atmega/attiny. Maybe that will lead more people to include their calc into their hardware hacking projects and create more awesomeness :)
Title: Re: Calc + TV remote = ???
Post by: Dapianokid on December 06, 2013, 06:07:37 pm
I like the idea of extremely limited platforms being used for complicated tasks. Forget the Nspire idea.
I think I'm going to use this to communicate with somebody else accross a room via calc. :P
Title: Re: Calc + TV remote = ???
Post by: Streetwalrus on December 09, 2013, 01:45:25 pm
Now you got me thinking about a calculator controlled microwave
*Hexatron runs
I'd love that! :D


I was actually thinking of something more versatile, kinda an Axe-to-Arduino interface - giving you all the major Arduino functions (pinMode, digitalRead/Write, analogRead/Write, Serial interface, etc) in the axiom and a slave program running on the arduino/atmega/attiny. Maybe that will lead more people to include their calc into their hardware hacking projects and create more awesomeness :)
Well, Keoni29 made a linking protocol for Axe + Arduino stuff. ;) I guess more of these interfaces can't hurt anyway. :P
Title: Re: Calc + TV remote = ???
Post by: MGOS on December 10, 2013, 12:56:33 am
I remembered that one, but my idea is quite a bit different - you load a single program to the AVR which makes it act like a slave and does everything for thr calc. The main program is running on the calc and giving Low level commands to the AVR - instead of just a linking protocol for bytes.