labview与arduino的RGB检测的问题?
时间:10-02
整理:3721RD
点击:
LZ近期想做一个TCS230颜色传感器的测试,因为代码基础薄弱,所以想利用labview做自动检测系统。时间较为紧迫,学习2周赶鸭子上架,目前遇到问题了。就是visa read buffer与数组、簇之间的传输吧。如图
我想知道中间部分该怎么连线啊?用了很多图标测试,都连不对。我的arduino程序是打开串口后,先进行白平衡再不断输出RGB值的。
附上RGB检测例程:
#include
#define S0 6
#define S1 5
#define S2 4
#define S3 3
#define OUT 2
int g_count = 0;
int g_array[3];
int g_flag = 0;
float g_SF[3];
void TSC_Init()
{ pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(OUT, INPUT);
digitalWrite(S0, LOW);
digitalWrite(S1, HIGH);
} // Select the filter color
void TSC_FilterColor(int Level01, int Level02)
{ if(Level01 != 0) Level01 = HIGH;
if(Level02 != 0) Level02 = HIGH;
digitalWrite(S2, Level01);
digitalWrite(S3, Level02); }
void TSC_Count(){
g_count ++ ;
}
void TSC_Callback()
{
switch(g_flag)
{ case 0:
Serial.println("->WB Start");
TSC_WB(LOW, LOW);
break;
case 1:
Serial.print("->Frequency R=");
Serial.println(g_count);
g_array[0] = g_count;
TSC_WB(HIGH, HIGH);
break;
case 2:
Serial.print("->Frequency G=");
Serial.println(g_count);
g_array[1] = g_count;
TSC_WB(LOW, HIGH);
break;
case 3:
Serial.print("->Frequency B=");
Serial.println(g_count);
Serial.println("->WB End");
g_array[2] = g_count;
TSC_WB(HIGH, LOW);
break;
default:
g_count = 0;
break; }}
void TSC_WB(int Level0, int Level1)
{
g_count = 0;
g_flag ++;
TSC_FilterColor(Level0, Level1);
Timer1.setPeriod(1000000);
}
void setup()
{
TSC_Init();
Serial.begin(9600);
Timer1.initialize();
Timer1.attachInterrupt(TSC_Callback);
attachInterrupt(0, TSC_Count, RISING);
delay(4000);
for(int i=0; i<3; i++)
Serial.println(g_array[i]);
g_SF[0] = 255.0/ g_array[0]; //R Scale factor
g_SF[1] = 255.0/ g_array[1] ; //G Scale factor
g_SF[2] = 255.0/ g_array[2] ; //B Scale factor
Serial.println(g_SF[0]);
Serial.println(g_SF[1]);
Serial.println(g_SF[2]);
}
void loop()
{
g_flag = 0;
for(int i=0; i<3; i++)
Serial.println(int(g_array[i] * g_SF[i]));
delay(4000);
}
这一段是例程,打开串口后先进行白平衡。
而这一段例程该怎么配合我的labview改呢?求各位高手不吝赐教。
问题总结:
1:labview的串口通信编程,用什么框图连接?
2:arduino程序的优化
我想知道中间部分该怎么连线啊?用了很多图标测试,都连不对。我的arduino程序是打开串口后,先进行白平衡再不断输出RGB值的。
附上RGB检测例程:
#include
#define S0 6
#define S1 5
#define S2 4
#define S3 3
#define OUT 2
int g_count = 0;
int g_array[3];
int g_flag = 0;
float g_SF[3];
void TSC_Init()
{ pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(OUT, INPUT);
digitalWrite(S0, LOW);
digitalWrite(S1, HIGH);
} // Select the filter color
void TSC_FilterColor(int Level01, int Level02)
{ if(Level01 != 0) Level01 = HIGH;
if(Level02 != 0) Level02 = HIGH;
digitalWrite(S2, Level01);
digitalWrite(S3, Level02); }
void TSC_Count(){
g_count ++ ;
}
void TSC_Callback()
{
switch(g_flag)
{ case 0:
Serial.println("->WB Start");
TSC_WB(LOW, LOW);
break;
case 1:
Serial.print("->Frequency R=");
Serial.println(g_count);
g_array[0] = g_count;
TSC_WB(HIGH, HIGH);
break;
case 2:
Serial.print("->Frequency G=");
Serial.println(g_count);
g_array[1] = g_count;
TSC_WB(LOW, HIGH);
break;
case 3:
Serial.print("->Frequency B=");
Serial.println(g_count);
Serial.println("->WB End");
g_array[2] = g_count;
TSC_WB(HIGH, LOW);
break;
default:
g_count = 0;
break; }}
void TSC_WB(int Level0, int Level1)
{
g_count = 0;
g_flag ++;
TSC_FilterColor(Level0, Level1);
Timer1.setPeriod(1000000);
}
void setup()
{
TSC_Init();
Serial.begin(9600);
Timer1.initialize();
Timer1.attachInterrupt(TSC_Callback);
attachInterrupt(0, TSC_Count, RISING);
delay(4000);
for(int i=0; i<3; i++)
Serial.println(g_array[i]);
g_SF[0] = 255.0/ g_array[0]; //R Scale factor
g_SF[1] = 255.0/ g_array[1] ; //G Scale factor
g_SF[2] = 255.0/ g_array[2] ; //B Scale factor
Serial.println(g_SF[0]);
Serial.println(g_SF[1]);
Serial.println(g_SF[2]);
}
void loop()
{
g_flag = 0;
for(int i=0; i<3; i++)
Serial.println(int(g_array[i] * g_SF[i]));
delay(4000);
}
这一段是例程,打开串口后先进行白平衡。
而这一段例程该怎么配合我的labview改呢?求各位高手不吝赐教。
问题总结:
1:labview的串口通信编程,用什么框图连接?
2:arduino程序的优化
大体框架
自己顶一下,不要沉了
已经找到突破口 完成后再上传上来
虽然我不懂还是支持一下
加油哦