Hi,
I have now finally come to a stage with my organ project at which I can start scripting my ngr file. In order to speed up my keyboard scans I have used the relatively new option to define the maximum number of shift registers (SRIO num_sr=16) which I think might explain the behaviour which I’m describing in the following.
I played a bit around with the scripting and in particular the delay functions. The script was as simple as:
if ^section == 0
Log "start"
delay_ms 1000
Log "end"
endif
The script was fired on a button press. But rather than seeing a delay of 1 sec between the two messages I saw only half a second. Could it be that the delay_ms is somehow coupled to the defined number of shift registers and that by halving that my delays halve as well?
Another thing I noticed is that if I press the button while the previous script is still running it seems to abort the script and start it again. Is that intended behaviour? Meaning:
<press button first time>
MIOS studio: “start”
<press button another time>
MIOS studio: “start”
<wait>
MIOS studio: “end”
This brings me to my specific application and I was hoping someone could give me an idea of how to approach this, as if done wrong I can fry quite a bit of my equipment.
I have stop action magnets (SAM) for the organ. Those have a digital output (reed switch) indicating if they are on or off (normal DIN). You are also able to automatically change the switch over to a certain position. For this the SAM carries two coils, one used to switch the SAM on and one to switch it off (DOUT/LED with ULN darlington transistor). The coils are operated with a 15V PSU, draw 0.5A current and are quite small … too small as if they could dissipate 7.5W. It is therefore key that neither coil gets activated for longer than ~100ms as otherwise I would risk to burn out the coil. There are now two operational modes which the controller needs to cater for:
Firstly: it needs to be possible to manually change over the SAM. The controller should recognise this and send out a midi signal to the computer (cc signal)
Secondly: An automatic change is requested by an incoming midi signal (same cc signal).
- If the SAM is already in the requested position: don’t do anything.
- the requested value is different
- The script should now disable the opposite coil (just in case it was still active)
- it should activate the correct coil
- wait for 100ms (I do not want to wait on the din as if the button is stuck we get to a situation where the current stays on indefinitely)
- switch the coil off (probably best to switch every coil off)
- if the digital input flips it should ignore this and not send out a midi signal as it is simply obeying a command. The computer expects the command to
having been executed and doesn’t need confirmation
Now the things I’m worried about. I have 43 of those SAMs and a lot of commands can come in in quick succession. The ngr file takes about 5ms to load for each called script section. How can I ensure that the coils are actually being switched on if a successive script call is going to cancel the previous one which started less than 5 ms ago and hasn’t activated the coil yet? Then how can I ensure that the coils are switched off after 100ms and lets say an absolute maximum of 200ms: Let’s say I alternate through all 43 SAMs with 10ms delay. That means the new coils would all get set but the delay_ms will never finish and no coil would ever get switched off.
It would be great if someone more experienced could shed some light on how to best approach the problem
thanks a lot
best regards
Mathis