slider control with power button limit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello everyone,

   

1.  I Have a 4 BTNS available to me for my slider.

   

2.  The slider consists of 4 stage operation.

   

3.  I do not hold an extra BTN for the ON-OFF control.

   

4.  How would I get the slider working ok if the conditions are-

   

      a>  #1 BTN = #1 LED ON & slider ON;     rest LEDs OFF

   

      b> #2 BTN = #2 LED ON;      rest LEDs OFF

   

      c> #3 BTN = #1 & #2 both LEDs ON;      rest LEDs OFF

   

      d> #4 BTN = # 4 LED ON;        rest LEDs OFF

   

      e> when I return (touch) to #1 BTN while slider is ON, slider should turn OFF

   

      f> Then repeat the ( a> to e> ) steps.

   

5. When I again press the #1 BTN (even time touch @#1 BTN should turn OFF (power Off) the slider & odd time touch @#1 BTN should turn ON (power On) the slider) it should turn off the slider, i.e. power Off.

   

6. At any point of operation for the even touch slider is off.

   

7. At any point of operation for the odd touch slider is on.

   

8. When #1 BTN is off i.e. slider is off no other segment of slider is in operation.

   

Can i do this in the abov specified circumstances, guide on the same.

   

Thanks & Regards-

   

Amit

0 Likes
9 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A slider has several segments and the CapSense is interpolating the touch to give a result that is of finer grade than just the number of segments.

   

Buttons are different and are single points of sensing a finger press, so do not mix them.

   

Your problem seems to be soved easily with a technique named "State machine".

   

Make a table for each state (give it a number, better a name) and write down what elements are on or off and what event causes a transfer to what state.

   

This can be programmed easily to fulfill all your requirements using a C-switch statement, preferrably using named states (enum is good for that), so that you can see what your  state machine performs.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Hello Bob,

   

I ment that I have 4 segments available. For the simplicity I mentioned it as buttons.

   

I have designed my board with a bit bigger size thean the standard board. I'm using the slider centroid algorithm for it.

   

Can you suggest me notes on 'state machines', C-switch statement & enum.

   

           The problem I have is I'm trying to implement 5 states while the controling switches I have is 4. I have implemented the slider with 4 states & 1 contolling button for ON-OFF. Now I wish to reduce that button from combo of 1BTN+4SLDRsegments, but without loosing the ON-OFF control.

   

Thanks & Regards-

   

Amit

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You should google for the items you don't know or ask Mrs. Wiki Pedia for explanations.

   

The exact syntax you will find in a C-Book like this: publications.gbdirect.co.uk/c_book/ which you may read online.

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Dana, did you get a VERY broad monitor for birthday?

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Here also is a good C book.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi Dana, Bob & all, check this out & tell me how to implement & run the state diagram in PSoC for the conditions I have mentioned.

   

Find the details in the attachment.

   

Thanks & Regards-

   

Amit

0 Likes
Anonymous
Not applicable

Thanks Dana the application notes were of real help understanding the state m/c part.

   

Regards-

   

Amit

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest would be now to create a table from your state diagram.

   

Here is an example

   

| State Name   |  Actions to take    | Events and State Transfers     | Comment
________________________________________________________________________________________________
| StInit            | All LEDs Off          | SW1: StBootLoad                  | Initialization
|                     | PWR LED On       | Nothing: StWaitProxi              |
|_______________________________________________________________________________________________
|StWaitProxi   |                             | Proxi: StSeeProxi                  | Wait for proximity switch
|_______________________________________________________________________________________________
|StSeeProxi    | LED1 On               | Button1: StBtn1                     | Handle button presses
|                    |                              | Button2: StBtn2                     |
|_______________________________________________________________________________________________
|
| StBtn2       | ..... And so on.

When the table is complete, you declare an enum with all the state names.

   

Then with a switch statement you write for all the cases (States names) what to do and where to go to when which event occurs like

   

if(Button1) NextState = StBtn1;

   

all this goes into a single function or into main() from which you break out only in case of an error.

   

 

   

Bob
 

0 Likes