Jump to content

How to use buttons connected to a Ainser64 as toggle buttons?


dOperator

Recommended Posts

Hi,

dusted off my unfinished midibox_ng ... so i got all encoders, LEDs and buttons working, but i can't figure out how to use buttons connected to a ainser64 module as toggle buttons.

(I wanted to use analog pots for the encoders at first, but decided for digi encoders later, so thats why all my buttons ended up on the ainser64 module.)

 

My first try was something like:

EVENT_BUTTON id=1041 range=0:80 button_mode=toggle fwd_id=LED:144
EVENT_AINSER id=41 ain_sensor_mode=NoteOnOff if_equal=80 fwd_id=BUTTON:1041

which does toggle the button on, but doesn't turn it off again. Tried a couple of other ideas too (conditional events, depending on the buttons state) .. but no matter what i do i don't get it to toggle on and off.

 

Is it possible? Just missing something obvious (just starting to get into the config options)?

Thanks a lot :)

Link to comment
Share on other sites

Hmm, sorry....

Whats about using a ngr script?

 

ngc

EVENT_AINSER id= 41 type=meta    meta=RunSection:2 range=0:127

ngr

if ^section == 2
    if (hw_id)AINSER:41 > 100
    set Button:1041 80
    else
    set Button:1041 0
    endif
endif

 

Best regards

Marxon

Edited by Marxon
  • Like 1
Link to comment
Share on other sites

Thx TK!

 

In case somebody is in the same situation, i figured sth like:

EVENT_AINSER id= 41 range=0:1 type=meta ain_mode=Snap  if_unequal=0 meta=RunSection:1 
EVENT_BUTTON id=1041 button_mode=Toggle type=CC chn=1 cc=1 range=0:127 fwd_id=LED:144

and

if ^section == 1
    if Button:1041 > 0
        set Button:1041 0
    else
        set Button:1041 127
    endif
endif

works way better than the code above (didn't allways trigger correctly, double trigger etc.)

Link to comment
Share on other sites

  • 2 weeks later...

Could you please try following version: http://www.ucapps.de/mios32/midibox_ng_v1_030_pre2.zip

 

It supports the new "ain_mode=Switch", which should work much better:

   o added ain_mode=Switch for AIN and AINSER events.
     Can be used if buttons are connected to analog inputs. The event will send the
     min value if a 30% threshold is reached, and the max value if a 70% threshold
     is reached.
     Schematic:  Ground |----o Button o-----> analog input + 10k Pull-Up resistor to 3.3V (AIN) resp. 5V (AINSER)

No .NGR hack required anymore :)

 

I tested this with:

EVENT_AINSER id=  1  type=CC     ain_mode=Switch  chn= 1 cc= 16   range=  0:127 offset=  0  ports=1000100000001000  lcd_pos=1:1:1  label="^std_aser"

 

Best Regards, Thorsten.

Link to comment
Share on other sites

Hey,

First, thanks, that was fast! :smile:

Just tried it, but it doesn't work for me. I guess that's because i wired the buttons differently.

My Buttons are Vd ----o Button o---- analog input .. and i added a 220 ohm resistor from pin #3 to #8 on the ainser64 4051's, to get rid of random messages.

No idea what i am doing there, really, just tried things until it worked :o

Will that setup potentially damage my hardware?

I'm considering to rewire the buttons, but it's some work, and it is actually working pretty nice with the hack for now.

 

When i set the range very low, something like 0:4 it does work like a standard 'press' button, but it doesn't toggle on/off .. with higher settings it doesn't trigger at all, or triggers once, but not again.

 

EVENT_AINSER id= 41 type=CC ain_mode=Switch chn=1 cc=16 range=0:3 offset=0 fwd_id=LED:144 lcd_pos=1:1:1  label="^std_aser"
[6010.478] MBNG_AINSER_NotifyChange(41, 2578)
[6010.480] [EVENT] id=AINSER:41 hw_id=AINSER:41 bank=0 fwd_id=LED:144 type=CC value=0 label=^std_aser
[6010.480] MBNG_DOUT_NotifyReceivedValue(144, 3)
[6010.581] MBNG_AINSER_NotifyChange(41, 0)
[6010.581] [EVENT] id=AINSER:41 hw_id=AINSER:41 bank=0 fwd_id=LED:144 type=CC value=3 label=^std_aser
[6010.581] MBNG_DOUT_NotifyReceivedValue(144, 0)

 

Link to comment
Share on other sites

Ok, I see!

In the hysteresis function I haven't considered that somebody could use the new switch mode with a reduced range.

This should be fixed now: http://www.ucapps.de/mios32/midibox_ng_v1_030_pre3.zip

 

But you have to change your hardware as well.

(don't worry, no risk for damage!)

 

One side of the button should be connected to ground, the other to the analog input.

And the Pull-Up resistor is mandatory, otherwise the input will float when the button is not closed, and this will result into random MIDI events.

 

The other unused inputs can be connected to ground directly, no need for 220 Ohm resistors.

 

Best Regards, Thorsten.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...