Omnimaga

General Discussion => Technology and Development => Other => Topic started by: Deep Toaster on October 12, 2012, 11:00:09 pm

Title: How do I use make an accelerometer work with the link port?
Post by: Deep Toaster on October 12, 2012, 11:00:09 pm
While looking through my older projects, I realized there was something I'd always wanted to do—make PapiJump (http://www.ticalc.org/archives/files/fileinfo/435/43518.html) work with an accelerometer so I could tilt it back and forth like an iPhone. I have plenty of wires and stuff that I could use, but the problem is that I know absolutely nothing about hardware.

happybobjr posted some info in the topic (http://ourl.ca/81775), but I have no idea what those terms mean—what's "left," "right," and "ground"? I can't learn from Google either, because I don't even know what to start searching for :/

What do I do with the link port to let me read values from it in a program?
Title: Re: How do I use make an accelerometer work with the link port?
Post by: thepenguin77 on October 12, 2012, 11:34:08 pm
First, a little terminology, the plug that plugs into the link port is composed of 3 parts, the sleeve, the ring, and the tip. The sleeve, (the part closest to the wire) is electronic ground (0V). The other two (the ring and the tip) are both data lines. By default these sit at 3V.

Ok, so when you open up calcsys and look at port (00h), you'll notice that it reads 03. It's reading 3 because both the tip and the ring are at 3 volts (the tip is bit 0 and the ring is bit 1).

Now, a pair of headphones is basically a short circuit from both the tip and ring to the sleeve. In normal operation the tip goes to the left earphone and then to ground and the ring goes to the right earphone and then to ground. But, the main point I'm trying to get across here is that the headphones lower both the tip and the ring to 0V. So now, to see what I'm talking about, you can plug a pair of headphones into your calculator and you'll notice that port (00h) now reads 00 (and your calculator is relatively frozen).

The basic idea here is that when disconnected, both the tip and the ring will gives 1's over port (00h). But when you connect them to ground (the sleeve), they will read 0.


Now that that's out of the way, you can start messing around with your accelerometer. The basic idea here is that when your accelerometer is tilted to the left, it will connect the ring to ground and when it is tilted to the right, it will connect the tip to ground (you can swap left/right ring/tip). The way to do this is up to you, but the simplest way would simply be a marble in a tube that connects the circuit when it reaches either end.

Edit:
   In axe, you can read the value of port (00h) by using the "Port" command (ClrTable).
Title: Re: How do I use make an accelerometer work with the link port?
Post by: Deep Toaster on October 12, 2012, 11:50:08 pm
So port 0 basically has bit 0 set if the tip is connected to the sleeve and bit 1 set if the ring is connected to the sleeve?

Thanks a lot!
Title: Re: How do I use make an accelerometer work with the link port?
Post by: DrDnar on October 13, 2012, 02:00:18 am
Yeah, it's pretty simple. You can also monitor switches and drive small relays (https://en.wikipedia.org/wiki/Relay) from the link port.

One addendum: The correct link voltage is 3.3 V OR 5.0 V. The higher voltage is used only on the early TI-83+ models. But frying newer calculators isn't an issue; modern calculators probably tolerate up to at least 6 or so volts.

Kerm already implemented a similar idea for an Etch-a-Sketch (http://www.cemetech.net/news.php?year=2010&month=all&id=392).

Also, you can control many Canon and Pentax dSLRs from your calculator---and others with an adapter---cf. my program (http://www.ticalc.org/archives/files/fileinfo/445/44581.html) and a less accurate method for the TI-83+ (http://www.ehow.com/how_8544915_program-ti83-time-lapse.html).
Title: Re: How do I use make an accelerometer work with the link port?
Post by: Keoni29 on October 18, 2012, 05:06:20 am
You can make a two wire serial protocol to communicate with a microcontroller. You could use a microcontroller simillar to an arduino board as a buffer which gathers information from an accelerometer and send it to the calculator on demand.

Edit: This might work for you as well:
T  G  R
|  |  |
|  |  |
|  |  |
|  |  |

T=tip
G=ground
R=ring

The | lines connected to tip and ring are metal plates. The line | connected to ground is a little rod which can move freely. Mount this to the back of your calc. Every time the wire shorts either tip or ring to ground you can read change in the port state.
Title: Re: How do I use make an accelerometer work with the link port?
Post by: Deep Toaster on November 10, 2012, 07:43:07 pm
Thanks for the help everyone! Here's what I ended up with: http://ourl.ca/5580/268974/