Shop OBEX P1 Docs P2 Docs Learn Events
I2C Keyboard/Mouse? — Parallax Forums

I2C Keyboard/Mouse?

jazzedjazzed Posts: 11,803
edited 2010-10-29 23:48 in Propeller 1
Has anyone tried to implement a Keyboard/Mouse interface via an I2C device? I'll try this soon using a small/cheap micro-controller as the I2C device interface (atTiny85).

Considering the built-in nature of I2C for Propeller such an interface seems natural. I'm thinking the Propeller object would poll the I2C device for keystrokes or mouse events using a COG and could also provide EEPROM device support. Any thoughts?
«13

Comments

  • TubularTubular Posts: 4,706
    edited 2010-08-09 21:47
    It seems like a very good idea especially when really pin constrained. It could easily be extended to larger atmegas to provide more pins, perhaps RTC and/or ADC functions. But its a good idea to start simple...

    I really like Peter J's idea (I think it was his) of Obex objects that include the attiny "firmware", so end users don't have to get involved in another programing environment to make it work. I'm not sure whether the i2c pins you have chosen are the same that normally program the attiny. I'm trying to do something vaguely similar with Cypress PSoC at the moment, and one of the reasons for selecting Cypress was programming (as well as runtime data) over the i2c interface.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-09 21:55
    I think it's a great idea. I like the loadable firmware idea to.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-09 22:30
    Thinking some more about the firmware.

    Given that in this case the keyboard and mouse are fairly fundamental interfaces that people have come to expect to be there, as on demo boards etc, and the atTiny devices are so small perhaps it's better to have them permanently programmed rather than have dynamically loadable firmware.

    Is it possible to program them via the I2C from the Prop with a Spin application run once when the board is constructed?

    Dynamically loaded firmware might be interesting for other uses. But I'm starting to worry about Zog which now has binary blobs of firmware to load into Cogs, for FullDuplexSerial for example. Having to manage firmware for external devices as well is getting to much for me to think about.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-08-10 01:59
    The Atmels would require SPI (5V) or parallel (12V, I think, never tried it) I can get access to a version of BASCOM AVR that allows for IC2 slave emulation.

    I often thought about lumping an AVR onto the Prop as an A-D. Sounds a bit like a Cameleon (if I could spell it)
  • Heater.Heater. Posts: 21,230
    edited 2010-08-10 02:14
    Unless you start with an AVR that already has a boot loader blown into it.

    Dare I say it, like this ATmega328 from SparkFun with an Arduino boot loader pre loaded. http://www.sparkfun.com/commerce/product_info.php?products_id=9217

    Which I start to think is not such a bad idea. It gets back use of a bunch of I/O lines that are used up in the Prop with the SDRAM interface that Jazzed wants to build. Provides A to D.

    Also one could work this the other way round, use the AVR as the boot EEPROM for the Prop!
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-08-10 02:38
    Yeah, I ducked the surgestion to bolt on an Arduino. People get twitchy.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-10 02:47
    Perhaps you should just go for it. It's just a chip that provides I/O expansion, A/D and maybe some program store. It just happens to be a micro-controller. So what? Even a USB serial adapter has a micro in it.

    On the other hand it is quite likely that ZOG is going to sprout some Arduino compatible libraries and the same "sketch" style API. So why not have more of the same "out there"?
  • bhenningbhenning Posts: 13
    edited 2010-08-10 06:32
    It is a good idea - I think Cluso99, Pvj and Leon (and probably others I can't remember before my morning coffee) have advocated using cheap uC's as peripherals before; GG is selling a PIC-based USB-prop programmer. It's an idea that I've had on the back burner as well, but no time to do it.

    I'd love to see a really cheap I2C kb/mouse/etc controller!
    jazzed wrote: »
    Has anyone tried to implement a Keyboard/Mouse interface via an I2C device? I'll try this soon using a small/cheap micro-controller as the I2C device interface (atTiny85).

    Considering the built-in nature of I2C for Propeller such an interface seems natural. I'm thinking the Propeller object would poll the I2C device for keystrokes or mouse events using a COG and could also provide EEPROM device support. Any thoughts?
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-08-10 06:49
    Bill: I see you are a junior member along with heater LOL

    I built the RamBlade with an option to use a PIC10F2xx 6pin SOT23. I was thinking to load a minimal prop boot code and possibly use it for a keyboard interface. I never did test any of it. I think there may not be enough Flash for the minimal prop boot code.

    As for the keyboard, I would suggest that it may be better to just make a keyboard to serial (output pin only) chip. I guess it depends on whether you want to have other I2C chips on the bus.

    However, wouldn't the easier way be to bight the bullet and use 2 props so that if/when we get the Prop 1.5 we can just use it instead??? Of course the second prop gives us access to the USB devices using the new non-compliant drivers .

    What I would really like to find is a <$2 micro chip (including internal xtal) that can do USB OTG to replace the expensive FTDI chip. Those chips bug me the most about cost.
  • bhenningbhenning Posts: 13
    edited 2010-08-10 07:01
    Personally I'd prefer a DIP-8 with 6 I/O's - 2 for I2C, 2 for KB, 2 for Mouse, with some registers that the prop can read for last key pressed (or a small fifo), and mouse registers.

    Why? Because it can share the eeprom I2C pins!!!

    Re/USB

    I've had PIC18F14K50 dev kits here for over a year, just no time to use them, intending to use it as an FTDI replacement. GG has a stick to do that now. The smaller memory version, the PIC18F13K50 is just under $2 in quantity! Note, this does not have USB OTG.

    As far as a second prop goes - that would be a great solution, except for the price of Prop's. A lot of people simply do not understand the costs involved, and complain about pricing.
    Cluso99 wrote: »
    Bill: I see you are a junior member along with heater LOL

    I built the RamBlade with an option to use a PIC10F2xx 6pin SOT23. I was thinking to load a minimal prop boot code and possibly use it for a keyboard interface. I never did test any of it. I think there may not be enough Flash for the minimal prop boot code.

    As for the keyboard, I would suggest that it may be better to just make a keyboard to serial (output pin only) chip. I guess it depends on whether you want to have other I2C chips on the bus.

    However, wouldn't the easier way be to bight the bullet and use 2 props so that if/when we get the Prop 1.5 we can just use it instead??? Of course the second prop gives us access to the USB devices using the new non-compliant drivers .

    What I would really like to find is a <$2 micro chip (including internal xtal) that can do USB OTG to replace the expensive FTDI chip. Those chips bug me the most about cost.
  • Heater.Heater. Posts: 21,230
    edited 2010-08-10 07:41
    Clusso: Bill and I just keep getting younger and younger:) Actually I had a birthday on the day of the forum changeover. When I sobered up I was very confused.

    Bill: I'm inclined to a agree. A DIP 8 AVR on the I2C pins would be just fine.

    Can we skip the PICs? I have an ulterior motive. Somewhere I have an AVR USB serial programmer built from just an ATMEGA8. It's about the first and last AVR project I got working before the Prop hit me. Never had any luck building a programmer for PICs. Also it's dead easy to code for AVR using GCC under Linux.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-08-10 07:41
    For me its not so much a price thing, with the FTDI chips, it's the pin pitch.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-08-10 07:53
    With an eight pin chip, 6 pins for trafic and the others for VCC and VSS, that leaves the reset fuse set for no extenal resets. that would stop a true Arduino program route.

    (I Think, ......... I'll just pop out and purchase a tin hat)
  • bhenningbhenning Posts: 13
    edited 2010-08-10 09:05
    An 8 pin AVR with internal clock sounds great for a kb/mouse controller; DIP8 for through-hole designs, and SOIC8 for surface mount.

    Re/ PIC's... sooner or later I may play with my PIC18F14K50's for USB->serial, but I have to finish all my new products first...

    Btw - Happy Birthday!!!!
    Heater. wrote: »
    Clusso: Bill and I just keep getting younger and younger:) Actually I had a birthday on the day of the forum changeover. When I sobered up I was very confused.

    Bill: I'm inclined to a agree. A DIP 8 AVR on the I2C pins would be just fine.

    Can we skip the PICs? I have an ulterior motive. Somewhere I have an AVR USB serial programmer built from just an ATMEGA8. It's about the first and last AVR project I got working before the Prop hit me. Never had any luck building a programmer for PICs. Also it's dead easy to code for AVR using GCC under Linux.
  • bhenningbhenning Posts: 13
    edited 2010-08-10 09:07
    Toby,

    I agree about the painful pitch of the FTDI parts; but the price is awful too...

    I see no reason to use the Arduino tool chain for what would be a simple I2C kb/mouse interface. Either AVR assembly, or GCC-AVR would be plenty, and besides - the Arduino Wiring extensions don't really suit writing such a driver.
    With an eight pin chip, 6 pins for trafic and the others for VCC and VSS, that leaves the reset fuse set for no extenal resets. that would stop a true Arduino program route.

    (I Think, ......... I'll just pop out and purchase a tin hat)
  • Heater.Heater. Posts: 21,230
    edited 2010-08-10 09:20
    Bill, quite so. Apart from the fact that the Arduino tool chain is AVR-GCC:) Of course we don't need all that library junk.
  • bhenningbhenning Posts: 13
    edited 2010-08-10 09:40
    It is the "library junk" I was referring to :)
    Heater. wrote: »
    Bill, quite so. Apart from the fact that the Arduino tool chain is AVR-GCC:) Of course we don't need all that library junk.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2010-08-10 10:21
    Yeah, I ducked the surgestion to bolt on an Arduino. People get twitchy.


    twitch... twitch...

    Actually, I love the idea of using some of the alternatives to do Propeller dirty work as in this case driving a keyboard/mouse. Am I going to have invest in some new programming tools to play?

    OBC
  • jazzedjazzed Posts: 11,803
    edited 2010-08-10 10:39
    Interesting posts. Thanks for your feedback.

    Having an I2C keyboard/mouse device can serve the Propeller community well.
    My primary motivations for choosing the AVR PDIP8 atTiny85 are:

    1) To preserve the I2C bus for additional I2C devices.
    2) AVR I2C device comm is faster than the Propeller equivalent.
    3) I know AVR ASM ... I've never programmed a PIC.
    4) PDIP8 atTiny85 are $1.82 each at mouser for 1 ($1.39 for 10).
    5) Having exactly 6 IO's for the job seems to be a perfect fit.
    6) If necessary, the code could be leveraged for bigger devices.
    7) Could be a way to add other features simultaneously like ADCs.

    I understand the desire to use a Propeller for this purpose and it is possible.
    My first I2C keyboard/mouse design will be on a 32MB SDRAM GG board
    that will allow a Propeller Computer using the GG PropellerPlatform SD.
    Later I may offer a single board version with the same feature-set.

    As you can see, there's no room for another Propeller on the 32MB SDRAM board.

    attachment.php?attachmentid=72403&stc=1&d=1281459868

    @OBC, I could send you new chips ;)

    In the spirit of our community though, I think open source makes sense.
    I would prefer a way to program a device in circuit from a Propeller.
    Meanwhile, here's a programmer from SFE that uses an RS232 interface.
    http://www.sparkfun.com/commerce/product_info.php?products_id=33
    Unfortunately, a programmer cable is also needed for that.

    The STK200 which I have is probably a better option because it comes with
    everything you need to program just about any AVR and is listed at about $70.
    http://www.kanda.com/products/kanda/STK200.html

    Cheers.
    --Steve
    445 x 388 - 16K
  • Heater.Heater. Posts: 21,230
    edited 2010-08-10 12:09
    Jazzed, I think that's a brilliantly optimal solution.

    OBC, yep, using 32 bit COGs on things like keyboards/mice has always made me feel uneasy. Having a little DIP do that ans using a COG to drive it which can also be used to access EEPROM seems great.

    I made an AVR programmer from an ATMEGA8, a USB socket, an XTAL and a bunch of resistors. From this design http://www.fischl.de/usbasp/ Which is in turn based on this USB stack for AVR http://www.obdev.at/products/vusb/index.html Which in turm means we can unload slow speed USB stuff to a dinky AVR as well :)
  • Heater.Heater. Posts: 21,230
    edited 2010-08-10 12:33
    Having said that looks like an ATAVRDRAGON is the thing to get now a days. Cheap too.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-08-10 13:18
    I just use all the free stuff, and push the hex files into the AVRs with PonyProg ans a serial interface (so that XP doesn't get in the parallel way).

    Anyway, What's wrong with the Wiring library? Whats 1/3 of a Gig beteen friends? (at least it is a mere fraction of the Xilinxs stuff !!!)
  • jazzedjazzed Posts: 11,803
    edited 2010-08-10 16:06
    Heater. wrote: »
    Jazzed, I think that's a brilliantly optimal solution.
    Thanks :o
    Wow that Dragon board looks great with full emulation and USB power :)
    I just use all the free stuff, and push the hex files into the AVRs with PonyProg ans a serial interface (so that XP doesn't get in the parallel way).
    PonyProg looks interesting. How hard would it be to come up with a PropPlug compatible programmer schematic for atTiny85? I see there is a 4MHz crystal on the PonyProg schematic; is that necessary for programming? I'm a little concerned that the RST* function PB5 fuse has to be cleared to allow general purpose input ... if the fuse remains set can PB5 be used as an output? Wrong forum for such questions I guess :) Looks like I need to get a chip or two for experiments and do more research.

    Thanks,
    --Steve
  • hinvhinv Posts: 1,255
    edited 2010-08-10 22:51
    This may be a bit off topic, but have you thought about replacing the chip within the keyboard? Most of my favorite keyboards have a 40pin dip for encoding the keystrokes. I was thinking that if I replaced that encoder chip with a prop, I could send both the keyboard and mouse(mouse plugged into keboard) codes over a 2 wire bidirectional BeauNet connection, or even 1 wire for uni directional.

    If you are going to incorporate an AVR or something into your design, would it be possible to incorporate an IR or BlueTooth boot loader that programs the propeller as soon as it receives a prop image an a checksum. This could elinate the need for the ftdi chip and the eeprom, and allow us to program the propeller from our smart phones!

    just throwing in my 10 bits

    Doug
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-08-11 01:30
    The AVRs come out of the factory set for SPI enabled, internal osc, devide by 8 enabled. This means that SPI can be done with reasonable speed (at 1MHz internal clk).

    I built the combined Interface bit and the 8, 20, 28 and 2x 40 pin bit. The 4MHz xtal is there for when you are reprogramming chips that have the fuse bits set for external xtal. I have put an osc block on as well so that option is covered too.

    People wish for fuse bits on the Prop, they are a right pain on the AVR. They are set when they are low, designed to confuse the stupid ......


    http://www.circuitdb.com/circuits/id/216
    800 x 600 - 56K
  • Heater.Heater. Posts: 21,230
    edited 2010-08-11 01:51
    Glad I'm not the only one who hates those fuse bits.

    Sure I've got a handful of "dead" AVRs that would be usable here if not for the fuse bits.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-08-11 02:05
    They could be resusitated with high voltage programming, but I have never done that because it is parallel, and Windoze gets in the way.

    When I tried high voltage programming on a Prop ......
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-08-11 06:11
    jazzed: There is pleny of room on that there pcb for a prop. You haven't touched the underside yet!

    hinv: WOW - I never realised they were still using DIP chips in keyboards still. Well my latest keyboard (USB & works as PS2) is still oldish. It has a small single sided pcb and 8x18 input scans and 3 Leds. This is the best solution I have heard in a long time ;) My keyboard is rated 100mA, but with a prop it would be much lower.

    BTW I could fit ~3 x RamBlades in there :D

    Only problem is going to be each keyboard will have a different pcb and connection no doubt :mad:
  • jazzedjazzed Posts: 11,803
    edited 2010-08-11 08:55
    Cluso99 wrote: »
    jazzed: There is pleny of room on that there pcb for a prop. You haven't touched the underside yet!
    I prefer to keep my underside untouched if possible.
    Cluso99 wrote: »
    BTW I could fit ~3 x RamBlades in there
    A multi-propeller GadgetGangster module might be interesting to explore. A ring topology could be easily done by cross connecting serial links between boards to allow N connections. You could probably get 8 Propellers on a 2 sided GG module. That would allow Humanoido's tower to contain as many Propellers as his power supply could support before toppling over or dimming the lights.
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-08-11 14:44
    jazzed: I like to place the decoupling caps right under the prop for best overclocking. On RamBlade the prop and sram are on one side and the rest of the circuitry is on the other, so microSD is under (or as I did it, on top of) the SRAM.

    Back to the prop in a keyboard -A single sided pcb with a DIP prop would work in the keyboard I opened. Wonder how many keyboards use a similar pcb?

    What about the $2 bluetooth modules? Could use a network of props with bluetooth modules (one in the keyboard). Has anyone overcome the fixed address in those $2 bluetooth modules???
Sign In or Register to comment.