Author Topic: Hooking up PIC µCs with accelerometer to TI-83+  (Read 10059 times)

0 Members and 1 Guest are viewing this topic.

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Hooking up PIC µCs with accelerometer to TI-83+
« on: January 20, 2013, 07:12:52 am »
Hey guys

You didn’t hear much from me for a while now, but don’t worry, I’m not gone. I just hadn’t a lot of time because of school. But that doesn’t mean I have nothing for you to show - especially for my b100000000th post :)

About half a year ago I came across the PIC microcontrollers by Microchip and since I was making a bunch of asm routines at that time, I decided to give them a try. I hooked up the PICkit3 demo board to my 83+ and programmed some routines for serial communication. With the accelerometer ADXL-335z at the AD inputs of the PIC it is even possible to control programs by moving the breadboard around. As power supply I’m using a Nokia BL-5C battery which lasts quite long (1020 mAh) and is relatively light in weight.



Code:

Spoiler For sender code (PIC asm):
Code: [Select]
; Byte to send in register “SerialData“

SerialBegin:
  MOVLF     0x8,Count
Serialout:
  BTFSC     SerialData,0    
  BSF       SDATA    
  BTFSS     SerialData,0
  BCF       SDATA
  BCF       CLOCK
  SDelay    0x12        ; delays have to be adjusted depending on clock speed; in that case: 18*3+6=60 cycles @ 1 MHZ -> 60µs
  BSF       CLOCK
  SDelay    0x12
  RRF       SerialData
  DECFSZ    Count,1
  GOTO      Serialout
  Return

Spoiler For receiver code(z80 asm):
Code: [Select]
; GET()
; gets a byte from the port as a sequence of 0s and 1s on the ring
; (bit 1 of port 00h) on falling edge of the tip (bit 0 of port 00h)
; the sequence begins with least significant bit.

; (1) Read tip
; (2) Repeat (1) until tip low
; (3) Read ring
; (4) Put that at bit 0 of result
; (5) Rotate result right
; (6) Wait until tip back high
; (7) Repeat from (1) total 8 times

    ld bc,$0803
    ld hl,$0000
loop:
    in a,(00h)
    bit 0,a
    jr nz,loop
    and c
    sra a
    add a,l
    rrca
    ld l,a
wait:
    in a,(00h)
    bit 0,a
    jr z,wait
    djnz loop
 
Interrupts have to be disabled.

In later versions I used polling to keep sender and receiver in sync, but the delays between the bytes are fixed. Thus, there mustn't be too much code between each GET(). It works quite well for now, but the program might get stuck in more complicated applications. To prevent that, I'm planning to make a closed function for the whole communication process.

This project isn't finished, I showing just early prototypes.

Planned features:
  • General purpose functions for axe and pic programmers
  • Communication in both ways
  • Arbitrary packet length and check sum
  • Network applications


Let me know what you think :)
« Last Edit: January 20, 2013, 07:14:02 am by MGOS »

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #1 on: January 20, 2013, 07:25:21 am »
Wow, amazing, all that with a 83+ :o

I got a question though. When you use the accelerometer to draw stuff, is it a program running that decodes, or do you have some kind of hook thingie that listens to the port and makes it act like real arrow key presses?

I love the UV meter, or whatever you call it, it's nice since you don't have to buy a screen, and still get nice and fast graphics.

Good job MGOS, very good job :) you last name doesn't happen to be Gaye, does it? Would be nice :)

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #2 on: January 20, 2013, 07:46:41 am »
The all examples with the accelerometer use the same program on the PIC, the programs on the calc are independent and made in axe. The Pic pretty much listens for a request by the TI (when data pin is set to HIGH) and makes a analog to digital conversion of the analog X and the Y values of the ADXL. Those raw values are sent as two bytes to the calc. The calculator subtracts a calibration value (stored at program start) off those bytes, so you get 0 when the board is hold horizontally. The new values function as the speed of the cursor.
But it is indeed a nice idea to write a hook and control the OS with the board.


And no, my last name isn't Gaye :P

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #3 on: January 20, 2013, 08:00:52 am »
That's fantastic! I'm really impressed at how responsive it is. O.O I could see the motion control being used in a snake game or a racing game. Very cool stuff! ^^

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #4 on: January 20, 2013, 08:43:28 am »
Yeah, I actually thought of making a racing game like Megacar (in case you remember that :) )

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #5 on: January 20, 2013, 09:30:10 am »
Yay more peripherals. We should have a hardware and schematics section on omnimaga!
If you like my work: why not give me an internet?








Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #6 on: January 20, 2013, 01:04:27 pm »
Keoni, there is, we're talking in it right now. :P

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: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #7 on: January 20, 2013, 01:43:35 pm »
Very great indeed. I,m glad there is more hardware stuff/mods lately here :)

I wonder if it would be hard to do something like a wiimote for the calc with this? O.O
« Last Edit: January 20, 2013, 01:44:15 pm by DJ_O »

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #8 on: January 20, 2013, 03:14:12 pm »
Keoni, there is, we're talking in it right now. :P
I mean something similar to the games an applications archives/download section.

A wiimote requires some kind of bluetooth tranceiver. A nunchuck however uses I2C which is much easier to interface with.
If you like my work: why not give me an internet?








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: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #9 on: March 10, 2013, 12:09:19 am »
If calculators were more popular than they are right now, it would be cool if some dedicated people started selling hardware add-ins like the above but that kinda looks nice-ish and could be easily hooked into the link port or at the top of the calc like how the TI-84+ for visual impaired thing seems to be. Example of games could be given as links or something, along with code examples, so people know what it can be used for. This, for example, could be nice for a 3D tunnel where you tilt the calc to avoid edges or other similar games, and it could be made so it fits the 83+, 84+ and 84+CSE series or even other models.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #10 on: March 10, 2013, 09:02:48 am »
The TI-interface is coming along nicely, so that might be your first product right here. As for the PIC mcu: It's really easy to port the link protocol. Just change some of the hardware specific stuff like interrupts and ports and you're good to go. Just hooking up accelerometers using I2C is also possible with calculators. The link protocol I wrote is very similar to I2C, so with some modifications a low speed I2C protocol can be implemented in AXE (low as opposed to 100Mb/s)
If you like my work: why not give me an internet?








Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #11 on: March 10, 2013, 10:47:49 am »
The only issue I can think of is the power supply. You either need an external power supply (relatively large, needs to be charged from time to time), such as a battery, or modify your calc to access its power. I tried to power the µC via the port an caps, but that doesn't do the trick.

Offline Keoni29

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2466
  • Rating: +291/-16
    • View Profile
    • My electronics projects at 8times8
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #12 on: March 10, 2013, 10:52:18 am »
You can simply run wires from the batteries in your calc to the mcu. That is what I did for my soundchip prototype. Now I just hacked my calculator and put an expansion port on the side that will connect to some I/O of the atmega and power.
If you like my work: why not give me an internet?








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: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #13 on: March 10, 2013, 11:19:53 pm »
The TI-interface is coming along nicely, so that might be your first product right here. As for the PIC mcu: It's really easy to port the link protocol. Just change some of the hardware specific stuff like interrupts and ports and you're good to go. Just hooking up accelerometers using I2C is also possible with calculators. The link protocol I wrote is very similar to I2C, so with some modifications a low speed I2C protocol can be implemented in AXE (low as opposed to 100Mb/s)
Ah I thought it was kinda discontinued or something (especially now with Orion 84+). Glad it's still being worked on.

Offline _Nicco_

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 173
  • Rating: +6/-0
    • View Profile
Re: Hooking up PIC µCs with accelerometer to TI-83+
« Reply #14 on: March 10, 2013, 11:32:43 pm »
Have you guys seen the game Cave Droid for android?  You're going through a cave and there are things that you need to avoid.

If we attach the accelerometer to the calculator then we would be able to make a similar game.  The problem is that only a few people would be able to play it since it would require additional hardware.
They say that your signature is supposed to go here...