Please help me to understand how the NG app works internally

Could you please post your complete .NGC and .NGR file? I will check it tomorrow…

Best Regards, Thorsten.

Ok, i got it working. I just quit MIOS Studio, disconnected the core and than restarted everything.

There is some strange stuff going when i edit and save NGC/NGR scripts in MIOS Studio. It looks like sometimes the core is not restarted/refreshed correctly. I’ve no idea what the problem is.

 

 

Here is my simplified NGC. (NGR posted above)

I removed everything not related to the remaining problem (enabled and dimmed LEDs).

If upload this config both LEDs are lit and dimmed. But when i uncomment KEYBOARD n=1 … all J5A related scripts work as expected.

Could there be a conflict regarding the shift registers?

# Reset to default RESET\_HW # KEYBOARD hardware KEYBOARD n=1 rows=8 dout\_sr1=1 dout\_sr2=2 din\_sr1=1 din\_sr2=2 din\_inverted=1 break\_inverted=0 din\_key\_offset=32 \ scan\_velocity=1 scan\_optimized=0 note\_offset=36 \ delay\_fastest=5 delay\_fastest\_black\_keys=0 delay\_slowest=100 EVENT\_KB id=1 type=NoteOn chn=1 key=any use\_key\_number=1 range=0:127 lcd\_pos=1:1:1 label="Note %n" # J5A PORT SETUP # J5.A0 -\> octave up switch # J5.A1 -\> octave up LED # J5.A2 -\> octave down switch # J5.A3 -\> octave down LED # now enable DIOs (0 = input / 1 = output) DIO port=J5AB emu\_din\_sr=1 emu\_dout\_sr=1 output\_mask=01010000 # button events (DIN SR1 pins are assigned to hw\_id=1/3) EVENT\_BUTTON id=1 hw\_id=1 type=CC chn=1 cc=16 range=0:127 fwd\_id=LED:2 EVENT\_BUTTON id=2 hw\_id=3 type=CC chn=1 cc=17 range=0:127 fwd\_id=LED:4 #EVENT\_BUTTON id=1 hw\_id=1 type=Meta meta=RunSection:1 button\_mode=OnOnly #EVENT\_BUTTON id=2 hw\_id=3 type=Meta meta=RunSection:2 button\_mode=OnOnly # LED events (DOUT SR1 pins are assigned to hw\_id=2/4) EVENT\_LED id=3 hw\_id=2 type=CC chn=1 cc=16 range=0:127 EVENT\_LED id=4 hw\_id=4 type=CC chn=1 cc=17 range=0:127

 

 

Yes, there is a conflict with the shift register assignments.

Try this one:

# now enable DIOs (0 = input / 1 = output)
DIO port=J5AB emu_din_sr=9 emu_dout_sr=9 output_mask=01010000

# button events (DIN SR1 pins are assigned to hw_id=65/67)
EVENT_BUTTON id=65 hw_id=65 type=CC chn=1 cc=16 range=0:127 fwd_id=LED:66
EVENT_BUTTON id=67 hw_id=67 type=CC chn=1 cc=17 range=0:127 fwd_id=LED:68
#EVENT_BUTTON id=65 hw_id=65 type=Meta meta=RunSection:1 button_mode=OnOnly
#EVENT_BUTTON id=67 hw_id=67 type=Meta meta=RunSection:2 button_mode=OnOnly

# LED events (DOUT SR1 pins are assigned to hw_id=66/68)
EVENT_LED id=66 hw_id=66 type=CC chn=1 cc=16 range=0:127
EVENT_LED id=68 hw_id=68 type=CC chn=1 cc=17 range=0:127

Best Regards, Thorsten.

Thank you very much

I’ll give it a try later.

I’m a little baffled how the SRs and IDs relate to each other and would like to understand how you determined that emu_din_sr/emu_dout_sr must be 9 (and the IDs continue at 65). Does the KEYBOARD config occupy 64 IDs somehow?

Is there something to read in the docs about that?

 

In your code you had assigned SR1 to both the keyboard and the DIO (J5A) module. This is invalid. You have to use a SR number that it not in use.

And the last pin on the 8th SR is Pin 64 (8x8). So the first pin on the 9th is 65. 

Thank you very much

Are 8 SRs in use because the DIO module is configured as a matrix for keyboard scanning?

I don’t properly understand what these parameters mean:

KEYBOARD n=1 rows=8 dout\_sr1=1 dout\_sr2=2 din\_sr1=1 din\_sr2=2

Looks like there are 4 SRs (2 in / 2 out) in use or is it only two? What does dout_sr1=1 mean? Is 1 an unique identifier?

43 minutes ago, tago said:

Are 8 SRs in use because the DIO module is configured as a matrix for keyboard scanning?

I don’t see the reason why TK choosed sr=9 as emulated shiftregister. But anyway: When working with emulated elements (same is valid for button- & LED-matrices f.e.) it’s always good to use a value that is definitely not blocked by real hardware.

The keyboard blocks the first two digital input-SRs (usually HC165) and the first two digital output-SRs (usually HC595). 

dout_sr1=1 means the first HC595 in the digital chain. din_sr1=1 means the first HC165 in the chain. For a beginner this might be confusing. 

In NG you can set the total number of scanned shiftregisters with this command:

SRIO num\_sr=2

Even though in this example I set num_sr=2 I can connect in total 4 shift registers. 2x HC165 and 2x HC595.

As mentioned by Christian, there was no special reason why assigned DIN and DOUT SR #9 to the DIO function.

I thought this might be better in case you would like to add more physical SRs in future, no need to change the IDs again until you reach #9. If you don’t like this, you could also use SR #3, but not SR #1 or SR #2, because these positions are already allocated by the scan matrix.

Btw.: the most simple way to find out the hw_ids is to enter “set debug on” in the MIOS terminal, then trigger the buttons and observe the debug messages in the terminal (doesn’t work with LEDs of course, but if you know the button position, you can easily conclude on the LED position)

Best Regards, Thorsten.