Shop OBEX P1 Docs P2 Docs Learn Events
Where can I find examples of these simple applications — Parallax Forums

Where can I find examples of these simple applications

ClintClint Posts: 95
edited 2010-01-22 20:39 in Propeller 1
I am currently using an SX to do a few simple tasks. With the SX EOL, I need to find a new microcontroller and I want to know how easy/difficult it is to use the Propeller for what I'm doing.

1) Read/count a quadrature encoder
2) Drive an·eight digit·7-segment display LED (or two four digit displays)
3) Trigger events with push buttons, drive LED indicators
4) Drive some type of speaker to make a "beep" sound when needed

Right now I use an interrupt to handle (1) because·a high sampling rate on the encoder is essential to prevent miscounts. With the Propeller architecture, I'm guessing I could dedicate a COG for this, but how would I determine the sampling rate to make sure the Propeller will be fast enough? I see on the Parallax site that each COG can execute 20MIPS. How many instructions will it take to read an encoder and increment a count up & down? Would it be possible to share this task amongst more than one COG to improve the sampling rate? Are there any code examples for handling·quadrature·encoders?

For (2) I currently use a separate IC that statically drives four digits, but if I can save money by using the Propeller to multiplex, it will help offset the increased cost over the SX. For 8 digits this would suck up 7 I/O for the segments and 8 more I/O to sink. I'm not sure how well that many digits would multiplex.

I'm guessing (3) will be a no brainer.

Any examples or suggestions of what type of speaker/sound generator to use for (4) would be helpful. This is to provide a function similar to the beep at the end of cycle for a microwave.

Thank you for any help you can offer. I am also looking at PIC chips, but Parallax and the community has been so great to work with I would hate to go to the dark side.

Post Edited (Clint) : 1/22/2010 6:07:37 PM GMT

Comments

  • TonyWaiteTonyWaite Posts: 219
    edited 2010-01-22 18:10
    Hi Clint,

    The Propeller can do the lot: for example, have a look at the Object Exchange (Obex), which has functions for the
    quadrature encoder 'ready to go'.

    And you're right to stick with the Parallax community: the forum is second to none!

    T o n y
  • BeanBean Posts: 8,129
    edited 2010-01-22 18:19
    Clint,
    · I don't know if you were using SX/B or not, but if you were you'll feel right at home with my new program PropBASIC.
    · It is based on the SX/B compiler.
    · You can download it from the first post in the thread http://forums.parallax.com/showthread.php?p=867134

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Use BASIC on the Propeller with the speed of assembly language.

    PropBASIC thread http://forums.parallax.com/showthread.php?p=867134·
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-22 18:36
    (2) The Propeller has plenty of I/O pins and could multiplex 8 7-segment displays easily. There may be an object in the Object Exchange that will do this for you.

    (4) How fancy do you want to get? The Propeller can generate single tones with one object in the Object Exchange. It can do speech synthesis if you want a talking device. It can play .WAV files as long as they're short enough to fit into memory or can read them from an attached PC-compatible SD card (just needs an SD card socket and 4 I/O pins). The code to do this is also in the Object Exchange. You'll need a small amplifier for the speaker. For simple stuff, a transistor or LM386 amplifier will do just fine.
  • ClintClint Posts: 95
    edited 2010-01-22 18:52
    TonyWaite - Thanks for pointing me to the OBEX. I did a search for "quadrature" and came up with a couple of examples right away. I opened one with my text editor and it looked like it would work for what I'm doing. The documentation said it could sample every 4microseconds (250kHz?), which I believe would be enough for my application.

    Bean - I have heard about PropBASIC and I'll definitely look into it. I have been using SX/B and assembly language is over my head right now. The little bit of SPIN I've seen seems to be somewhere in between. If I can transition with PropBASIC and still have the speed I need to accurately read this encoder, I will be happy.

    Mike Green - I don't want to get very fancy with the speaker. All I need is a single tone "beep". If there were a device that I can put on a PCB that I could set high for tone and set low for no tone, I would be happy. I want to use as few components as possible.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-22 19:01
    You could drive a piezo-speaker directly from a Prop I/O pin. There's a Frequency Synthesizer object in the Object Exchange that you can use to produce single tones. If you want to use a conventional speaker, try using a small transformer, maybe 500 Ohms:8 Ohms or 1K:8 Ohms with a reverse connected diode across the speaker primary.
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-01-22 20:39
    1. Look at QuadratureEncoder.spin in the library that comes with the Propeller Tool. It works very well.
    3. Look at the Propeller Education Kit Labs. It is under help in the Propeller Tool.
    4. Also in the Propeller Education Kit Labs.

    John Abshier
Sign In or Register to comment.