All pastes #448165 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-19 14:17 UTC
rendered paste body


/*------------------------------------------------------------------------------------------------------------
read light values into an array	


//recording light values from light sensor

	comedi_data_read(device,0,3,1,AREF_GROUND,&record_my_light[i]);
	record_my_light[i] = record_my_light[i] & 0xfff;  //^^we must mask out 12bits to use this data  




/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

		COMEDI_DATA_READ/WRITE FUNCTION EXPLAINED



comedi_data_[read/write](device,subdevice,channel,range,AREF_GROUND,data)

device - box
subdevice - section of box (digital (2),DAC (1), ADC (0))
channel - DAC 0 = left channel(left motor)
			  1 = right channel(right motor)
        - ADC 0 = a0
              1 = a1
              2 = a2
              3 = a3
range - '0' = 0-> 10 v
      - '1' = '-10' -> '+10v'
aref always = AREF_GROUND
data = data i wanna pass/store/record....etc
--------------------------------------------------
		HOW TO USE FOR LIGHT FOLLOW
	
		-- DEVICE IS ALWAYS UNCHANGED
		-- SUBDEVICE IS THE ADC ON THE RACK,= 0
		-- CHANNEL IS 3 -; FOR EXAMPLE.. SENSOR(EYE ON PATCH BOX) 
							IS PLUGGED INTO A3 = 3
		-- RANGE WILL BE -10 -> +10 = 1 
		-- DATA WILL BE AN ARRAY OF VALUES THAT U WILL READ IN 
		
	e.g>>	comedi_data_read(device,0,3,1,AREF_GROUND,&record_my_light[i]);
		
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=	
				MOVING THE STEPPER MOTOR

	the stepper motor for the light sensor has two sensors to test whether the stepper motor has reached
   full clockwise scan or full anti clockwise scan.       
 
 The stepper motor cannot simply continue after 360° in a clock fashion, it reaches an end point at which
		   point after a full rotation it must return in the opposite direction.*/
		   
	//stepper values are:  10,6,5,9		
	//stpr_motor_value1 = 10
	//stpr_motor_value2 = 6
	//stpr_motor_value3 = 5
	//stpr_motor_value4 = 9
	
/*The light stepper motor has two sensors which are active low.. (see below for e.g)
    so what you must do is record a light intensity into an array and then move the stepper value one place (10 then 6 then 5 then 9)...		
	
	
//moving the stepper motor the light sensor is attached to	

	stpr_sensor_1eft = the value that the cable is plugged into i.e top plug = 128
	
	while(stpr_sensor_1eft & stpr_sensor_1eft != 0)
	{
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value1);
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value2);
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value3);
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value4);
	}
	
	..now reverse direction of motor
	
	while(stpr_sensor_right & stpr_sensor_right != 0)
	{
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value4);
	now read light
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value3);
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value2);
	comedi_dio_bitfield(device,subdevice,0xff,&stpr_motor_value1);
	}
	
	*/