use https for features.
text: sort by
tags: modified
type: chronology
Given proper implementation of fixed-point sine and cosine, we present the C portion of our microstepping controller below, hopefully commented to a sufficient extent to make it intelligible and to document the logic behind our design.

#include <msp430x54x.h>
#define INCR 1
#define PI2 (12868) //we use a 11 bit fixed-point representationf of motor angles.  
	// 12867 = 2*pi*2^11.  
#define TIMER_SCL	128
#define SHUTTER_CLOSED 	0 //defines used in the state-machine control of the shutter. 
#define SHUTTER_OPEN	1

	//Start of Stepper Motor Program
	//ME270 Project

short theta1 = 0; //the MSP430 is a 16-bit processor. 
short theta2 = 0; //hence, most datatypes should be 'short' for efficiency.
short theta1_v = 0; //we cannot control the poition of the stepper motors directly, 
short theta2_v = 0; // since we only have 3 bits of control from the parallel port. 
// also, direct position control of postion would cause the stepper to miss steps 
// smooth position change and limited acceleration is guaranteed by controlling the velocity. 

short shutter_state = 0; // none of the steppers have encoders, 
	// so we keep track of the shutter position here.  
short shutter_cmd ;  //this is set in ISR (interupt service routine) 
	// and read, and acted upon, in the main loop. 

short qsin(short i){
	//i goes from  0 pi/2 base 11 or... 
	// 0 to 3217
	short cube, fifth, result; 
	cube = mply_11(i,i);
	cube = mply_11(cube, i); 
	fifth = cube; 
	fifth = mply_11(fifth, i);
	fifth = mply_11(fifth, i); 
	//our approximation to sine based on taylor series: 
	//original: sin(x) = x - x^3/3! + x^5/5!
	//sin(x) = x - x^3/(8+32+128) + x^5/128 
	result = i - 
		((cube >> 3) + (cube >> 5) + (cube >> 7)) + (fifth >> 7);
	//result is base 11.  need it to be base 7. (0 to 127)
	result = result >> 4; 
	if(result > TIMER_SCL) result = TIMER_SCL; 
	return (short)result; 

// this is an even more simplified version of sin - 
// made in an attempt to make the microstepping smoother. 
// it turned out to not matter very much.  to get very smooth stepping , 
// may have to develop an inverse model of the nonlinear stepper motors 
// ** quantitatively **
short qsin2(short i){
	//i goes from  0 pi/2 base 11 or... 
	// 0 to 3217
	short cube, result; 
	cube = mply_11(i,i);
	cube = mply_11(cube, i); 
	//our approximation to sine based on taylor series: 
	//original: sin(x) = x - x^3/3! + x^5/5!
	//sin(x) = x - x^3/(8+32+128) + x^5/128 
	result = i - (cube >> 3) ;
	//result is base 11.  need it to be base 7. 
	result = result >> 4; 
	if(result > TIMER_SCL) result = TIMER_SCL; //maximum..
	return (short)result; 

short isin(short i){
	// i is base 2^11
	//but we accept 0 to 2*pi or 12867
	if(i >= 0 && i < 3217) return qsin(i); 
	else if(i >= 3217 && i < 6434) return qsin(6434 - i); 
	else if(i >= 6434 && i < 9651) return -1*qsin(i - 6434); 
	else if(i >= 9651 && i < 12867) return -1*qsin(12867 - i); 
	else return 0; 

short icos(short i){
	// i is base 2^11
	//but we accept 0 to 2*pi or 12867
	if(i >= 0 && i < 3217) return qsin(3217 - i); 
	else if(i >= 3217 && i < 6434) return -1*qsin(i - 3217); 
	else if(i >= 6434 && i < 9651) return -1*qsin(9651 - i); 
	else if(i >= 9651 && i < 12867) return qsin(i - 9651); 
	else return 0; 

//this interrupt is triggered by the parallel port. 
//because we only have 3 lines and need 8 commands, 
//after triggering (0 to 1 transition on PORT2.0 ), 
//the control program on the PC will either hold the pin up 
// (indicating a velocity step command) or drop it (indicating shutter/stop cmd). 

#pragma vector=PORT2_VECTOR
__interrupt void port2_ISR (void)
	//need to read the two pins to figure out which axis to change.
	short k; 
	for(k=0; k<8; k++){
		P9OUT ^= 0x4;	
	switch(P2IN & 0x7){
		case 1: theta1_v += INCR;  break; 
		case 3: theta1_v -= INCR;  break; 
		case 5: theta2_v += INCR;  break; 
		case 7: theta2_v -= INCR;  break; 
		case 0: shutter_cmd = SHUTTER_CLOSED; break; 
		case 2: shutter_cmd = SHUTTER_SMALL; break; 
		case 6: shutter_cmd = SHUTTER_OPEN; break; 
		case 4: theta1_v = 0; theta2_v = 0; break;
	P2IFG = 0; //clear the interupt. 

#pragma vector=TIMER1_A0_VECTOR 
__interrupt void timera1_ISR (void)
	return; //if this vector is not here and the interupt is enabled, then the proc will crash! 
// have to integrate the velocity at a consistent rate, 
// hence we pushed integration as well as the sine/cosine computation 
// into this timer interrupt. 
#pragma vector=TIMER1_A1_VECTOR 
__interrupt void timera11_ISR (void)
	short ps, pc; 
	P1OUT ^= 0xFF; //toggle P1 to indicate the update rate. (the led is there)
	TA1CTL = 0x0004; //reset counter
	TA1CTL = 0x0112; //turn back in interrupts.	

	theta1 += theta1_v; 
	theta2 += theta2_v;
	if(theta1 > PI2) theta1 -= PI2; 
	if(theta1 < 0) theta1 += PI2; 

	if(theta2 > PI2) theta2 -= PI2; 
	if(theta2 < 0) theta2 += PI2; 

	ps = isin(theta1)+TIMER_SCL;
	pc = icos(theta1)+TIMER_SCL;

	TA0CCR1 = ps; //update the counter (PWM output) registers. 
	TA0CCR4 = pc;

	ps = isin(theta2)+TIMER_SCL;
	pc = icos(theta2)+TIMER_SCL;
	TA0CCR2 = ps; 
	TA0CCR3 = pc;
	P1OUT ^= 0xFF; //toggle P1 to indicate the update rate. (the led is there)

//delay is used in moving the shutter. 
// too short, and the stepper motor controlling the shutter will skip steps! 
void delay(short time){
	short k; 
	short j = 0; 
	for(k=0; k<time; k++){

void delay_long(short time){
	short k,j,f; 
	for(k=0; k<time; k++){
		f = 0; 
		for(j=0; j<100; j++){

// ideally, we would ramp the shutter velocity up and down to maximize speed 
// and minimize time - constant velocity works fine and fast. 
#define SHUTDLY	1600
void shutter_ccw(void){
	P9OUT = 0x1; 
	P9OUT = 0x3; 
	P9OUT = 0x2; 
	P9OUT = 0x0; 

void shutter_cw(void){
	P9OUT = 0x2; 
	P9OUT = 0x3; 
	P9OUT = 0x1; 
	P9OUT = 0x0; 

void shutter_open(void){
	short i; 
	if(shutter_state == SHUTTER_CLOSED){
		//I was quite pleased to discover that the three shutters states
		// are exactly 5 full steps apart! 
		for(i=0; i<5; i++){ 

	if(shutter_state == SHUTTER_SMALL){
		for(i=0; i<5; i++){
	shutter_state = SHUTTER_OPEN; 
void shutter_close(void){
	short i; 
	if(shutter_state == SHUTTER_OPEN){
		for(i=0; i<5; i++){
	if(shutter_state == SHUTTER_SMALL){
		for(i=0; i<10; i++){
	shutter_state = SHUTTER_CLOSED; 
void shutter_small(void){
	short i; 
	if(shutter_state == SHUTTER_OPEN){
		for(i=0; i<5; i++){
	if(shutter_state == SHUTTER_CLOSED){
		for(i=0; i<10; i++){
	shutter_state = SHUTTER_SMALL; 

void main (void){
	//SR = 0x02;
	short t1, t2, ps, pc; 
	short k; 
	WDTCTL = WDTPW + WDTHOLD; //stop the watchdog timer.
	// UCSCTL = Universal clock system control (registers). 
	// sets the core clock of the device. 
	//SR = SR | 0x40 ;
	// setup the digitally controlled oscillator. 
	UCSCTL0 = 0x0700; //DCO = 5, MOD = 0
	UCSCTL1 = 0x0060; //DCORSEL = 3, middle freq. 
	UCSCTL2 = 0x101F; //FLL (frequency locked loop); doesnt matter here.
	UCSCTL4 = 0x0333; //select DCOCLK for all clock sources 
	UCSCTL0 = 0x0900; //DCO = 9, MOD = 0
		// DCO = internal high-frequency oscillator). 
	//UCSCTL5 = 0x0000; 

	// setup timer A (for controlling PWM outputs)
	TA0CCR0 = TIMER_SCL*2+1; //Timer A end pulse
	TA0CCR1 = TIMER_SCL; //Timer A start pulse
	TA0CCR2 = TIMER_SCL; //Timer A start pulse
	TA0CCR3 = TIMER_SCL; //Timer A start pulse
	TA0CCR4 = TIMER_SCL; //Timer A start pulse
	TA0CTL = 0x0110; //TASSEL = ACLK; input divider=1; MCx = count up mode; 
	TA0CCTL0 = 0x0040; //sets the mode of the output: here=2, toggle/reset.
		// (produces pulses at 8Khz). 
	TA0CCTL1 = 0x00C0; //output mode: toggle/set. 
	TA0CCTL2 = 0x00C0; // same
	TA0CCTL3 = 0x00C0; // same
	TA0CCTL4 = 0x00C0; // same

	//setup timer B (for controlling theta & velocity updates). 
	TA1CCR0 = 10000; //Timer A end pulse
	TA1CCR1 = 5000; //Timer A start pulse
	TA1CCR2 = 5000; //Timer A start pulse	
	TA1CTL = 0x0004;
	TA1CTL = 0x0112; //TASSEL = ACLK; input divider=1; MCx = count up mode; 
	TA1CCTL0 = 0x0050; //sets the mode of the output: here=2, toggle/reset.
		// (produces pulses at 8Khz). 
	TA1CCTL1 = 0x00C0; //output mode: toggle/set. 
	TA1CCTL2 = 0x00C0; // same
	P1DIR = 0x03; //P1.0 and P1.1 to output. (the LED)
	P1SEL = 0x00;
	P1OUT = 0; 
	P8DIR = 0xFF; //for some reason Port 1 does not work for the dev board --  
	P8SEL = 0x7F; //hence, we switched over to Port 8, which also is connected 
	// to the timers. 
	// the P8SEL register selects the timer output as opposed to general purpose IO. 
	//setup port2 (computer command via parallel port) interrupt. 
	P2DIR = 0; //all inputs. 
	P2IFG = 0;
	P2IE = 0x01; //enable interupts on P2.0
	P2IES = 0; // low to high edge detect. 
	_bis_SR_register(GIE | SCG0 );  //enable interrupts, dont go to sleep.
	P9DIR = 0x07; 
	//test the shutter. first move all the way to the limit.
	// since we do not know the initial position.
	for(k=0; k<30; k++){
	shutter_ccw();  //step one out so we don't hit the limits later.
	shutter_state = SHUTTER_CLOSED; //this is where the init will leave it
		//now just sit here waiting for a shutter command from the 
		// parallel port ISR.  
		if(shutter_state != shutter_cmd){
				case SHUTTER_OPEN: shutter_open(); break; 
				case SHUTTER_CLOSED: shutter_close(); break; 
				case SHUTTER_SMALL: shutter_small(); break;

We has some problem getting Port1 to work, hence had to use Port8 to get the PWM signals out -- see below. Note the shutter does not need to be microstepped and instead can be controlled as per a conventional stepper motor. The pins used are marked in yellow; pin 57 is a simple pulse output.

Note that each PWM signal is generated from the same timer counter, hence they are synchronous (this is of course not necessary). Below are some examples of two phases of one motor output; in real life, of course, the PWM ratio continually changes.

Below is the development board being probed to produce the plots above.

We then used the pinouts of the NXP microcontrollers, intuited last time by probing their on-line function (specifically the auto-calibration sequence upon startup), to wire up a harness for external control of the H-bridges. Below is a picture of that (we removed the original microcontrollers to prevent contention), and the associated wiring labels.

The next task was to make a 5V to 3.2V regulator (the MSP430 only runs at 3.2V, max), nothing major just a LM317. See below.

Finally, everything was wired together. The 3.2 V supply was jumpered, as the MSP430 USB programmer provided its own power. (Amazingly, the ultra low power MSP430 could run on power from the parallel port, too!)

A level translator is needed to properly interface the 3.2V MSP430 to the 5V parallel port - we canibalized a spare JTAG adapter for this purpose. It was this that limited us to only 3 bits of control.

And that, minus the difficulty we had getting the compiler working properly, is the entirety of the microcontroller part of the project.

hide / / print
ref: -2011 tags: HiLo speckle imaging confocal boston university optical sectioning date: 02-19-2019 06:18 gmt revision:2 [1] [0] [head]

PMID-21280920 Optically sectioned in vivo imaging with speckle illumination HiLo microscopy

  • Ah, brilliant! Illuminate a sample with a speckle pattern from a laser, and use this to optically section the data -- the contrast of the speckle pattern shows how in focus the sample is.
    • Hanece, the contrast indicates the in-focus vs out-of-focus ratio in a region.
  • The speckle statistics are invariant even in a scattering media, as scattering only further randomizes an already random laser phase front. (Within some limits.)
  • HiLo microscopy involves illuminating with a speckle pattern, then illuminating with standard uniform illumination, resulting in a diffraction-limited optically sectioned image. PMID-18709098
  • Algorithm is :
    • Take the speckle image and subtract the uniform image δI\delta I
    • Bandpass δI\delta I
    • Measure the standard deviation of the δI\delta I to get a weighting function C δs 2C^2_{\delta s}
    • Debias this estimate based on sensor..
    • Generate low-passed image from the weighted uniform image, LP[C δsI u] LP[C_{\delta s} I_u] , and high-pass from the difference HP=1LPHP = 1 - LP
    • Resultand image is a weighted sum of highpassed and lowpassed images.
  • Looks about as good as confocal.
  • Cited by...

hide / / print
ref: -0 tags: diffraction terahertz 3d print ucla deep learning optical neural networks date: 02-13-2019 23:16 gmt revision:1 [0] [head]

All-optical machine learning using diffractive deep neural networks

  • Pretty clever: use 3D printed plastic as diffractive media in a 0.4 THz all-optical all-interference (some attenuation) linear convolutional multi-layer 'neural network'.
  • In the arxive publication there are few details on how they calculated or optimized given diffractive layers.
  • Absence of nonlinearity will limit things greatly.
  • Actual observed performance (where thy had to print out the handwritten digits) rather poor, ~ 60%.

hide / / print
ref: Gradinaru-2009.04 tags: Deisseroth DBS STN optical stimulation 6-OHDA optogenetics date: 05-10-2016 23:48 gmt revision:8 [7] [6] [5] [4] [3] [2] [head]

PMID-19299587[0] Optical Deconstruction of Parkinsonian Neural Circuitry.

  • Viviana Gradinaru, Murtaza Mogri, Kimberly R. Thompson, Jaimie M. Henderson, Karl Deisseroth
  • DA depletion of the SN leads to abnormal activity in the BG ; HFS (>90Hz) of the STN has been found to be therapeutic, but the mechanism is imperfectly understood.
    • lesions of the BG can also be therapeutic.
  • Used chanelrhodopsin (light activated cation channel (+)) which are expressed by cell type specific promoters. (transgenic animals). Also used halorhodopsins, which are light activated chloride pumps (inhibition).
    • optogenetics allows simultaneous optical stimulation and electrical recording without artifact.
  • Made PD rats by 6-hydroxydopamine unilaterally into the medial forebrain bundle of rats.
  • Then they injected eNpHr (inhibitory) opsin vector targeting excitatory neurons (under control of the CaMKIIa receptor) to the STN as identified stereotaxically & by firing pattern.
    • Electrical stimulation of this area alleviated rotational behavior (they were hemiparkinsonian rats), but not optical inhibition of STN.
  • Alternately, the glia in STN may be secreting molecules that modulate local circuit activity; it has been shown that glial-derived factor adenosine accumulates during DBS & seems to help with attenuation of tremor.
    • Tested this by activating glia with ChR2, which can pass small Ca+2 currents.
    • This worked: blue light halted firing in the STN; but, again, no behavioral trace of the silencing was found.
  • PD is characterized by pathological levels of beta oscillations in the BG, and synchronizing STN with the BG at gamma frequencies may ameliorate PD symptoms; while sync. at beta will worsen -- see [1][2]
  • Therefore, they tried excitatory optical stimulation of excitatory STN neurons at the high frequencies used in DBS (90-130Hz).
    • HFS to STN failed, again, to produce any therapeutic effect!
  • Next expressed channel rhodopsin in only projection neurons Thy1::ChR2 (not excitatory cells in STN), again did optotrode (optical stim, eletrical record) recordings.
    • HFS of afferent fibers to STN shut down most of the local circuitry there, with some residual low-amplitude high frequency burstiness.
    • Observed marked effects with this treatment! Afferent HFS alleviated Parkinsonian symptoms, profoundly, with immediate reversal once the laser was turned off.
    • LFS worsened PD symptoms, in accord with electrical stimulation.
    • The Thy1::ChR2 only affected excitatory projections; GABAergic projections from GPe were absent. Dopamine projections from SNr were not affected by the virus either. However, M1 layer V projection neurons were strongly labeled by the retrovirus.
      • M1 layer V neurons could be antidromically recruited by optical stimulation in the STN.
  • Selective M1 layer V HFS also alleviated PD symptoms ; LFS had no effect; M2 (Pmd/Pmv?) LFS causes motor behavior.
  • Remind us that DBS can treat tremor, rigidity, and bradykinesia, but is ineffective at treating speech impairment, depression, and dementia.
  • Suggest that axon tract modulation could be a common theme in DBS (all the different types..), as activity in white matter represents the activity of larger regions compactly.
  • The result that the excitatory fibers of projections, mainly from the motor cortex, matter most in producing therapeutic effects of DBS is counterintuitive but important.
    • What do these neurons do normally, anyway? give a 'copy' of an action plan to the STN? What is their role in M1 / the BG? They should test with normal mice.


[0] Gradinaru V, Mogri M, Thompson KR, Henderson JM, Deisseroth K, Optical Deconstruction of Parkinsonian Neural Circuitry.Science no Volume no Issue no Pages (2009 Mar 19)
[1] Eusebio A, Brown P, Synchronisation in the beta frequency-band - The bad boy of parkinsonism or an innocent bystander?Exp Neurol no Volume no Issue no Pages (2009 Feb 20)
[2] Wingeier B, Tcheng T, Koop MM, Hill BC, Heit G, Bronte-Stewart HM, Intra-operative STN DBS attenuates the prominent beta rhythm in the STN in Parkinson's disease.Exp Neurol 197:1, 244-51 (2006 Jan)

hide / / print
ref: -0 tags: histology optical coherence tomography vasculature avoidance date: 01-29-2013 06:46 gmt revision:0 [head]

PMID-9766311 Optical coherence tomography for neurosurgical imaging of human intracortical melanoma.

  • Relevant for our interests: Subsurface cerebral vascular structures could be identified and were therefore avoided.
  • more broadly, could identify subsurface metastatic melanoma due to reflectance changes. nice.

hide / / print
ref: -0 tags: optical neural recording photon induced electron transfer date: 01-02-2013 04:25 gmt revision:2 [1] [0] [head]

PMID-22308458 Optically monitoring voltage in neurons by photo-induced electron transfer through molecular wires.

  • Photoinduced electron transfer.
    • About what you would think -- a photon bumps an electron into a higher orbital, and this electron can be donated to another group or drop back down & fluoresce a photon.
  • Good sensitivity: ΔF/F\Delta F/F of 20-27% per 100mV, fast kinetics.
  • Not presently genetically targetable.
  • Makes sense in terms of energy: "A 100-mV depolarization changes the PeT driving force by 0.05 eV (one electron Ɨ half of 100-mV potential, or 0.05 V). Because PeT is a thermally controlled process, the value of 0.05 eV is large relative to the value of kT at 300 K (0.026 eV), yielding a large dynamic range between the rates of PeT at resting and depolarized potentials.
  • Why electrochromic dyes have plateaued:
    • "In contrast, electrochromic dyes have smaller delta G values, 0.003 (46) to 0.02 (47) eV, and larger comparison energies. Because the interaction is a photochemically controlled process, the energy of the exciting photon is the comparison energy, which is 1.5ā€“2 eV for dyes in the blue-to-green region of the spectrum. Therefore, PeT and FRET dyes have large changes in energy versus their comparison energy (0.05 eV vs. 0.026 eV), giving high sensitivities; electrochromic dyes have small changes compared with the excitation photon (0.003ā€“0.02 eV vs. 2 eV), producing low voltage sensitivity."

hide / / print
ref: -0 tags: optical imaging neural recording diamond magnetic date: 01-02-2013 03:44 gmt revision:0 [head]

PMID-22574249 High spatial and temporal resolution wide-field imaging of neuron activity using quantum NV-diamond.

  • yikes: In this work we consider a fundamentally new form of wide-field imaging for neuronal networks based on the nanoscale magnetic field sensing properties of optically active spins in a diamond substrate.
  • Cultured neurons.
  • NV = nitrogen-vacancy defect centers.
    • "The NV centre is a remarkable optical defect in diamond which allows discrimination of its magnetic sublevels through its fluorescence under illumination. "
    • We show that the NV detection system is able to non-invasively capture the transmembrane potential activity in a series of near real-time images, with spatial resolution at the level of the individual neural compartments.
  • Did not actually perform neural measurements -- used a 10um microwire with mA of current running through it.
    • I would imagine that actual neurons have far less current!

hide / / print
ref: -0 tags: optical recording voltage sensitive dyes redshirt date: 01-02-2013 03:17 gmt revision:3 [2] [1] [0] [head]

PMID-16050036 Imaging brain activity with voltage- and calcium-sensitive dyes.

  • Voltage-sensitive dyes are well suited for measuring synaptic integration, as:
    • Electrodes are too blunt to effectively record these fine, < 1um diameter structures.
    • The surface area to volume ratio is highest in the dendrites
    • Voltage-sensitive dyes also permeate internal membranes not subject to voltage gradients, hence this does not contribute to the signal, leading to a decreased ΔF/F\Delta F / F .
  • Dominant experimental noise is shot noise, statistical -- see {1181}.
  • modern dyes and imagers can reliably record single action potentials; spatial averaging yields similar resolution as electrical recording.
  • They performed optical recording of Aplysia sensory ganglia, and discovered following light tail touch: "It is almost as if the Aplysia nervous system is designed such that every cell in the abdominal ganglion cares about this (and perhaps every) sensory stimulus. In addition, more than 1000 neurons in other ganglia are activated by this touch..."
      • These results force a more pessimistic view of the present understanding of the neuronal basis of apparently simple behaviors in relatively simple nervous systems.
  • Used calcium imaging on olfactory glomeruli of mice and turtles; measurements were limited by either shot-noise or heart/breathing artifacts.
  • Confocal and two-photon microscopes, due to their exchange of spatial resolution for sensitivity, are not useful with voltage-sensitive dyes.
    • The generation of fluorescent photons in the 2-photon confocal microscope is not efficient. We compared the signals from Calcium Green-1 in the mouse olfactory bulb using 2-photon and ordinary microscopy. In this comparison the number of photons contributing to the intensity measurement in the 2-photon confocal microscope was about 1000 times smaller than the number measured with the conventional microscope and a CCD camera.
  • By the numbers, quote: Because only a small fraction of the 10e16 photons/ms emitted by a tungsten filament source will be measured, a signal-to-noise ratio of 10e8 (see above) cannot be achieved. A partial listing of the light losses follows. A 0.9-NA lamp collector lens would collect 0.1 of the light emitted by the source. Only 0.2 of that light is in the visible wavelength range; the remainder is infrared (heat). Limiting the incident wavelengths to those, which have the signal means, that only 0.1 of the visible light is used. Thus, the light reaching the
preparation might typically be reduced to 1013 photons/ms. If the light-collecting system that forms the image has high efficiency e.g., in an absorption measurement, about 1013 photons/ms will reach the image plane. (In a fluorescence measurement there will be much less light measured because 1. only a fraction of the incident photons are absorbed by the fluorophores, 2. only a fraction of the absorbed photons appear as emitted photons, and 3. only a fraction of the emitted photons are collected by the objective.) If the camera has a quantum efficiency of 1.0, then, in absorption, a total of 10e13 photoelectrons/ms will be measured. With a camera of 1000 pixels, there will be 10e10 photoelectrons/ms/pixel. The shot noise will be 10e5 photoelectrons/ms/pixel; thus the very best that can be expected is a noise that is 10eāˆ’5 of the resting light (a signal-to-noise ratio of 100 db). The extra light losses in a fluorescence measurement will further reduce the maximum obtainable signal-to-noise ratio.

hide / / print
ref: -0 tags: optical coherence tomography neural recording squid voltage sensitive dyes review date: 12-23-2012 21:00 gmt revision:4 [3] [2] [1] [0] [head]

PMID-20844600 Detection of Neural Action Potentials Using Optical Coherence Tomography: Intensity and Phase Measurements with and without Dyes.

  • Optical methods of recording have been investigated since the 1940's:
    • During action potential (AP) propagation in neural tissue light scattering, absorption, birefringence, fluorescence, and volume changes have been reported (Cohen, 1973).
  • OCT is reflection-based, not transmission: illuminate and measure from the same side.
    • Here they use spectral domain OCT, where the mirror is not scanned; rather SD-OCT uses a spectrometer to record interference of back-scattered light from all depth points simultaneously (Fercher et al., 1995).
    • Use of a spectrometer allows imaging of an axial line within 10-50us, sufficient for imaging action potentials.
    • SD-OCT, due to some underlying mathematics which I can't quite grok atm, can resolve/annul common-mode phase noise for high temporal and Δphase\Delta phase measurement (high sensitivity).
      • This equates to "microsecond temporal resolution and sub-nanometer optical path length resolution".
  • OCT is generally (intially?) used for in-vivo imaging of retinas, in humans and other animals.
  • They present new data for depth-localization of neural activity in squid giant axons (SGA) stained with a voltage-sensitive near-infrared dye.
    • Note: averaged over 250 sweeps.
  • ΔPhase>>ΔIntensity\Delta Phase &gt;&gt; \Delta Intensity -- figure 4 in the paper.
  • Use of voltage-sensitive dyes improves the resolution of ΔI\Delta I , but not dramatically --
    • And Δphase\Delta phase is still a bit delayed.
    • Electrical recording is the control.
      • It will take significant technology development before optical methods exceed electrical methods...
  • Looks pretty preliminary. However, OCT can image 1-2mm deep in transparent tissue, which is exceptional.
  • Will have to read their explanation of OCT.
  • Used in a squid giant axon prep. 2010, wonder if anything new has been done (in vivo?).
  • Claim that progress is hampered by limited understanding of how these Δphase\Delta phase signals arise.

hide / / print
ref: -0 tags: optical coherence tomography neural recording aplysia date: 12-23-2012 09:12 gmt revision:2 [1] [0] [head]

PMID-19654752 Detecting intrinsic scattering changes correlated to neuron action potentials using optical coherence imaging.

  • Aplysia, intrinsic imaging of scattering change following electrical stimulation.
    • Why did it take so long for them to get this paper out.. ?
  • Nicolelis first cited author.
  • Quality of recording not necessarily high.
  • quote: "Typical transverse resolutions in OCT (10-20um) are likely insufficient to identify smaller mamallian neurons that are often studied in neuroscience."
    • Solution: optical coherence microscopy (OCM), where a higher NA lens focuses the light to a smaller spot.
    • Expense: shorter depth-of-field.
  • Why does this work? "One mechanism of these optical signals is believed to be a realignment of charged membrane proteins in response to voltage change [6].
  • A delay of roughly 70ms was observed between the change in membrane voltage and the change in scattering intensity.
    • That's slow! Might be due to conduction velocity in Aplysia.
  • SNR of scattering measurement not too high -- the neurons are alive, afterall, and their normal biological processes cause scattering changes.
    • Killing the neurons with KCl dramatically decreased the variance of scattering, consistent with this hpothesis.
  • Birefringence: "Changes in the birefringence of nerves due to electrical activity have been shown to be an order of magnitude larger than scattering intensity changes" PMID-5649693

hide / / print
ref: Song-2009.08 tags: wireless neural recording RF Brown laser optical Donoghue date: 01-15-2012 00:58 gmt revision:6 [5] [4] [3] [2] [1] [0] [head]

IEEE-5067358 (pdf) Wireless, Ultra Low Power, Broadband Neural Recording Microsystem

  • 16 channels.
  • Use a VCSEL (vertical cavity surface emission laser) to transmit data through the skin.
  • Nice design, and they claim to have made recordings for 1 month already.
  • One PCB, kapton substrate reinforced with alumina where needed.
  • Custom 12mW neural amplifier.


Song, Y.-K. and Borton, D.A. and Park, S. and Patterson, W.R. and Bull, C.W. and Laiwalla, F. and Mislow, J. and Simeral, J.D. and Donoghue, J.P. and Nurmikko, A.V. Active Microelectronic Neurosensor Arrays for Implantable Brain Communication Interfaces Neural Systems and Rehabilitation Engineering, IEEE Transactions on 17 4 339 -345 (2009)

hide / / print
ref: -0 tags: optical illusion date: 12-04-2011 16:54 gmt revision:1 [0] [head]

-- So cool! How do you come up with something like this?

hide / / print
ref: -0 tags: ME270 optical power date: 12-03-2008 22:25 gmt revision:17 [16] [15] [14] [13] [12] [11] [head]

Section 2: Microcontroller & microstepping

As mentioned before, we chose MSP430F5438 100-pin 16 bit microcontroller because it offers sufficient timers and speed for our problem and because we were both familiar with the architecture. Four 16-bit timers are used to control microstepping mirror tilt and pan, since the stepper motors have two phases. The microcontroller only needs to provide digital signals; current is provided through H-bridge drivers in the control board of the mm-150 - the DIPs with heat sinks below.

Opposite sides of the H-bridge are driven via hex inverters; hence, we only have to supply two PWM signals per motor, one per phase. Setting the PWM duty cycle to 50% will set the motor phase current to zero; by vectoring the duty cycle proportional to the sine and cosine of theta, where theta is the orientation of the motor * number of poles of the stepper, you can control microstepping. That, of course, is simplified; in practice, there are many details to contend with, namely:

  • The MSP430 is a 16 bit integer processor; hence, fractional values must be represented as fixed-point numbers. We chose 11-bit fixed point to optimize resolution and prevent overflow.
  • There is no divide. Division can be accomblished via bit-shifts (which is equivalent to dividing by 2), and addition.
  • There is one 16*16 -> 32 bit multiplier used as a peripheral in the MSP430 architecture, but the standard C library does not access it properly for our fixed-point math.
  • We have to approximate sine and cosine using fixed-point math, since the standard C library Sin and cos each take more than 2500 cycles -- too long when the microcontroller is only running at 12Mhz, and we want to update 4 microstepping phases at ~ 40Khz.

{646} hide/ /

We approximated sine and cosine, needed to vector the stepper motor phase currents, in fixed-point arithmetic first in C on linux - where the results could be plotted in matlab - before converting to MSP430 code. Since the trigonometric functions are repeating, we only need a polynomial approximation of sine from 0 to pi/2. The taylor series for sine is

 sin(x) = x - x^3/3! + x^5/5! - x^7/7! ...
; a quick check in matlab showed that the first three terms are enough to get an accurate approximation in the domain of interest. The MSP430 does not have division, however, so we approximated 1/3! = 1/6 as (1/8 + 1/32 + 1/128) and 1/5! = 1/120 as 1/128; division by powers of two is possible with right bit-shift operations. We chose base 11 (5 bits whole, 11 bits fractional) representation to avoid overflow: if 2^11 -> 1, we need to represent (pi/2)^5 -> 9.5 ; ceil(log_2(9.5)) = 4 (plus one bit for safety). The C program below shows this test.

#include <stdio.h>

char qsin(short i){
       //i goes from  0 pi/2 base 11 or...
       // 0 to 3217
       unsigned int cube, fifth, result;
       cube = (i*i) >> 11;
       cube = (cube*i) >> 11; //max = 7937
       fifth = (cube*i) >> 11;
       fifth = (fifth*i) >> 11; // max = 19585
       //our approximation to sine based on taylor series:
       //original: sin(x) = x - x^3/3! + x^5/5!
       //sin(x) = x - x^3*(1/8+1/32+1/128) + x^5*(1/128)
       result = (unsigned int)i -
               ((cube >> 3) + (cube >> 5) + (cube >> 7)) + (fifth >> 7);
       //result is base 11.  need it to be base 7.
       result = result >> 4;
       if(result > 127) result = 127;
       return (char)result;
//this is tricky, as it involves shifts, x-inversions, and y-inversions. 
//but it all makes sense if you plot out the respective functions. 
char isin(short i){
       // i is base 2^11
       //but we accept 0 to 2*pi or 12867
       if(i >= 0 && i < 3217) return qsin(i);
       else if(i >= 3217 && i < 6434) return qsin(6434 - i);
       else if(i >= 6434 && i < 9651) return -1*qsin(i - 6434);
       else if(i >= 9651 && i < 12867) return -1*qsin(12867 - i);
       else return 0;
char icos(short i){
       // i is base 2^11
       //but we accept 0 to 2*pi or 12867
       if(i >= 0 && i < 3217) return qsin(3217 - i);
       else if(i >= 3217 && i < 6434) return -1*qsin(i - 3217);
       else if(i >= 6434 && i < 9651) return -1*qsin(9651 - i);
       else if(i >= 9651 && i < 12867) return qsin(i - 9651);
       else return 0;

int main(void){
	short i; 
	for(i=0; i<12867; i++){
		printf("%d\t%f\t%d\t%d\n", i, ((float)i)/2048.0, (int)(isin(i)), (int)(icos(i))); 
	return 0; 

We compiled and ran this program on the command line:

 gcc integer_trig.c 
 ./a.out > test.txt

Then we imported the data into matlab and plotted (Actual double floating-point sine and cosine are plotted on the same axis as thin black and magenta lines, respectively)

Later, we had to change the naive standard implementation of multiply to assembly to properly implement the fixed-point arithmetic - the MSP430's standard library did not implement the 16x16 multiply followed by shift correctly (it only keeps the bottom 16 bits). Note: this assembly function is for use with Code-Composer Studio, available from the Texas Instruments website. It seems that the IAR compiler uses different assembly syntax.

            .cdecls C,LIST,"msp430x54x.h"  ; Include device header file

            .text                           ; Progam Start
          ;;.sect "mply_11"
          ;;.asmfunc "mply_11"
                        .global mply_11 ;; this MUST BE PRECEDED BY TABS !!!!!

        PUSH	SR	; 
         DINT		; turn off interrupts here. 
         NOP			; required after DINT
         MOV.W	R12, &MPY ; load the first operand. 
         MOV.W	R13, &OP2 ; load the second operand & start multiplication. 
         MOV.W	&RESLO, R12 ; low to R12 (this is the return value)
         MOV.W	&RESHI, R13 ; high to R13
         RRA.W R12 ; 1
         RRA.W R12 ; 2
         RRA.W R12 ; 3
         RRA.W R12 ; 4 
         RRA.W R12 ; 5
         RRA.W R12 ; 6
         RRA.W R12 ; 7
         RRA.W R12 ; 8
         RRA.W R12 ; 9
         RRA.W R12 ; 10
         RRA.W R12 ; 11
         RLA.W R13 ; 1
         RLA.W R13 ; 2
         RLA.W R13 ; 3
         RLA.W R13 ; 4
         RLA.W R13 ; 5
        ;; r14 can be clobbered across a function call, according to the msp430 ABI
        MOV.W	#0x001f, R14
        AND.W	R14, R12 ; mask off all but the bottom 5 bits from RESLO
         ADD.W	R13, R12 ; add (logical OR) the results. R12 is the 11-bit fixed point result.
         POP.W 	SR	;
         RETA		; return from subroutine.


Note the MSP430 does not have an opcode for multiple arithmetic shifts, nor does it have code for logical shifts - hence the need for repeated shifts and bitmasks!

hide / / print
ref: notes-0 tags: elektralite mm150 optical power light ME270 project date: 12-03-2008 20:39 gmt revision:5 [4] [3] [2] [1] [0] [head]

Section 1 : Reverse-engineering the light, part selection

Rather than engineering our own articulated spotlight, we elected to buy a moving-mirror DJ light; creating our own light source would simply have taken too much time, and demanded optical experience that we lack. After a brief survey, we bought an Elekralite mm150 (moving mirror, 150W bulb) DJ light, one of the cheapest on the market ($650); despite this, it is very well constructed, as you will see below. The light was originally controlled through the stage-specific DMX bus, but the possibility of directly controlling the light through this was discarded after we learned that the resolution on each axis is only 8 bits (+- 127); given the large range of the pan mirror, this is insufficient for tracking. Hence we decided to reverse engineer the light to determine the best way to directly control the mirror and shutter.
  • Overview, with dichroic color filter wheel and globos removed. We ended up putting these back in, as without them the unit does not initialize properly.
  • Another view with the shell taken off. The white ballast on the bottom powers the 150W HMI metal-halide bulb, along with a stabilization capacitor (to the left of the ballast) and starter (below the capacitor). The starter produces 2kV to initially ionize the gas in the bulb; there is no third starter electrode as in mercury vapor bulbs, as this would be a point of stress in the high-pressure (90atm) fused quartz arc tube. The bulb is on whenever the unit is plugged in, and the light output is controlled via the shutter. The top large transformer (+20V, +12V) is used to drive the display/control unit (left center) and the 6 stepper motors in the lamp, which are:
    • mirror tilt
    • mirror pan
    • shutter
    • globo selection
    • globo rotate
    • colorwheel
    • Detail of the breakout board for the 6 stepper motors, with the colorwheel stepper above it. The stepper motors are two-phase, permanent-magnet rotor types; we're not sure of the steps/revolution yet, though they all seem different. The breakout board also has attachments for the hall-effect sensors to detect orientation of the globo and color wheels.
    • The dichroic mirror color wheel. Regular filters would undoubtedly melt here - a pencil put into the beam of the HMI lamp will light on fire!
    • The globo wheel. Each globo is mounted to a gear which engages a center gear on the same axis as this plate. This center gear is driven by the globo rotate stepper motor.
    • Dichroic IR filter. Note that since it is viewed at an angle, the reflective wavelength goes up, and so you can see a slight red tint in the reflections off this. Removed this, since silicon photovoltaic cells respond to near IR energy.
    • Stepper motor controller. The three chips at the bottom are NXP 87LPC768 OTP microcontroller. Each can control two stepper motors, and each has an internal program for self-calibration using either the hall-effect sensors or hard mechanical limits on motor range. Upper chip is for the mirror (U3). These chips are controlled via one high-speed serial bus from the upper control board (the one with the LED display). The six upper chips, with heat-sinks on them, contain dual H-bridges, probably similar to the Allegro A3955 PWM microstepping motor driver. Between them are two standard 74HC04 hex inverters to drive the opposite leg of the h-bridges (each 87LPC768 has four outputs, two per motor, whereas each motor requires four inputs, two per phase. In this way, you can switch the direction of current flow through each motor phase with a single +20v supply rail.)
    • The Elekralite mm150 without the two control boards, globo wheel, or filter wheel. You can see the lamp, focus adjustment screws and reflector. Below the lamp is a 24V radial fan.
    • The Elektralite powered on, with globo and filter wheel back in place. The lamp is very, very bright!
    • Close-up of filter and globo wheels. The shutter has been removed; it fits on the shaft just above the long hex spacer. Just above that is the mechanical hard stop for the shutter.
    • The pin on the main controller that is used to control the 6 stepper axes. We tried probing it for some time, but could not directly figure out the serial protocol without a good logic analyzer (which is at home), so decided to implement our own microstepping PWM controller, and drive the inverters / H-bridges driectly.
    • The shutter, after being used for a good bit. The UV and IR from the lamp (mostly the IR, I think - the shutter gets really hot!) bleaches the black anodization on this bit of aluminum. We've drilled a 1/4" hole in one side to try to get a more tightly-collated beam.
    • The PWM waveform at the motor for the two phases (the glare at the left is from the light, which was of course on!). The other leads in the motor are simply the inverse of these via the 74HC04. For vector control like this, a 50% on/50% off PWM effectively sets the phase current to zero (the motor has sufficient leakage inductance at the 16kHz PWM frequency to keep di/dt low over multiple PWM periods). Hence, to control the motors we need something like:
      phase1 = 0.5*sin(theta) + 0.5 ; phase2 = 0.5*cos(theta) + 0.5
      , where theta is changed based on the control algorithm, and phase is scaled and used to set the PWM counter compare register. See below.
    • Microstepping control scheme based on vector control of current in the two phases of these stepper motors. As before, current will be regulated via PWM @ 16kHz, as the Elektralite engineers do, as opposed to linear current control. To generate the appropriate 6 PWM signals (mirror pan, mirror tilt, and shutter), we used a MSP430 microcontroller with 3 16-bit counters and 5+ capture-compare registers.
    • We used a MSP430F5xxx development board from TI -- see the next section. The device features sufficient timers and PWM outputs to control the stepper motors in the Elekralite. We will control motion of each using a simple up-down toggling via the parallel port to increment/decrement the motor theta variable. The microcontroller will need a look-up table or algorithm for calculating the sines and cosines of rotor angles.
    • small solar cell from Spark Fun Electronics. When placed in the beam of the light, it is possible to generate 500ma short-circuit current and 5V open-circuit voltage, but not at the same time. In a solar cell composed of a series of junctions, such as this, the total current at full voltage is limited by the minimum current from each of the junctions (they are in series!). Therefore to get maximum current you need very uniform illumination, something that is normally not difficult with the sun, but which will be difficult in this application. To avoid this problem we will try to procure higher efficiency single-junction GaAs concentrator cells, which can be up to ~40% efficient (as compared to this one, which is ~15% efficient).