void setup()
{
/* Modbus setup example, the master must use the same COM parameters */
/* 115200 bps, 8N1, two-device network */
configure_mb_slave(115200, 'n', 0);
pinMode(flowPin, INPUT);
digitalWrite(flowPin, HIGH);
}
int flowPin=7;
unsigned long tnew = millis();
unsigned long told = millis();
int total = 0;
boolean flowPinStatePrev = LOW;
boolean flowPinStateNow = HIGH;
int flowRate;
const int RCount = 10;
int count = 0;
int index = 0;
int tstore[RCount];
void setup()
{
/* Modbus setup example, the master must use the same COM parameters */
/* 115200 bps, 8N1, two-device network */
configure_mb_slave(115200, 'n', 0);
pinMode(flowPin, INPUT);
digitalWrite(flowPin, HIGH);
}
void loop()
{
/* This is all for the Modbus slave */
regs[0] = flowFunc();
update_mb_slave(MB_SLAVE, regs, MB_REGS);
/* your code goes here */
}
/*
flowFunc
Inputs: N/A - use global varriables
Outputs:
flowRate -> this is the calibrated flow rate multiplied by 1000
Comments:
This function uses persistant variables and operates on them to calculate
a calibrated flow rate in LPM*1000 using the koolance flow meter INS-FM17N
The function needs to be in a loop that will operate at at least 100Hz to be
able to catch and count the leading edge from the flow meter with flows up
to about 10 LPM. The function counts the number of revs in 1 second and then
keeps a running average over 10 seconds and returns this value.
*****************************************************************************/
int flowFunc(){
// int *fr=&flowRate+1;
// return(*fr);
flowPinStateNow = digitalRead(flowPin);
if (flowPinStateNow ==HIGH) {
if (flowPinStatePrev == LOW) {
count += 1;
}
}
tnew = millis();
if ((tnew - told) >= 1000){
total = total - tstore[index];
tstore[index] = 0.28*count*1000;
total = total + tstore[index];
flowRate = int(float(total)/float(RCount));
if (index >= RCount){
index = 0;
}
count=0;
told=tnew;
index += 1;
}
flowPinStatePrev=flowPinStateNow;
return(flowRate);
}
dirktheeng wrote:The thing I don't much care for is the pattern of circulation. Because the vents are at the top of the unit only with no vents at the bottom, the smoke tends to move from the bottom of the unit towards the front, move up to be inducted into the high velocity flow from the vents and then be shot back to either go out the back or recirculate again depending on where it is.
BenJackson wrote:dirktheeng wrote:The thing I don't much care for is the pattern of circulation. Because the vents are at the top of the unit only with no vents at the bottom, the smoke tends to move from the bottom of the unit towards the front, move up to be inducted into the high velocity flow from the vents and then be shot back to either go out the back or recirculate again depending on where it is.
That definitely doesn't happen with the dust collector I'm using. You can watch the outlet (where it's blowing out of the house) and see a puff of smoke for each cut.
I didn't really get it to have such ridiculous suction: I got it so I could put it far away and still have sufficient suction. Right now it's about 3' of hose away, though.
int flowPin = 7;
int pumpPWMPin = 9;
unsigned long tnew = millis();
unsigned long told = millis();
int total = 0;
boolean flowPinStatePrev = HIGH;
boolean flowPinStateNow = HIGH;
int flowRate;
const int RCount = 10;
int count = 0;
int index = 0;
int tstore[RCount] = {0};
float I = 50;
void setup()
{
/* Modbus setup example, the master must use the same COM parameters */
/* 115200 bps, 8N1, two-device network */
configure_mb_slave(115200, 'n', 0);
pinMode(flowPin, INPUT);
digitalWrite(flowPin, HIGH);
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
TCCR1B = TCCR1B & 0b11111000 | 0x01;
//tstore[0]=0;
}
void loop()
{
regs[0] = flowFunc();
if (regs[1] < 0) {regs[1] = 0;}
if (regs[1] > 2200) {regs[1] = 2200;}
I = I + 0.0000003*float(regs[1] - tstore[index]);
if (I < 40) {I = 40;}
if (I > 150) {I = 150;}
analogWrite(pumpPWMPin,I);
update_mb_slave(MB_SLAVE, regs, MB_REGS);
}
int flowFunc(){
flowPinStateNow = digitalRead(flowPin);
if (flowPinStateNow ==HIGH) {
if (flowPinStatePrev == LOW) {count += 1;}
}
tnew = millis();
if ((tnew - told) >= 500){
total = total - tstore[index];
tstore[index] = 0.28*count*1000*2;
total = total + tstore[index];
flowRate = total/(RCount);
if (index >= RCount-1) {index = 0;}
count=0;
told=tnew;
index += 1;
}
flowPinStatePrev=flowPinStateNow;
return(flowRate);
}
int flowPin = 7;
int pumpPWMPin = 9;
int fanPWMPin = 10;
unsigned long tnew = millis();
unsigned long told = millis();
unsigned long tstart = millis();
int total = 0;
boolean flowPinStatePrev = HIGH;
boolean flowPinStateNow = HIGH;
int flowRate;
const int RCount = 10;
int count = 0;
int index = 0;
int tstore[RCount] = {0};
float I = 50;
void setup()
{
/* Modbus setup example, the master must use the same COM parameters */
/* 115200 bps, 8N1, two-device network */
configure_mb_slave(115200, 'n', 0);
pinMode(flowPin, INPUT);
digitalWrite(flowPin, HIGH);
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
pinMode(10, OUTPUT);
digitalWrite(10, LOW);
TCCR1B = TCCR1B & 0b11111000 | 0x01;
//tstore[0]=0;
}
void loop()
{
if ((millis()-tstart) <= 2000){
for (int i = 0; i < RCount; i++) {tstore[i] = 0;}
regs[1] = 0;
total = 0;
count = 0;
}
regs[0] = flowFunc();
if (regs[1] < 0) {regs[1] = 0;}
if (regs[1] > 2000) {regs[1] = 2000;}
I = I + 0.0000003*float(regs[1] - tstore[index]);
if (I < 40) {I = 40;}
if (I > 150) {I = 150;}
analogWrite(pumpPWMPin,I);
analogWrite(fanPWMPin,regs[1]*float(255-30)/2000+30);
update_mb_slave(MB_SLAVE, regs, MB_REGS);
}
int flowFunc(){
flowPinStateNow = digitalRead(flowPin);
if (flowPinStateNow ==HIGH) {
if (flowPinStatePrev == LOW) {count += 1;}
}
tnew = millis();
if ((tnew - told) >= 500){
total = total - tstore[index];
tstore[index] = 0.28*count*1000*2;
total = total + tstore[index];
flowRate = total/(RCount-1);
if (index >= RCount-1) {index = 0;}
count=0;
told=tnew;
index += 1;
}
flowPinStatePrev=flowPinStateNow;
return(flowRate);
}
Sub Main
Begin Dialog CheckSample 15,32,149,96,"Check Boxes"
OKButton 92,8,40,14
CancelButton 92,32,40,14
CheckBox 12,8,50,8,"Reference X",.XBox
CheckBox 12,24,50,8,"Reference Y",.YBox
CheckBox 12,40,50,8,"Reference Z",.ZBox
CheckBox 12,56,50,8,"Reference 4",.FourBox
CheckBox 12,72,50,8,"Reference All",.AllBox
End Dialog
Dim Dlg1 As CheckSample
Button = Dialog ( Dlg1 )
If Button = 0 Then Exit Sub
If Dlg1.ZBox = 1 Or Dlg1.AllBox = 1 Then
Begin Dialog ButtonSample 16,32,180,60,"Z Axis Reference Set?"
OkButton 16,40,40,14
CancelButton 124,40,40,14
Text 16,8,164,8, "Is the Z Probe in Place and the Laser Head"
Text 16,16,164,8, "Positioned? Ok for Yes, Cancel for No"
End Dialog
Dim Dlg2 As ButtonSample
Button2 = Dialog (Dlg2)
If Button2 = 0 Then
MsgBox("Set up Z Reference Hardware and Retry.")
Exit Sub
End If
DoButton( 24 )
End If
If Dlg1.XBox = 1 Or Dlg1.AllBox = 1 Then
DoButton( 22 )
End If
If Dlg1.YBox = 1 Or Dlg1.AllBox = 1 Then
DoButton( 23 )
End If
If Dlg1.FourBox = 1 Or Dlg1.AllBox = 1 Then
DoButton( 25 )
End If
DoOEMButton(133)
DoOEMButton(134)
DoOEMButton(135)
End Sub
Users browsing this forum: No registered users and 38 guests