Page 1 of 1

Setting value between 0 and 10 with two buttons

PostPosted: Fri Sep 19, 2008 10:39 pm
by Robin Poenisch
Hi,

is there a way, to count a value up and down with two buttons connected to ADL2? I want to generate and send a value over CAN. This value must not leave the defined range (e.g. 0 to 10) and should decrement if button 1 is pressed and increment if button 2 is pressed. This value should be incremented/decremented only once every time a button is pressed.

thanx
Robin

Re: Setting value between 0 and 10 with two buttons

PostPosted: Tue Sep 23, 2008 5:25 pm
by DarrenR
Hi Robin,

There is a way to do this, but it is not an actual function. I've attached a configuration with the setup in it. It uses two GP off/on channels assigned to Switch input 1 and 2. These two channels are combined in a channel math function of one minus the other, to give a result channel (GP 1) that is -1 when one button is pressed and 1 when the other button is pressed, otherwise it is 0.
This is then applied to one axis of a 3D table with the other axis being the count number (GP 2). The data in the table is arranged so the result of the table (GP 3) is the same as GP 1 unless the count is 0 or 10, this limits the count to the range.
Another Channel Maths is used to add GP 3 to GP 2 where GP 2 is also the result of the function, Basicly GP 2 = GP 2 + GP 3. To stop GP 2 from running away while a button is pressed, the condition to run the Channel Maths is 'GP 1 Changed by 1'. This gives an edge trigger so the maths is only calculated when the GP 1 value actually changes.

This can be done slightly different ways, with limits and count by values changed to suit your needs.

Re: Setting value between 0 and 10 with two buttons

PostPosted: Tue Sep 23, 2008 7:00 pm
by Robin Poenisch
Thank you, Darren!
This config is exactly what i needed :P
I tried different things before by myself, but nothing was so easy to implement and to understand as yours.

Re: Setting value between 0 and 10 with two buttons

PostPosted: Mon Oct 13, 2008 1:11 pm
by ElectronSpeed
Nicely done Darren.

Re: Setting value between 0 and 10 with two buttons

PostPosted: Tue Oct 21, 2008 5:37 pm
by PQatPIT
Robin Poenisch wrote:Hi,

is there a way, to count a value up and down with two buttons connected to ADL2? I want to generate and send a value over CAN. This value must not leave the defined range (e.g. 0 to 10) and should decrement if button 1 is pressed and increment if button 2 is pressed. This value should be incremented/decremented only once every time a button is pressed.


Eehh, what is this used for? Counting fallen or not fallen flagpoles here and there :D

Re: Setting value between 0 and 10 with two buttons

PostPosted: Thu Sep 03, 2009 11:32 pm
by IDP
Does anyone have a method for doing this or something similar with an SDL?

Re: Setting value between 0 and 10 with two buttons

PostPosted: Mon Sep 21, 2009 11:58 am
by DarrenR
I haven't tried it, but you should be able to do the same function using 3D tables to do the maths.
So you would use three 3D tables, and put both switches through the user conditions with 'changed by 1' as the condition.

Re: Setting value between 0 and 10 with two buttons

PostPosted: Tue Sep 22, 2009 1:49 am
by thorstengsxr
Hi

I think one of the mayor problems is, that you can't save gp3 if you switch off the sdl

regrads Thorsten