From: Shane M. <smu...@ob...> - 2012-05-02 13:49:32
|
James, COM ports (i.e., serial ports) work by sending bytes sequentially at a specific rate (e.g., 9600 baud I think means 9600 chars/sec). I'm not sure how the pinout structure on the serial cable really works, but I think there are 8 signal bits/pins and a ground. If you are using an application that is monitoring one pin, you should be able to compute how many cycles at the baud rate are needed for the pulse and send a character string that has a 1 in that pin equal to the length of the time you want. If 9600 baud means what I think it does, that is about 10 characters/ms, so sending a character string of roughly 150-160 letters would be about right. I'd guess that this whole setup might be a bit touchy though, and is not typically how serial ports are used. Parallel ports are a bit simpler in this respect I think, because you can essentially turn a pin on and off again whenever you want; and this may be what wuold be easiest for your application. And the DLP-IO8 works like that too (and can be had for under $30), but uses the comport interface so you send it messages to turn bits on and off when you want. Similarly, the Cedrus buttonbox uses the same serial port interface, and has some functionality to control TTL signals. I've got basic functionality for the cedrus in PEBL, but haven't tried out the TTL interface stuff. Send me more info on your hardware setup and I'll see if I can help. Shane > I have a follow on question. > > Can the "ComPortSendByte" send a 16ms pulse? Or is it only limited to > characters? > > Thanks for all your help > > James Fielder > US Army Aberdeen Test Center > (410) 278-4080 DSN 298 > jam...@us... > > > -----Original Message----- > From: Shane Mueller [mailto:smu...@ob...] > Sent: Thursday, March 29, 2012 2:27 PM > To: Fielder, James E CIV (US) > Cc: peb...@li...; Buxton, James A CIV (US) > Subject: Re: [Pebl-list] COMPort usage > > James, > > The basics of comport are fairly simple, as there are only three > functions . Basically, you open a comport with a command like: > > > dev <- OpenComPort(13,9600) > > > where 13 is the com port number (more on this later), and 9600 is the > baud rate. > > > Then, you can get bytes from the port using: > > byte <- ComPortGetByte(dev) > > and send bytes using: > > ComPortSendByte(dev,char) > > > > Now, char is a single-character letter you want to send. byte is a > numeric value that gets passed from the device, which you can convert to > text using the NumToASCII() function copied below. > > Now, the example above uses 13 because that is what the USB serial port > emulator assigned to the particular device I was using in this example > (the cedrus button box). A number of devices that use the FTDI chip > will emulate a com port over usb. Look at the following for more > information about how to determine what port your device is using, if > you are indeed using such a device: > > http://www.ftdichip.com/Support/Documents/AppNotes/AN_132_Re-Assigning_COM_Port_Numbers_Using_Registry.pdf > > I don't think there should be any additional drivers necessary; I think > the ones I have tried out just worked, but if the usb com emulator you > are using is based on the FTDI chip (which is very likely), you can > download their drivers here: > > http://www.ftdichip.com/FTDrivers.htm > > > Let me know if you have any more specific questions; and if you can tell > me in more detail what devices you are using, I may be able to help. > > Shane > > > > define NumToASCII(num) > { > > letters <- [" ","!",gQuote,"#","$","%","&","'","(",")","*","+",",","-", > ".","/","0","1","2","3","4","5","6","7","8","9",":",";", > "<","=",">","?","@","A","B","C","D","E","F","G","H","I", > "J","K","L","M","N","O","P","Q","R","S","T","U","V","W", > "X","Y","Z","[","\","]","^","_","`","a","b","c","d","e", > "f","g","h","i","j","k","l","m","n","o","p","q","r","s", > "t","u","v","w","x","y","z","{","|","}","~"] > > > if(num==13) > { > val <-CR(1) > }elseif(num>=32 and num<=122) > { > val <- Nth(letters,num-31) > } else { > val <- "["+num+"]" > } > > return val > } > > > > On Thu, 2012-03-22 at 16:38 +0000, Fielder, James E CIV (US) wrote: >> Has anyone been able to successfully send triggers to an external device >> from PEBL. I'm trying to send a pair of pulses to an EEG to trigger the >> start of the experiment. My electrical engineer has questions about USB >> drivers and special cables. Isn't the USB driver already contained >> within PEBL and is activated when the OpenCOMPort function is used? >> Any clarification on how to use the COMPort function would help. >> >> Thanks >> >> James Fielder >> US Army Aberdeen Test Center >> (410) 278-4080 DSN 298 >> jam...@us... >> >> >> >> ------------------------------------------------------------------------------ >> This SF email is sponsosred by: >> Try Windows Azure free for 90 days Click Here >> http://p.sf.net/sfu/sfd2d-msazure >> _______________________________________________ >> Pebl-list mailing list >> Peb...@li... >> https://lists.sourceforge.net/lists/listinfo/pebl-list > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Pebl-list mailing list > Peb...@li... > https://lists.sourceforge.net/lists/listinfo/pebl-list > |