Beispiel #1
0
void ArduEyeSMHClass::begin(short vref,short nbias,short aobias,char gain,char selamp)
{
  //set all digital pins to output
  RESP_DDR|=RESP;
  INCP_DDR|=INCP;
  RESV_DDR|=RESV;
  INCV_DDR|=INCV;
  INPHI_DDR|=INPHI;

  //set external ADC SS to high
  ADC_SS_DDR|=ADC_SS;
  ADC_SS_PORT|=ADC_SS;
 
  //set all pins low
  SMH1_SetAllLow;

  //clear all chip register values
  clearValues();

  //set up biases
  setBiases(vref,nbias,aobias);

  short config=gain+(selamp*8)+(16);
  
  //turn chip on with config value
  setPointerValue(SMH_SYS_CONFIG,config);
  
  //if amp is used, set useAmp variable
  if(selamp==1)
   useAmp=1;
  else
   useAmp=0;

}
Beispiel #2
0
// init
// Initializes the vision chips for normal operation.  Sets vision chip pins to low outputs, clears
// chip registers, sets biases and config register.  Arduino pin numbers must be specified.  For
// the remaining parameters if no parameters are passed in, default values are used.
void Stonyman::init( char inPinRESP, char inPinINCP, char inPinRESV, char inPinINCV,
                     char inPinINPHI, char inPinANALOG1, char inPinANALOG2, short vref, short nbias,
                     short aobias, char gain, char selamp )
{
  short config;

/* TODO russ: use later
  if(Stonyman::MAX_GAIN < inGain)
  {
    return Stonyman::RC_ERROR_BADPARAM;
  }
  // TODO russ: there are likely other checks to perform (vref, nbias, aobias)
*/
  pinRESP = inPinRESP;
  pinINCP = inPinINCP;
  pinRESV = inPinRESV;
  pinINCV = inPinINCV;
  pinINPHI = inPinINPHI;
  pinANALOG1 = inPinANALOG1;
  pinANALOG2 = inPinANALOG2;

  // set all digital pins to output
  pinMode(pinRESP, OUTPUT);
  pinMode(pinINCP, OUTPUT);
  pinMode(pinRESV, OUTPUT);
  pinMode(pinINCV, OUTPUT);
  pinMode(pinINPHI, OUTPUT);
  // FIXME russ: is this necessary?
  pinMode(pinANALOG1, INPUT);
  pinMode(pinANALOG2, INPUT);

  // set all pins low
  digitalWriteFast(pinRESP, 0);
  digitalWriteFast(pinINCP, 0);
  digitalWriteFast(pinRESV, 0);
  digitalWriteFast(pinINCV, 0);
  digitalWriteFast(pinINPHI, 0);

  //clear all chip register values
  clearValues();

  //set up biases
  // TODO russ: haven't looked at what this function does
  setBiases(vref,nbias,aobias);

  // sanitize this input before use
  flagUseAmplifier=selamp ? 1:0;

  config=gain+(flagUseAmplifier*8)+(16);

  //turn chip on with config value
  setPointerValue(Stonyman::REG_CONFIG,config);

// TODO russ: use later
//  return Stonyman::RC_OK;
}