60 likes | 143 Views
Mark I Interface Usage Notes. Glenn Jones July 13, 2006. I have included the Windows USB drivers and some Matlab routines that I used to test so you can try those out.
E N D
Mark I Interface Usage Notes Glenn Jones July 13, 2006
I have included the Windows USB drivers and some Matlab routines that I used to test so you can try those out. • I don’t have an interface spec for the raw commands yet, but the commands and data format can be easily figured out from the PIC code and the Matlab routines. • I modified the PIC code slightly so now it doesn’t miss the falling blanking signal even if it is in the middle of transmitting data.
Linux stuff • Here are some application notes giving programming advice. The particular chip I used is the FT232R. http://www.ftdichip.com/Documents/AppNotes.htm • There are two types of USB drivers, Virtual Com Port (VCP) and direct (D2XX). I have been using the VCP driver exclusively without trouble, though you may want to look into the D2XX if you think it may help. I have not tried any interface stuff under linux. The drivers are located here: http://www.ftdichip.com/FTDrivers.htm • The Windows VCP driver I included is NOT the same as the one on the website. I modified it so that when you set the virtual com port to 600 baud, it actually sets the chip up to do 250kbaud. This is explained in this appnote: http://www.ftdichip.com/Documents/AppNotes/AN232B-05_BaudRates.pdf I think probably a similar thing can be done under linux. • The PIC UART is configured for 250kbaud
Starting up Matlab • When you get the USB driver installed correctly using the drivers I included, check to see which COM port it is assigned to. Edit init.m to reflect this COM port. • init.m sets up the COM port object ‘I2Cser’, which must be the first argument to all of the other routines. (you can name it something else if you like) • To test communications, try sending:set_atten(I2Cser,2,’FF’) • You should see something like this:>> set_atten(I2Cser,2,'FF') • cmd = • `S02FFA1~ • ans = • `S0~ • If not, try sending a couple more times.. I find it takes sending a few commands at startup to get the UARTs synched up. • At the end of the Matlab session, run closedown.m to free the COM port. If you accidentally clear I2Cser, the instrfind command is very useful.
I added comments describing usage of all the useful Matlab routines, thus look there to see how to use them. The main commands you probably want to use for testing are: SetPICint – Set the PIC to generate a blanking signal SetExtBlank – use an external blanking signal on the BNC connector ReadFor – take data for x seconds Matlab commands
A typical matlab session might look like this: >> init % setup the serial port >> set_atten(I2Cser,2,'FF') % Select the 1000 MHz filter and set the attenuator to 0dB cmd = `S02FFA1~ ans = `S0~ >> set_atten(I2Cser,2,'01') % Select the 500 MHz filter and set the attenuator to 16 dB cmd = `S020075~ ans = `S0~ >> SetPICint(I2Cser,0.01,0.1); % set the pic blanking to 10 ms high, 100ms integration cmd = `PFFB3FCF4B4~ % FYI this is what the command to the pic looks like status = `P~ % successful reception >> [tp st] = ReadFor(I2Cser,1); % Tell the pic to give you 1 second worth of data cmd = `IFF35~ % Random inner workings cmd = `I0009~ status = Vlid ¤Ù ¦\ `I~ cmd = `I0009~ status = `I~ ans = Dataset size: 547 Found 8 headers % This means that it received 547 bytes which it parsed into 8 sets of 8 % channels worth of total power >> plot(tp(3,:)) % look at the results for a channel. >>[tp st] = ReadTPn(I2Cser,10) % Tell the pic to give you the data from the next 10 blanking signals it sees cmd = `I0A1A~ ans = Dataset size: 683 Found 10 headers % found all 10 >> SetExtBlank(I2Cser) % change to external blanking mode cmd = `XB8~ status = `X0~ % indication that the command was understood >> closedown % All done, so clean up the COM port