+xHi Inquisit Team,
I'm using the <port> element in Inquisit 5 and a d/a-changer to control a device for electrical stimulation (STMISOLA, BIOPAC). The d/a changer has a parallel port and transforms the 8-bit input from Inquisit to a 0-2,55V signal, which is used to control the electrical stimulator.
Because of individual differences in sensitivity to electrical stimuli in humans, we need our scripts to be easily adjustable to individual thresholds of participants. Thus, we programmed <openended> elements in the beginning of our scripts, where we first register individual information for the stimulation as decimal numbers. Then, I want to use the openended.NAME.response to flexibly adjust the /items attribute of the <port> element with a given formula. E.g., if stimulating with 6.4mA, I need the port to output the number 64. I tried incorporating my formula [<%(openended.schmerz.response + 0.6* (openended.toleranz.response - openended.schmerz.response)*10%>]in the /items attribute [/ items = (<%openended.schmerz.response + 0.6* (openended.toleranz.response - openended.schmerz.response)*10%>)], which gave me an error:
"-1 is invalid. Value must greater than 0."
Next, I defined this as an <item>, e.g. named staerke60, and tried to read in this in the <port> element. Interestingly, now the scripts starts, but again produces errors after finishing/quitting, e.g.:
'64' is not a valid setting.
I found in the description for <item>, that in ports they must be written as binaries in "". However, the in the <port> and respective / items description, using decimals in parantheses is mentioned, too. And when using decimals regularily, not flexibly via <% %>, it works just fine.
So am I correct, that the error occurs, because my calculation in <% %> produces a decimal, but when using a calculation, the <port> only accepts binaries? If so, do you know any simple and short workaround for this? I'm not sure, if I can again transform my decimal do a 8bit binary with the mathematical operations included in Inquisit, but maybe you have more experience with that?
Another option could be defining every decimal from 0 to 255 in a single <port> element each and choosing these elements flexibly based on the openended value. However, that would heavily enlarge the script, which I would like to avoid if anyhow possible.
Thanks a lot in advance for any help and suggestions.
Best,
Mattis
PS.: the script is attached. Sorry for the German parts here and there, but I hope it is still understandable.
Try something like this:
<expressions>
/ s60 = evaluate((openended.schmerz.response + 0.6* (openended.toleranz.response - openended.schmerz.response))*10)
/ s70 = evaluate((openended.schmerz.response + 0.7* (openended.toleranz.response - openended.schmerz.response))*10)
/ s80 = evaluate((openended.schmerz.response + 0.8* (openended.toleranz.response - openended.schmerz.response))*10)
/ s90 = evaluate((openended.schmerz.response + 0.9* (openended.toleranz.response - openended.schmerz.response))*10)
/ s95 = evaluate((openended.schmerz.response + 0.95* (openended.toleranz.response - openended.schmerz.response))*10)
</expressions>
********************************************************************************************
******PARALLEL PORT TRIGGERS********
********************************************************************************************
<port pain_on60>
/ items = (0)
/ port = lpt1
/ subport = data
</port>
<port pain_on70>
/ items = (0)
/ port = lpt1
/ subport = data
</port>
<port pain_on80>
/ items = (0)
/ port = lpt1
/ subport = data
</port>
<port pain_on90>
/ items = (0)
/ port = lpt1
/ subport = data
</port>
<port pain_on95>
/ items = (0)
/ port = lpt1
/ subport = data
</port>
with
<block preperation>
/ onblockend = [
port.pain_on60.setitem(expressions.s60, 1);
port.pain_on70.setitem(expressions.s70, 1);
port.pain_on80.setitem(expressions.s80, 1);
port.pain_on90.setitem(expressions.s90, 1);
port.pain_on95.setitem(expressions.s95, 1);
]
/ trials = [1=schmerz; 2=toleranz; 3=start]
/preinstructions = (welcome)
</block>
You need to make sure that your values stay within range, though, i.e. if any of the expressions take on a decimal value greater than 255, you'll encounter errors.
Alternatively, if you prefer to convert from a decimal to an 8-bit binary string, this can be implemented like so:
https://www.millisecond.com/forums/FindPost4530.aspxHope this helps.