Shop OBEX P1 Docs P2 Docs Learn Events
Spin2 for Beginners -- Session 8 Files Available Now - Page 5 — Parallax Forums

Spin2 for Beginners -- Session 8 Files Available Now

1235

Comments

  • Happy New Year to you too!

    In the meantime, I was perusing some off-the-shelf rotary encoders datasheets, and it turns out my concepts on contact bouncing needs some healthy updating.

    When it comes to contact noise, even the cheaper encoders appear to be able to keep it within the vicinity of 2.0 - 5.0 mS, so those numbers should be kept in mind, when crafting the most convenient filter configurations.

    By simply relying on the -3_to_+3 phisical-pin-to-smart-cell mapping, you should be able to do simultaneous experiments with a wider selection of filterings, in order to find a sweet spot.
  • I put the Quadrature encoder on a scope and found that they must be digital devices as I did not see any contact type noise. I saw nice even square waves on each pin.

    What I did see was that sometimes there would be an A pulse but no B pulse or if going in the other direction a B pulse with no A pulse.

    At first I thought that this was a 5 volt device and that powering it with 3.3 volts was a issue. It did not make any difference.

    Mike
    824 x 447 - 21K
  • Hi iseries

    Any hint about the brand/model of the encoder you're using, in order to grab and display those signals?


    Henrique
  • I've attached an image file that I made that shows the character-set for the LCD we got as part of this project.

    I found a reasonably good copy of the character-set table and added additional information and examples for working with the Custom Characters (Character codes #0 thru #7) that you can define.

    Note: Character codes #8 thru #15 are duplicate copies of what are defined in #0 thru #7.

    jonnymac's "jm_lcd_pcf8574.spin2" driver works great with the Noyito Technologies 1602 IIC LCD.

    I hope you find the image/table useful when working with the LCD.
    1000 x 1000 - 421K
  • Hi

    Thought I would dig out one of my el-cheapo ebay encoders.
    Very noisy but tame-able with re-reading until n number of reads without a change. I use an adjustable constant for this and just tweek for best results.

    However having said that, this noisy encoder is completely tamed by adding a 0.1uF cap from the a/b pins to 0v, and using a pin pullup of 15k, no noise suppression software needed.
    As long as you don't attach a motor to the shaft you can't turn the shaft by hand quick enough to beat it.

    Dave
  • Roy ElthamRoy Eltham Posts: 2,996
    edited 2021-01-06 07:08
    Played around a bit using JonnyMac's Spin2 driver for the LEDs but calling it from FlexProp C. Hooked up my 241 LED ring set setup like a tree.
    Had to add various delays, otherwise everything flashed by too fast, and might have caused epilepsy attacks. :)


  • Nice, Roy!
  • I played a little more, and added the encoder using Jon's Spin2 driver for that.
    The encoder picks between the various modes you can see in the video above, and if you push the button then it toggles the encoder to adjusting the brightness instead of changing mode.

    I've attached the source file below, should compile and run with recent versions FlexProp, and uses the same pinouts for the encoder and LEDs as Jon's demos. I used the same or similar naming conventions for most things, and you can adjust everything in the #define's near the top of the code.
    However, it's set for 241 LEDs (and 100 candles), so you will likely need to change those down to lower numbers to match your LED setup. I recommend NUM_CANDLES be around 40% of N_PIXELS (e.g. use ~20 candles for 50 LEDs).

    Once Jon teaches us about using his code for the display, I'll add that in too.
  • Roy Eltham wrote: »
    ...
    Really cool, Roy!


  • Code for Week 3 is uploaded!
  • Dave,

    You commented -
    "However having said that, this noisy encoder is completely tamed by adding a 0.1uF cap from the a/b pins to 0v, and using a pin pullup of 15k, no noise suppression software needed.
    As long as you don't attach a motor to the shaft you can't turn the shaft by hand quick enough to beat it."

    I’m a software type try to learn electronics. Could you post a drawing of the circuit? So it's a bit clearer in my mind.

    Thanks,
    James

  • Another great presentation, really enjoy your style of discussing the P2 and coding. I’m starting to employ your coding style more as it is easier to review old code that hasn’t been visited in a while.
  • tritoniumtritonium Posts: 539
    edited 2021-01-07 14:10
    Hi jahenke

    This is how I did it.
    The capacitor value can be changed to suit your situation. For a noisy hand encoder 0.1uF worked well for me.
    I suspect a much smaller value may work.
    The resistors shown are either provided by you externally or by the prop using its programmable internal pullup in smartpins. As regards values the faster the coder spins the smaller the resistor needs to be. So using a better quality encoder driven by a motor, 2k pullup and 0.001uF might be better. Foe very high quality opto / capacitive / hall then no capacitor or debounce may be found to be satisfactory.

    I started by using software debounce-
    (if you're a software guy then this may look crude! :) )
    '
    	do
     		newread=input(acpin,bcpin)
    	loop until newread<>oldread
    	lcnt=mxcnt	                    'mxcnt is a constant found by trial and error
             do
    		if newread<>input(acpin,bcpin) then
    			lcnt=mxcnt          'top up downcounter
    		else
    			lcnt-=1
    		end if
    	loop until lcnt=0
    

    you'l need to click on the image to see it full size

    Dave
    471 x 338 - 44K
  • DiverBob wrote: »
    Another great presentation, really enjoy your style of discussing the P2 and coding. I’m starting to employ your coding style more as it is easier to review old code that hasn’t been visited in a while.
    Thank you, Bob!
  • Dave,

    Thanks, that really helped, and it's helping to set the words to how the wiring really goes.

    I don't mind crude code - and trying to show in a non-code editor is always a problem.

    Thanks, again.
    James
  • This was posted in another thread, but as this week's topic was I2C with the P2, I thought I'd share it here. This company provides low-cost I2C widgets.

    https://electricdollarstore.com/
  • Dave MatthewsDave Matthews Posts: 93
    edited 2021-01-11 11:13
    Many thanks to JonnyMac and Parallax, inc. for the great presentations, the P2 Edge, the Edge Module Breadboard, and the fantastic P2!

    Dave, KI4PSR
  • Many thanks to JonnyMac and Parallax, inc. for the great presentations, the P@ Edge, the Edge Module Breadboard, and the fantastic P2!
    Dave, KI4PSR
    Thank you, Dave!
  • JonnyMac wrote: »
    This was posted in another thread, but as this week's topic was I2C with the P2, I thought I'd share it here. This company provides low-cost I2C widgets.

    https://electricdollarstore.com/

    This is an interesting store, thanks for the heads up
  • Code for Week 4 is up. Be sure to update your Library as I've added files, and updated at least one of them.
  • The files for today's session on SPI communications are posted -- you can find them in the first post on page 1 of this thread.

    -- https://forums.parallax.com/discussion/172535/p2-christmas-lighting-project-beginner-intermediate-spin2-coding-week-5-files-available-now/p1

  • I won't be able to attend today, I'll have to watch the video.

  • We missed you today, Roy.

  • I wanted to share a decent SPI mode picture I found a
    few years ago, and so I put it into a pdf to use as a reference.

    Bill M.
  • Thanks Jon, I had a work meeting overlap, and also was feeling awful so I crashed early after the work meeting. I'll watch the video tonight and play along with my parts.

  • I wasn't feeling great yesterday, either. Better today -- and I hope you are, too. Have fun.

  • I am late to this (having just ordered the holiday kit in mid February.), but hopefully I can follow along with the prerecorded live sessions on YouTube. I see three sessions so far or are there others?
    RJ

  • @RetroJeff said:
    I am late to this (having just ordered the holiday kit in mid February.), but hopefully I can follow along with the prerecorded live sessions on YouTube. I see three sessions so far or are there others?
    RJ

    Rj, the code examples have also been incorporated into Quick Bytes https://www.parallax.com/propeller-2/quick-bytes/

    Welcome to the forums, BTW :smile:

    Ken Gracey

  • Week 6 files attached here

  • CJMJCJMJ Posts: 223
    edited 2021-02-11 01:16

    I missed the Live Forum today. I thought I checked the Events page yesterday but didn't see anything for today. When was this event posted? Also, would it be possible to list past events somewhere? I use to do this for my local chapter of IEEE when I was running their website. After the event I would move the announcement to a Past Events page and post the presenter's presentation there with any provided links from the presenter.

Sign In or Register to comment.