Thread Tools  
chowdy
Junior Member
 
Join Date: Oct 2013
chowdy is on a distinguished road Posts: 2
Hello,

Just purchased a StimTracker and using the interface to neuroscan EEG (http://www.cedrus.com/support/stimtr..._neuroscan.htm). So seems like I should have 8 event marker/trigger bits with which to send events from Matlab.So using serial.m in Matlab my commands are:

s1 = serial('/dev/cu.usbserial-AH01NEJ7', 'BaudRate', 115200,'DataBits', 8, 'StopBits', 1, 'FlowControl', 'none', 'Parity', 'none', 'Terminator','CR', 'Timeout', 400, 'InputBufferSize', 16000);

fopen(s1)


But now I get a little confused. Say I want to send a 10ms pulse, so first thing I need to do is set the pulse duration. According to the cedrus documentation (http://www.cedrus.com/support/stimtr...t_commands.htm) to set the time I need to use a "four byte binary value indicating the number in milliseconds" forming a "32-bit unsigned integer". So if I use matlab's decimal-to-binary converter for 10 I get:

dec2bin(10)
ans =
1010

But this is not a four byte binary value. To make this four bytes then I guess I need to add a bunch of 0's. Also from what I read, bits are read from right to left so the 0's should be placed on the left of 1010. So then to set the pulse duration to 10ms I would execute the command:

fprintf(s1,['mp',00000000000000000000000000001010]);


Then say I want to have this 10ms pulse on channel 3 (out of the 8 possible event channels available to me). The documentation states "mh followed by two 'bit mask' bytes (a binary value). In the first byte, each bit corresponds to an output line. The second byte is currently ignored". So if I understand things correctly in the first byte each bit represents the state of each channel - so to have all 8 channels off would be:
00000000
Then to turn on channel 3 (and remembering bits are read right to left) would be:
00000100
and then taking this and adding a second bit mask byte that is ignored, so will just make it all zeros:
00000000
means the Matlab command should ultimately look like this (since read right to left, the ignored byte is supposed to be second, so will add it to the left):

fprintf(s1,['mh',0000000000000100]


Is my understanding of this correct? If not, could someone else explicitly give their fprint() statements for 1) setting a pulse duration for some time (like 10ms), and 2) sending an event to one of the channels? It would be extremely helpful! (and ultimately I want to use IOPort.m commands since they apparently are more precise, but to begin with I figure I should understand serial.m commands)


Thanks so much!
David
Reply With Quote
psycit@vuw.ac.nz
Junior Member
 
Join Date: Aug 2013
psycit@vuw.ac.nz is on a distinguished road Posts: 6
Posted October 16th, 2013 #2
Hi David

Try sending the decimal equivalent of your bits and see if it will work.
Had the same issue before and was trying to send bits (even with 0x0101) but the decimal part works for me.

Cheers

Al
Reply With Quote
Hisham
Founder
 
Join Date: Aug 2006
Location: San Pedro, CA
Hisham is on a distinguished road Posts: 1,165
Posted October 21st, 2013 #3
We’ve just created a new web page that illustrates how to use the RealTerm terminal emulation program to interact with StimTracker. Of course, please do not hesitate to post any follow up questions after checking out that page.
Reply With Quote
Tags
matlab, stimtracker
Thread Tools
Posting Rules
Forum Jump:
© Copyright Cedrus Corporation, 1991-2014.
All times are GMT -7. The time now is 09:22 PM.