Pin Definitions
By placing these definitions near the top of your Arduino "Sketch" you can use the inputs and outputs provided by the GCU without needing to look up the Arduino pins they relate to. For example:
pinMode(FET0, OUTPUT); analogWrite(FET0,128); // (set FET0 to half duty cycle)
or
pinMode(ANA0, INPUT); value = analogRead(ANA0)
Adjusting the timer settings can allow advanced PWM control (see Set the Frequency for PWM)
// KS pin out definitions
#define FET0 5 //Arduino pin 5 = FET 0 Timer:TCCR3B
#define FET1 2 //Arduino pin 2 = FET 1 Timer:TCCR3B
#define FET2 3 //Arduino pin 3 = FET 2 Timer:TCCR3B
#define FET3 6 //Arduino pin 6 = FET 3 Timer:TCCR4B
#define FET4 7 //Arduino pin 7 = FET 4 Timer:TCCR4B
#define FET5 8 //Arduino pin 8 = FET 5 Timer:TCCR4B
#define FET6 46 //Arduino pin 46 = FET 6 Timer:TCCR5B
#define FET7 45 //Arduino pin 45 = FET 7 Timer:TCCR5B
#define SERVO0 11 //Arduino pin 11 = SERVO 0 Timer:TCCR1B
#define SERVO1 12 //Arduino pin 12 = SERVO 1 Timer:TCCR1B
#define SERVO1 13 //Arduino pin 13 = SERVO 2 Timer:TCCR0B Freq = 2x
#define ANA0 54 //Arduino pin 54 = ANALOG 0
#define ANA1 55 //Arduino pin 55 = ANALOG 1
#define ANA2 56 //Arduino pin 56 = ANALOG 2
#define ANA3 57 //Arduino pin 57 = ANALOG 3
Calculate Volumetric Flow Through Orifice Flowmeter
double CalcFlowmeter(double CfA0, double dP, double density, double offset) {
return CfA0*sqrt(((dP-offset)*2)/density);
}
where:
CfAo is determined through flowmeter calibration
dP is the differential pressure across the flowmeter (from Press_Data[i]) in Pascals
density is the density of the gas (1.2 kg/m3 for air, estimated to be 0.95 for wood gas)
offset is the zero offset for the pressure sensor. The zero offset does fluctate with time, ideally the offset should be found before each run (no flow condition)
Manually Pulse Servo
Pending library support for servo control, you can manually control a Futaba servo:
void PulseServo(int servo_pin,double angle) {
// manually pulse servo - up to 2 ms delay will be be an issue w/ more then a few servos, may be ok w/ 3. digitalWrite(servo_pin,HIGH);
delayMicroseconds(1000+angle*5.556);
digitalWrite(SERVO0,LOW);
}
PID Control Library
http://www.arduino.cc/playground/Code/PIDLibrary
Note that the library defaults to limiting inputs to 0-1024 (the 10-bit analog input native to arduino). These limits will need to be changed to handle values from pressure sensors etc. The library also defaults to a sample time of one second (compute() will not run,even if called more frequently), which is too slow in some cases (like mantaining reactor vacuum through ejector air input).
These methods are useful:
void SetSampleTime(int NewSampleTime)
void SetInputLimits(double INMin, double INMax)
void SetOutputLimits(double OUTMin, double OUTMax)
Wikipedia has a good discussion on the theory and operation of PID control:
http://en.wikipedia.org/wiki/PID_controller
See section "Manual Tuning" for methods to determine the good values for the PID tuning parameters.
Set The Frequency Used For PWM (of the FET banks)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1235060559/15
Comments (0)
You don't have permission to comment on this page.