Nuts & Volts question for Johnny Mac
w4fej
Posts: 264
First off, I am new to the Prop coming from the Basic Stamp. I learn by looking through different program listings and figure out how the program works by seeing how others do things.
Nuts & Volts Column 6, May 2010: Spinning Up Fun With Encoders.
I have firgured out how most of the program example works and have been trying to figure out how to adapt it to my needs. The only thing I can't get my head around is the "HiLimit and LoLimit" you mention in the article. (-100, +100). Is that number the number of "detents" your encoder had?? The encoder I am using is the Parallax 27805 which has 16 detents per revolution. Would the Hi/Lo be -16, +16 for my encoder??
Could you shed some light on this Hi/Lo limit value referenced in the article?
Thanks, Mike B.
(P.S. I Love the N/V articles. I've learned a ton from them).
Nuts & Volts Column 6, May 2010: Spinning Up Fun With Encoders.
I have firgured out how most of the program example works and have been trying to figure out how to adapt it to my needs. The only thing I can't get my head around is the "HiLimit and LoLimit" you mention in the article. (-100, +100). Is that number the number of "detents" your encoder had?? The encoder I am using is the Parallax 27805 which has 16 detents per revolution. Would the Hi/Lo be -16, +16 for my encoder??
Could you shed some light on this Hi/Lo limit value referenced in the article?
Thanks, Mike B.
(P.S. I Love the N/V articles. I've learned a ton from them).
Comments
I'm also a fan of JonnyMac's articles.
I'm pretty sure his use of limits is just for your own needs.
What is your encoder controlling? If it's controlling oven temperature then you might have the low limit be 100 and the high limit 500. It doesn't make sense to set your oven to -100 so you wouldn't use the end point examples in Jon's article.
My encoder sets my guitar amp volume, so I have the end points set to 0 and 11.
BTW, my Mecanum wheeled robot monitors four quadrature encoders using a program based on JonnyMac's encoder code.
BTW, I appreciate the kind words by both of you. I do work hard to make my column educational (without being overwhelming) and entertaining.
Ok, the encoder will be used to scroll through several "menus" on a remote control device. I want to be able to scroll forwards and backwards. If I hit the highest menu then I want it to roll over back to the first menu etc.. The encoder I am using doesn't have a button however I have a "select" button right next to the encoder so in effect It has one. Let's say I have 7 different menus I want to scroll through, would the limits then be +7 to -7? Is the negative number to indicate the opposite direction of rotation? Or would my limits be 0 or 1 and 7??
Thanks again and keep spining..
Mike B.
Edit: I think a light bulb just went off on this question. Doooh... If I have seven menus then the limits would be 1 to 7 thus not allowing for a value of say 8 or 9 etc. Sometimes you just can't see the stinking forest through all those darn trees!
Then you could determine menu choice by using the modulus operator:
The range of "menuChoice" would be from 0 to 6. This will allow the desired "roll over" effect you want.
Instead of using one billion exactly, you could choose a starting value where the above equation gives you the memu choice you what to start with. For example if you want "menuChoice" to equal zero before the encoder is turned, you would set the start value to 999,999,994 or 1,000,000,001.