Shop OBEX P1 Docs P2 Docs Learn Events
Can you SEND ASCII strings with this CHIP? HELP PLEASE — Parallax Forums

Can you SEND ASCII strings with this CHIP? HELP PLEASE

gth629egth629e Posts: 40
edited 2008-02-08 07:50 in Propeller 1
Okay,

Here is what I need to do or find out if it is possible.

Lets say I have 20 standard I/O switches. With the propeller chip, can you detect those switches and program it to send ASCII keyboard codes to the PC via PS/2 or USB.

So pretty much I need to detect when a switch has been closed and in return send the ASCII command to computer. Like making your own keyboard. Also it would have to be able to realize when a key is continuously pressed.

I am at whits end and I know this has to be possible with some kind of PIC.


Please let me know if you have any idea. Thanks

Comments

  • RaymanRayman Posts: 14,162
    edited 2008-02-07 00:18
    Somebody was working on a basic USB HID driver... I think they had some success.
    Try search.parallax.com for "USB HID driver f=25".
  • RaymanRayman Posts: 14,162
    edited 2008-02-07 00:27
    But, it's A LOT easier to send data to the PC using the PropPlug. In fact, you can send data simply using "fullduplexserial" and Pins 30 and 31 (the same ones used for programming).
  • gth629egth629e Posts: 40
    edited 2008-02-07 00:31
    Thanks for the info.

    What about a basic chip or something else. All I need is to have a button pressed and send a code to the pc. I mean I could hack a keyboard but I would rather not. The only other requirment is that it either be usb or ps/2.
  • Harrison.Harrison. Posts: 484
    edited 2008-02-07 00:42
    If you are using Windows 95 - XP (not sure if Vista is supported) you can use something called 'SerialKeys'. It is built into windows as an accessibility option that allows people to send keystrokes/mouse movements to a computer through the serial port using any configurable serial device.

    Microsoft provides straightforward instructions on how to use this feature. All you need is some experience with serial port access on your microcontroller.

    support.microsoft.com/kb/260517
    www.microsoft.com/enable/training/windowsxp/serialkeys.aspx

    Just remember this takes control of your selected serial port. This shouldn't be too much of an issue since you can buy usb to serial converters for < $20.

    Harrison
  • RaymanRayman Posts: 14,162
    edited 2008-02-07 01:09
    There are plenty of ~$20 serial to USB converters around. With one of those, it would be easy to use a Parallax BasicStamp chip instead...
  • gth629egth629e Posts: 40
    edited 2008-02-07 01:38
    I'm trying to keep costs low and no "shortcut" lol. This might be something I will sale.


    Thanks though

    Looks like Ill have to find another PIC to do the job =(
  • OzStampOzStamp Posts: 377
    edited 2008-02-07 02:20
    Hi

    If costs is an issue..look also at the SX chip from Parallax
    It has 21 I/I lines ( the SX28 dip version)
    Low cost $3-4 bucks USA
    Basic compiler also easy to use..
    Beats a PIC

    cheers ron mel oz..
  • gth629egth629e Posts: 40
    edited 2008-02-07 02:25
    SOUNDS GREAT,

    Now could you program it to send the correct "report" like a keyboard. Also, it should show up on the pc as a HID device or keyboard.

    With the SX can you output via USB?

    Thank all you guys for your help so far. I should mention I will be producing my own circuit boards so that is not an issue.
  • RaymanRayman Posts: 14,162
    edited 2008-02-07 02:33
    Actually, this is the really easy way to do what you've described:

    http://www.ultimarc.com/ipacve.html

    This turns button pushes into USB keyboard commands.· It's actually designed for MAME based arcade games, but should work for you...

    ·
  • gth629egth629e Posts: 40
    edited 2008-02-07 02:58
    Yes that is the back up plan however, the ipac boards only allow up to 4 combo key presses like ctrl-a and so on and I need more than that.

    Also, its $30.00 vs $5.00 and I am not allowed to sale anything with the ipac board already installed. There are other issues as well. But essentially it does exactly what I am looking for and a lot more.

    I know that this is possible though using a PIc, look at this

    http://pe.ece.olin.edu/ece/handouts/050215_lab2.pdf

    but that is not enough information.

    But is does let me know that using a simple PIC that has been programed, you can hook up using usb and have it create the require string.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-07 03:11
    The SX does not have the built-in USB logic that the PIC shown in your lab project has. I'm not aware of anyone who has provided a sample program that emulates a USB keyboard. There was someone who was working on some Propeller code to emulate HID class USB slave devices, but I haven't seen further work on it.

    You are correct that it should be possible to program a PIC to provide a string via USB in response to a switch closure.

    Remember that if you want to sell such a device, you need to have an official device identification code which is expensive to get.
    It's different if you want to just experiment.

    Have a look at this thread. It may give you some ideas. http://forums.parallax.com/showthread.php?p=645487
  • Chuck McManisChuck McManis Posts: 65
    edited 2008-02-07 03:19
    Probably not as helpful as you might like, but there are a number of people who have done USB widgets with the Atmel ATiny chip. Check out this URL www.xs4all.nl/~dicks/avr/usbtiny/index.html. Don't confuse the software implementation of USB with the AVR chip that has USB built in. You can get a chip that runs this code for between $1.50 and $3.00 from www.digikey.com and you can get them with 16 I/O pins. If you are doing something like a keyboard it would be pretty trivial, there is sample code that emulates a keyboard on the avrfreaks web site. You can also write your code in C or Assembler.

    --Chuck
  • gth629egth629e Posts: 40
    edited 2008-02-07 03:28
    Now we are getting somewhere.

    Chuck,

    Excuse my ignorance as electrical engineering is obviously not my cup of tea. I'm a mechanical engineer by trade. Could you explain a little more on you comment above?
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-07 06:37
    This is now obviously already out of the context, but still referring to the first posting.

    It is absolutely easy - even for the advanced beginner - to have a program on the Propeller to
    - send PS/2 strings to a PC
    - check any switches or whatever.

    This in fact is one of the homeworks for my class smile.gif
    It can be done in SPIN when the PS/2 clock from the PC is not too demanding (it should not exceed 20 kHz). There is no special hardware needed for 20 keys except 2 resistors. When you want to power it from the PS/2 port you also need a (small) 3.3 V regulator.

    But using a more specific chip for this - ESPECIALLY with USB - will be less expensive. (As it uses 1% of the propeller power only...)

    Post Edited (deSilva) : 2/7/2008 7:37:41 PM GMT
  • RaymanRayman Posts: 14,162
    edited 2008-02-07 13:49
    deSilva: That is interesting! I would have thought you'd need 5V logic for that... Do you think you could connect a PS2 cable directly from PC to demo board (or proto with Norcomp connector) and send keys?
  • gth629egth629e Posts: 40
    edited 2008-02-07 18:41
    desilva,

    That sounds good. Could you send me a link to your hw? lol, I am getting real close and have been doing a lot of reading and am starting to understand a little more. It seems possible. Yes I thought I would have to use a small regulator to get 3.3 volts.

    If you would be willing to help me I would gladly try to compensate you for your time. Also, I have several CNC machines so if you need anything cut for projects or anything of the like, I could give you my services in return.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-07 20:21
    I shall have to prepare a sample solution anyhow smile.gif

    I have to find a PC with a real PS/2 interface; I have checked only with a propeller running Keyboard.spin, which is not representative... As it is SPIN "only", the clock is slower than from a generic Keyboard... Maybe I shall translate it to assembly.... Also the electrical interface is not yet represantative.

    A PC has those pins out of the miniDIN connector:
    4: +5 V
    1: DATA (bi-directional)
    3: GND
    5: CLOCK (Keyboard to PC, but pulled low by the PC for commands)

    As I am using 3 Volts only at the moment there is no need for any special care...

    But as both Pull-Ups are on the PC side, there is no way around 5V...
    (@Rayman as well!)
    However DATA and CLOCK are assumed to be driven low only (!) so the paranoic's 100 Ohm series safety belt against short cuts might suffice. The Hydra interface is safer though and more recommendable for a commercial project...

    The +5V regulated by a low power/low drop down regulator deliveres ample power for the Propeller.
    ----
    Edit:
    Oops: I looked at the wrong plug smile.gif
    1 - Data
    3 - Ground
    4 - VCC (+5 V)
    5 - Clock

    Post Edited (deSilva) : 2/8/2008 7:47:38 AM GMT
  • Chuck McManisChuck McManis Posts: 65
    edited 2008-02-07 22:23
    gth629e said...

    Chuck,

    Excuse my ignorance as electrical engineering is obviously not my cup of tea. I'm a mechanical engineer by trade. Could you explain a little more on you comment above?

    Sure, the PIC chip is Microchip's single chip microcontroller solution, the AVR series is the Atmel equivalent. They are similar in many ways except that AVRs tend to be programmed more often in C whereas PIC chips seem to be more commonly programmed in BASIC (compiled or interpreted) and assembly. There are C compilers for the PIC but the architecture doesn't lend itself well to the assumptions that C makes about the computer it is being compiled to.

    AVR chips come in effectively three families, the ATTiny series (most like the PIC), the ATMega series (similar to the high end PIC chips), and specialized for specific environments (like automotive, or driving LCDs, etc) There is an active support community on the AVRFreaks web site (www.avrfreaks.net). One of Atmels recent chips is the AVRUSB which has a USB device built into it which they put into a demo board called the AVR-USBKEY (which is similar to a bazzillion other microprocessor demo/eval boards that exist as a USB device). Long story short, some bright guys figured out that if you clocked the AVR at 12Mhz (the native clock speed of USB 1.1) you could implement USB in software. A number of things came out of that, the most popular seems to be alternative human interface devices (an easy to program USB class), but USB keyboard devices are showing up as well. The software the Atmel distributes with their AVR-USBKEY demo board allows it to emulate a keyboard and you can put a button on the board and have it type in "Hello World" to your computer. There are plenty of I/O pins on the USBKEY for adding switches as well, but the AVR-USB chip (the AT90USB series) is about twice as expensive as the ATTiny series. So if all you want to do is a replacement keyboard the ATTiny running a simple keyboard matrix scanning algorithm and doing USB in software would probably be your cheapest solution.

    --Chuck
  • RaymanRayman Posts: 14,162
    edited 2008-02-08 01:08
    Somebody just posted again in that USB host code I was referring to:

    http://forums.parallax.com/showthread.php?p=673220

    As I read it (maybe Mike Green will correct me?), it turns the Prop into a USB host that is recognized as a keyboard and then sends keys to the PC...
  • gth629egth629e Posts: 40
    edited 2008-02-08 04:12
    Thank guys and chuck that was a very good explanation. I am about to buy an ATmega8 or Atmega16 and implement the usb via software using a 12 mhz crystal etc.

    Or at least thats my plan. Although I'm about to research the AVR-USBKEY and see what that leads to. I am concerned about trying to program one actual pushbutton to send multiple key press string. Hopefully I can get it done.

    I will keep you guys posted as I might try using an propeller as well. I still welcome input.

    Here is a question, I would like to buy or build a programmer for pics or the ATmega chips, do you guys have any suggestions

    Brian
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-08 07:50
    I shall also post the sample solution for the "PS2-Feed" soon. The interesting thing is that this can be done in SPIN smile.gif

    The most awkward piece of code ist the parity.. I remember we had a discussion about that some months ago...

    Post Edited (deSilva) : 2/8/2008 8:08:15 AM GMT
Sign In or Register to comment.