this->eta_current = this->kernel->config->value(eta_current_checksum )->by_default(-1)->as_number();
this->theta_current = this->kernel->config->value(theta_current_checksum )->by_default(-1)->as_number();
+ digipot->set_max_current( this->kernel->config->value(digipot_max_current )->by_default(2.0)->as_number());
+ digipot->set_factor( this->kernel->config->value(digipot_factor )->by_default(113.33)->as_number());
+
this->digipot->set_current(0, this->alpha_current);
this->digipot->set_current(1, this->beta_current );
this->digipot->set_current(2, this->gamma_current);
#define theta_current_checksum CHECKSUM("theta_current")
#define currentcontrol_module_enable_checksum CHECKSUM("currentcontrol_module_enable")
#define digipotchip_checksum CHECKSUM("digipotchip")
+#define digipot_max_current CHECKSUM("digipot_max_current")
+#define digipot_factor CHECKSUM("digipot_factor")
#define mcp4451_checksum CHECKSUM("mcp4451")
#define ad5206_checksum CHECKSUM("ad5206")
double theta_current;
DigipotBase* digipot;
+
};
virtual void set_current( int channel, double current )= 0;
virtual double get_current(int channel)= 0;
+ void set_max_current(double c) { max_current= c; }
+ void set_factor(double f) { factor= f; }
+
+ protected:
+ double factor;
+ double max_current;
};
for (int i = 0; i < 8; i++)
currents[i] = 0.0;
}
-
+
~MCP4451(){
delete this->i2c;
}
void set_current( int channel, double current )
{
- current = min( max( current, 0.0L ), 2.0L );
+ current = min( max( current, 0.0 ), this->max_current );
currents[channel] = current;
char addr = 0x58;
while(channel > 3){
{
return currents[channel];
}
-
+
private:
void i2c_send( char first, char second, char third ){
}
char current_to_wiper( double current ){
- return char(ceil(double((113.33*current))));
+ return char(ceil(double((this->factor*current))));
}
mbed::I2C* i2c;