GEK Wiki / GCU Example Code
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Want to organize your cloud files? Sign up for a free webinar to see how Dokkio (a new product from PBworks) can help you find, organize, and collaborate on your Drive, Gmail, Dropbox, and Slack files: Weds, May 27 at 2PM Eastern / 11AM Pacific
View
 

GCU Example Code

Page history last edited by bk 10 years, 6 months ago

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)
// KS pin out definitions
#define FET0 5 //Arduino pin 5 = FET 0
#define FET1 2 //Arduino pin 2 = FET 1
#define FET2 3 //Arduino pin 3 = FET 2
#define FET3 6 //Arduino pin 6 = FET 3
#define FET4 7 //Arduino pin 7 = FET 4
#define FET5 8 //Arduino pin 8 = FET 5
#define FET6 46 //Arduino pin 46 = FET 6
#define FET7 45 //Arduino pin 45 = FET 7
#define SERVO0 11 //Arduino pin 11 = SERVO 0
#define SERVO1 12 //Arduino pin 12 = SERVO 1
#define SERVO2 13 //Arduino pin 13 = SERVO 2
#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);
  digitalWrite(servo_pin,HIGH);
  delayMicroseconds(1000+angle*5.556);   
  digitalWrite(servo_pin,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.