Shop OBEX P1 Docs P2 Docs Learn Events
Simple QuickStart Propeller Board Question.. — Parallax Forums

Simple QuickStart Propeller Board Question..

Kyle_KKyle_K Posts: 1
edited 2012-03-07 11:07 in Propeller 1
Hey Guys,<br>
<br>
I am new to the whole microcontroller thing and programming them as well.. I've been searching for a while trying figure out how to program one touch button on the board to turn on the corresponding LED.. Can anyone help?

Comments

  • g3cwig3cwi Posts: 262
    edited 2012-02-27 09:28
    There is a program example on Parallax's Quickstart pages that will get you started.
    http://www.parallaxsemiconductor.com/quickstart

    Regards

    Richard
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-27 10:49
    There are several touch pad to LED programs out there.

    IMO, my altered very of the touchpad object makes it easier for someone new to the Prop to use a touchpad as a button. I explained how to use the object starting in post #15 of this thread.

    I have a link to a partial list of QuickStart projects in post #2 of my index.
  • MarineCorpsCommMarineCorpsComm Posts: 8
    edited 2012-03-03 17:47
    @Kyle_K ,

    Attached is the Parallax example code if you have not figured it out yet.
  • cavelambcavelamb Posts: 720
    edited 2012-03-03 18:45
    I bought a QuickStart board today to play with since it has 8 LEDs and 8 buttons already on it.
    So I wrote a quick LED Chase program, then Cylon! for the LEDs.
    Stored that in EEPROM.

    It works fine.

    But there seems to be a catch with it.
    It runs fine attached to a real USB port.

    But won't run the EEPROM program on a non-computer USB power source (iPod charger).

    Any way to fix that?

    I though I'd try Propeller Pong next.
    And I'd like it to be portable.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-03 19:10
    Yeah, you need to connect something (ground I think) to the "USB Power Enable" (or something like that) pin (I think it's pin 30 on header).

    There's some note on the schematic about it, IIRC.

    I found it from the link near the top of this thread.
    /USB_PWR_EN —USB power enable pin, inverted. Pulled to USB 5 V supply. Internally driven low after successful USB power negotiation. Can be externally driven low to force the USB power input to drive the QuickStart power supply, such as when powering from a USB charger.
  • cavelambcavelamb Posts: 720
    edited 2012-03-03 20:00
    Cool!

    Thanks Duane. I missed that one.

    Looking at the schematic it looks like a battery can be connected to the connector pins 39 - 40.
    I'll probably go that route.
    But it would be handy to power from a charger now and then.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-03 20:10
    cavelamb wrote: »
    Cool!

    Thanks Duane. I missed that one.

    Looking at the schematic it looks like a battery can be connected to the connector pins 39 - 40.
    I'll probably go that route.
    But it would be handy to power from a charger now and then.

    I always add a few things to my QuickStart boards. Labels on the front and back of the 40-pin header, female headers on the Vdd and Vss holes on the right side of the board and a 2-pin male header on pins 39 and 40 so I can connect a battery pack with four AA NiMH batteries.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-03 20:15
    I found a picture that shows a battery pack connected to a QuickStart.

    attachment.php?attachmentid=83296&d=1311402017
  • cavelambcavelamb Posts: 720
    edited 2012-03-03 21:26
    If that battery pack has a switch on it, I have the very same one!
    Two, actually.
    One has a 3.5mm plug for my Protoboard and FF Platform,
    The spare one will have a berg connector for the QuckStart board.
  • cavelambcavelamb Posts: 720
    edited 2012-03-06 19:33
    I put this together this evening to play with the touch pads.
    It works ok, but the pads themselves are problematic.
    Too much variation in skin conductivity.
    My old dry caloused fingers don't make it very happy.
    I found that a bent paper clip really helped.
    (actually the cuticle cutter worked best)

    I'd give another 8 bucks retail for real switches on this board, guys!

    But overall, I like it a lot.

    (Edit to put the right copy here!)
    { SCAN TOUCH PADS }
    CON     
      _CLKMODE=XTAL2
      _xinfreq = 5_000_000                                          
      ALL_1 = 11111111
      ALL_0 = 00000000
    VAR
      LONG MS001 
      LONG US001 
      BYTE Tpad[8], Pad, P1, P2,  B
    PUB TPads' SCAN THE TOUCH PADS
      B := 0
      MS001 := CLKFREQ / 1_000
      US001 := CLKFREQ / 1_000_000
      repeat
        Repeat pad from 0 to 7
          P1 := 0
          dira [pad]:= 1    
          outa [pad]:= 1
          dira [pad]:= 0
          P1 := ina[pad]
          dira [pad]:= 1
          dira [pad]:= 0
          P2 := ina[pad]    
          P1 := P1 + P2  
          if P1 == 0    
             dira[pad+16] := 1
             outa[pad+16] := 1
             WaitMS(100)
             outa[pad+16] := 0
    
    PUB WaitMS(w)|  C
      C := W*MS001 
      WaitCNT (C+cnt)
    PUB WaitUS(w)| C
      C := W*US001 
      WaitCNT (C+cnt) 
     
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-06 19:50
    cavelamb wrote: »
    I put this together this evening to play with the touch pads.
    It works ok, but the pads themselves are problematic.

    Did you try the method I linked to in post #3 above?

    I think it works pretty well.
  • cavelambcavelamb Posts: 720
    edited 2012-03-06 21:18
    Duane Degn wrote: »
    Did you try the method I linked to in post #3 above?

    I think it works pretty well.

    I haven't yet, but will take a look at it .

    My focus here is learning the lingo and architecture.
    I wanted to give it a try for my own bad self.
    As a touch pad demo I think it's pretty decent.

    It's just that my fingers don't work so well as jumpers.
    I thought I might try to enhance it by scanning each key two or three times.
    See it that makes it respond better....
  • AribaAriba Posts: 2,690
    edited 2012-03-06 21:51
    Add a short delay between setting the pad-pins to input and reading the pins (1..2 ms), this makes the pads more sensitive.
          ....
          dira [pad]:= 0
          WaitMS(2)
          P1 := ina[pad]    
          if P1 == 0    
             ...
    

    Andy
  • cavelambcavelamb Posts: 720
    edited 2012-03-06 22:34
    Following your suggestion, I did that, and I suspect you are right.
    It does seem to be steadier.
    I'm playing around with now it to see how long is too long.

    But I still have to lick my finger to get any response.
    I'm just a high impedance guy, I guess. ;)
  • cavelambcavelamb Posts: 720
    edited 2012-03-07 00:05
    Duane Degn wrote: »
    Did you try the method I linked to in post #3 above?

    I think it works pretty well.

    I have now, Duane, and I agree whole completely!

    Nice piece of work.
  • cavelambcavelamb Posts: 720
    edited 2012-03-07 10:49
    Duane, thank you for the reminder to look at the example.
    That paid off big time. Prior art usually does.
    It took a while to figure out what was going on in there...
    But it gave me some pretty solid ideas on how to improve my effort.

    In order to get better control of the timing: (and this one is ALL timing!)
    at the beginning of the program, preset all touch pad pins as outs and preset them HI.
    We won't have to bother with the output levels again,
    just toggle the direction to outputs for a moment to charge the output pin to HI.
    Then flip the direction back to input, wait a couple of MS for the charge to decay some,
    (went out to 4500 US before it got flaky again, but more than 2 MS just slows down the program)
    and read the pin. Voila! I'm low impedance!


    CON { TPAD2.SPIN - SCAN TOUCH PADS }     
       _CLKMODE=XTAL2
       _xinfreq = 5_000_000                                          
    
    VAR
       LONG MS001 
       LONG US001 
       BYTE Pad, P1
    
    PUB TPad2                   ' SCAN THE TOUCH PADS
      MS001 := CLKFREQ / 1_000
      US001 := CLKFREQ / 1_000_000
      dira [0..7]  := %11111111    ' preset all pad pins high
      outa [0..7] := %11111111
      
      Repeat
        Repeat pad from 0 to 7
          dira [pad]:= 1          ' make it an output 
          P1 := 0
          dira [pad]:= 0          ' make it an input
          WaitMS(2)
          P1 := ina[pad]
          if P1 == 0    
             dira[pad+16] := 1
             outa[pad+16] := 1
             WaitMS(10)
             outa[pad+16] := 0
    
    PUB WaitMS(w)|  C
       C := W*MS001 
       WaitCNT (C+cnt)
    
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-07 11:07
    cavelamb,

    I'm glad I could help.

    I can't claim credit for all the code I linked to. I mainly changed it so it was easier for new user to the Prop to use the touchpads as buttons. Instead of having all touchpad states as bits in a byte I had each touchpad have its own byte. (I know I have a version the fills both a byte array and also writes all states to one byte.)

    I see you converted the code to all spin.

    I liked not having to deal with the pins at all, just read the bytes from the button array.

    BTW, the battery box I posted does have a switch. I think I have at least four of those boxes. They're great to use with QuickStart boards.

    I think the way the touchpads respond is dependent on the local weather. I've used code others swear by that doesn't work for me and I've also had people think my code doesn't work well for them.

    I used my version in the QuickStart servo tester, I think it works great.

    I think the main thing is to get across to new users that you can't treat the touchpads as if they were buttons (without the appropriate code).
Sign In or Register to comment.