Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp
00001 #include "mbed.h" 00002 #include <string> 00003 #include <stdio.h> 00004 #include <stdlib.h> 00005 #include <iostream> 00006 #define tempo_pipeta 1.5 00007 00008 //Para acessar a interface com o arduino e os arquivos do NEXTION DISPLAY: https://github.com/Diogonac/Projeto-mecatronico-.git 00009 00010 //================== Comunicação Serial ========================== 00011 00012 Serial recebe_arduino(PA_9, PA_10); // Comunicação com arduino TX, RX 00013 Serial pc (D1, D0); //Comunicação com USB TX, RX 00014 00015 //========== unsigned char para logicas de funções ================ 00016 00017 unsigned char set_eixos[5] = {0, 0, 0, 0, 0}; //Armazena os dados recebido do arduino 00018 char tmp[2]; //Usado para armazenar comandos específicos 00019 00020 //================== Pinos dos motores ============================ 00021 00022 BusOut motor_x(PC_8, PC_6, PC_5, PA_12); //Pinos para acionamento do motor do eixo X 00023 BusOut motor_y(PA_11, PB_12, PB_11, PB_2); //Pinos para acionamento do motor do eixo Y 00024 BusOut motor_z(PB_1, PB_15, PB_14, PB_13); //Pinos para acionamento do motor do eixo Z 00025 00026 //================== Pinos de interrupção ========================== 00027 00028 InterruptIn botao_emergencia_in(PC_4); //Botão de emergência para detectar acionamento 00029 InterruptIn botao_reset(PC_3); //Botão de reset para detectar acionamentoR 00030 InterruptIn botao_fim_curso_rise_X(PC_12); //Chave de fim de curso EIXO X 00031 InterruptIn botao_fim_curso_rise_Y(PA_15); //Chave de fim de curso EIXO Y 00032 InterruptIn botao_fim_curso_rise_Z(PB_7); //Chave de fim de curso EIXO Z 00033 00034 //==================== Pinos digitais ============================== 00035 00036 DigitalOut sinal_pipeta(PC_10); // Pino para o acionamento da pipeta 00037 00038 //==================== Timers para deboucing e JOG ================= 00039 00040 Timer debounce1; //Correção para botão de posição de salva 00041 Timer debounce2; //Correção para botão de emergência 00042 Timer debounce3; //Correção para chave de fim de curso 00043 Timer tempo_motor; //Timer para movimento descretizado dos eixos 00044 00045 //==================== Variáveis globais int, float, bool ========== 00046 00047 int pulsos_Z = 0; //Contagem dos pulsos para o motor_Z 00048 int pulsos_X = 0; //Contagem dos pulsos para o motor_X 00049 int pulsos_Y = 0; //Contagem dos pulsos para o motor_Y 00050 00051 int i, j, count; //Variáveis para contadores e acesso de char 00052 00053 int Z_seguranca = 3; //Define a posição de segurança do eixo Z para então movimentar X ou Y 00054 int cont_fim_curso_X = 0; //Variável para contar o incremento do fim de curso 00055 int cont_fim_curso_Y = 0; //Variável para contar o incremento do fim de curso 00056 int cont_fim_curso_Z = 0; //Variável para contar o incremento do fim de curso 00057 int passo_fuso = 5; //Declara o passo do fuso 00058 00059 int contador_SELECT_X = 0; //Define o contator do botão SELECT 00060 int contador_SELECT_Y = 0; //Define o contator do botão SELECT 00061 int contador_SELECT_Z = 0; //Define o contator do botão SELECT 00062 int contador_emergencia = 0; //Define o contator do botão de emergência 00063 00064 int contador_rise_X = 0; 00065 int contador_rise_Y = 0; 00066 int contador_rise_Z = 0; 00067 00068 int seguranca_fdc_X = 0; 00069 int seguranca_fdc_Y = 0; 00070 int seguranca_fdc_Z = 0; 00071 00072 int tubos_usados; 00073 int tubo_atual; 00074 int quantidade_depositada; 00075 00076 int tempo_acionamento = 3180; //Tempo padrao de acionamento dos eixos 00077 00078 int quantidades[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//ml PEGA, ml SOLTA1, ml SOLTA2, ... 00079 float posicoes[30] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//XYZ PEGA, XYZ SOLTA1, XYZ SOLTA2, ... 00080 00081 float tempo_horario, tempo_anti_horario; //Define os tempos de acionamento do motor 00082 float deslocamento_X = 0; //Define o deslocamento linear total 00083 float deslocamento_Y = 0; //Define o deslocamento linear total 00084 float deslocamento_Z = 0; //Define o deslocamento linear total 00085 00086 float deslocamento_max_X = 0; //Define o deslocamento linear total 00087 float deslocamento_max_Y = 0; //Define o deslocamento linear total 00088 float deslocamento_max_Z = 0; //Define o deslocamento linear total 00089 00090 float passo_motor = 5.625/32; //Declara o passo angular do motor 00091 float velocidade = 0.003; //Armazena a velocidade dos motores 00092 00093 bool estado_referenciamento = false; //Boleana para identificar a necessidade do referênciamento 00094 00095 bool estado_referenciamento_X = false; //Boleana para identificar a necessidade do referênciamento 00096 bool estado_referenciamento_Y = false; //Boleana para identificar a necessidade do referênciamento 00097 bool estado_referenciamento_Z = false; //Boleana para identificar a necessidade do referênciamento 00098 00099 bool estado_botao_emergencia_in = false; //Boleana para identificar a necessidade do referênciamentosatisfazer a lógica da rotina_emergencia_in 00100 00101 //==================== Variáveis globais int, float, bool ========== 00102 00103 void rotina_JOG (void); 00104 void rotina_pega (void); 00105 void rotina_solta (void); 00106 void rotina_movimenta(void); 00107 void rotina_fdc_rise_X (void); 00108 void rotina_fdc_rise_Y (void); 00109 void rotina_fdc_rise_Z (void); 00110 void referenciamento_X (void); 00111 void referenciamento_Y (void); 00112 void referenciamento_Z (void); 00113 void rotina_botao_reset (void); 00114 void rotina_aciona_pipeta(void); 00115 void rotina_emergencia_in (void); 00116 void rotina_velocidade_eixo (void); 00117 void rotina_deslocamento_eixo (void); 00118 void rotina_deslocamento_eixo_menos_Z (void); 00119 void recebe_dados(unsigned char *data_buf, int numchar); 00120 00121 00122 00123 int main() 00124 { 00125 recebe_arduino.baud(115200);// Interface com arduino 00126 pc.baud(115200); //Define a velocidade da porta USB 00127 00128 motor_x = 0x00; //Estabelece a condição inicial do motor do eixo X 00129 motor_y = 0x00; //Estabelece a condição inicial do motor do eixo Y 00130 motor_z = 0x00; //Estabelece a condição inicial do motor do eixo Z 00131 00132 //Declara os pinos de interrupção com suas funções 00133 botao_reset.fall(&rotina_botao_reset); 00134 botao_emergencia_in.rise(&rotina_emergencia_in); 00135 botao_fim_curso_rise_X.rise(&rotina_fdc_rise_X); 00136 botao_fim_curso_rise_Y.rise(&rotina_fdc_rise_Y); 00137 botao_fim_curso_rise_Z.rise(&rotina_fdc_rise_Z); 00138 00139 //Inicializa os timers 00140 debounce1.start(); 00141 debounce2.start(); 00142 debounce3.start(); 00143 00144 wait_ms(500); 00145 sinal_pipeta = 0; //Estado inicial da pipeta 00146 00147 while(1) { 00148 00149 //Limpa os comandos armazenados no set_eixos 00150 for(i = 0; i < sizeof(set_eixos); i++) { 00151 set_eixos[i] = 0; 00152 } 00153 00154 recebe_dados(set_eixos, 5); //Coleta novos comandos 00155 00156 00157 if(set_eixos[0] == '0') { 00158 00159 pc.printf("Antes: %s \r\n", set_eixos); 00160 00161 for(i = 1; i <= sizeof(set_eixos); i++) { 00162 set_eixos[i-1] = set_eixos[i]; 00163 } 00164 set_eixos[3] = 0; 00165 pc.printf("Depois: %s \r\n", set_eixos); 00166 00167 } 00168 00169 if(set_eixos[0] == 'R' & set_eixos[1] == 'F') { 00170 00171 pc.printf("Referenciamento \r\n"); 00172 00173 estado_referenciamento = false; 00174 00175 pc.printf("Estagio 1: movendo ate detectar\r\n"); 00176 00177 contador_SELECT_X = 1; 00178 referenciamento_X(); 00179 wait_ms(250); 00180 00181 contador_SELECT_Y = 1; 00182 referenciamento_Y(); 00183 wait_ms(250); 00184 00185 contador_SELECT_Z = 1; 00186 referenciamento_Z(); 00187 wait_ms(250); 00188 00189 } else { 00190 00191 00192 if(estado_referenciamento == true & estado_botao_emergencia_in == false) { 00193 00194 rotina_velocidade_eixo(); 00195 rotina_JOG(); 00196 pc.printf("%s \r\n", set_eixos); 00197 00198 } 00199 00200 if(set_eixos[0] == 'P' & estado_botao_emergencia_in == false) { //set_eixos = P27; 00201 00202 posicoes[0] = deslocamento_X; 00203 posicoes[1] = deslocamento_Y; 00204 posicoes[2] = deslocamento_Z; 00205 00206 for(i = 2; i < 4; i++) { 00207 tmp[i-2] = set_eixos[i]; 00208 } 00209 00210 quantidades[0] = atoi(tmp); 00211 00212 pc.printf("PosicoesX= %f, PosicoesY= %f, PosicoesZ= %f \r\n", posicoes[0], posicoes[1], posicoes[2]); 00213 pc.printf("Quantidades_pega= %d \r\n", quantidades[0]); 00214 pc.printf("set_eixos= %s\r\n", set_eixos); 00215 00216 } 00217 00218 if(set_eixos[0] == 'S' & estado_botao_emergencia_in == false) { 00219 00220 switch(set_eixos[1]) { 00221 00222 case '1': 00223 00224 posicoes[3] = deslocamento_X; 00225 posicoes[4] = deslocamento_Y; 00226 posicoes[5] = deslocamento_Z; 00227 00228 for(i = 2; i < 4; i++) { 00229 tmp[i-2] = set_eixos[i]; 00230 } 00231 00232 quantidades[1] = atoi(tmp); 00233 pc.printf("PosicoesX1= %f, PosicoesY1= %f, PosicoesZ1= %f \r\n", posicoes[3], posicoes[4], posicoes[5]); 00234 pc.printf("Quantidades_solta1= %d \r\n", quantidades[1]); 00235 tubos_usados = 1; 00236 00237 break; 00238 case '2': 00239 00240 posicoes[6] = deslocamento_X; 00241 posicoes[7] = deslocamento_Y; 00242 posicoes[8] = deslocamento_Z; 00243 00244 for(i = 2; i < 4; i++) { 00245 tmp[i-2] = set_eixos[i]; 00246 } 00247 00248 quantidades[2] = atoi(tmp); 00249 pc.printf("PosicoesX2= %f, PosicoesY2= %f, PosicoesZ2= %f \r\n", posicoes[6], posicoes[7], posicoes[8]); 00250 pc.printf("Quantidades_solta2= %d \r\n", quantidades[2]); 00251 tubos_usados = 2; 00252 00253 break; 00254 case '3': 00255 00256 posicoes[9] = deslocamento_X; 00257 posicoes[10] = deslocamento_Y; 00258 posicoes[11] = deslocamento_Z; 00259 00260 for(i = 2; i < 4; i++) { 00261 tmp[i-2] = set_eixos[i]; 00262 } 00263 00264 quantidades[3] = atoi(tmp); 00265 pc.printf("PosicoesX3= %f, PosicoesY3= %f, PosicoesZ3= %f \r\n", posicoes[9], posicoes[10], posicoes[11]); 00266 pc.printf("Quantidades_solta3= %d \r\n", quantidades[3]); 00267 tubos_usados = 3; 00268 00269 break; 00270 00271 case '4': 00272 00273 posicoes[12] = deslocamento_X; 00274 posicoes[13] = deslocamento_Y; 00275 posicoes[14] = deslocamento_Z; 00276 00277 for(i = 2; i < 4; i++) { 00278 tmp[i-2] = set_eixos[i]; 00279 } 00280 00281 quantidades[4] = atoi(tmp); 00282 pc.printf("PosicoesX4= %f, PosicoesY4= %f, PosicoesZ4= %f \r\n", posicoes[12], posicoes[13], posicoes[14]); 00283 pc.printf("Quantidades_solta4= %d \r\n", quantidades[4]); 00284 tubos_usados = 4; 00285 00286 break; 00287 case '5': 00288 00289 posicoes[15] = deslocamento_X; 00290 posicoes[16] = deslocamento_Y; 00291 posicoes[17] = deslocamento_Z; 00292 00293 for(i = 2; i < 4; i++) { 00294 tmp[i-2] = set_eixos[i]; 00295 } 00296 00297 quantidades[5] = atoi(tmp); 00298 pc.printf("PosicoesX5= %f, PosicoesY5= %f, PosicoesZ5= %f \r\n", posicoes[15], posicoes[16], posicoes[17]); 00299 pc.printf("Quantidades_solta5= %d \r\n", quantidades[5]); 00300 tubos_usados = 5; 00301 00302 break; 00303 case '6': 00304 00305 posicoes[18] = deslocamento_X; 00306 posicoes[19] = deslocamento_Y; 00307 posicoes[20] = deslocamento_Z; 00308 00309 for(i = 2; i < 4; i++) { 00310 tmp[i-2] = set_eixos[i]; 00311 } 00312 00313 quantidades[6] = atoi(tmp); 00314 pc.printf("PosicoesX6= %f, PosicoesY6= %f, PosicoesZ6= %f \r\n", posicoes[18], posicoes[19], posicoes[20]); 00315 pc.printf("Quantidades_solta6= %d \r\n", quantidades[6]); 00316 tubos_usados = 6; 00317 00318 break; 00319 00320 case '7': 00321 00322 posicoes[21] = deslocamento_X; 00323 posicoes[22] = deslocamento_Y; 00324 posicoes[23] = deslocamento_Z; 00325 00326 for(i = 2; i < 4; i++) { 00327 tmp[i-2] = set_eixos[i]; 00328 } 00329 00330 quantidades[7] = atoi(tmp); 00331 pc.printf("PosicoesX7= %f, PosicoesY7= %f, PosicoesZ7= %f \r\n", posicoes[21], posicoes[22], posicoes[23]); 00332 pc.printf("Quantidades_solta7= %d \r\n", quantidades[7]); 00333 tubos_usados = 7; 00334 00335 break; 00336 case '8': 00337 00338 posicoes[24] = deslocamento_X; 00339 posicoes[25] = deslocamento_Y; 00340 posicoes[26] = deslocamento_Z; 00341 00342 for(i = 2; i < 4; i++) { 00343 tmp[i-2] = set_eixos[i]; 00344 } 00345 00346 quantidades[8] = atoi(tmp); 00347 pc.printf("PosicoesX8= %f, PosicoesY8= %f, PosicoesZ8= %f \r\n", posicoes[24], posicoes[25], posicoes[26]); 00348 pc.printf("Quantidades_solta8= %d \r\n", quantidades[8]); 00349 tubos_usados = 8; 00350 00351 break; 00352 case '9': 00353 00354 posicoes[27] = deslocamento_X; 00355 posicoes[28] = deslocamento_Y; 00356 posicoes[29] = deslocamento_Z; 00357 00358 for(i = 2; i < 4; i++) { 00359 tmp[i-2] = set_eixos[i]; 00360 } 00361 00362 quantidades[9] = atoi(tmp); 00363 pc.printf("PosicoesX9= %f, PosicoesY9= %f, PosicoesZ9= %f \r\n", posicoes[27], posicoes[28], posicoes[29]); 00364 pc.printf("Quantidades_solta9= %d \r\n", quantidades[9]); 00365 tubos_usados = 9; 00366 00367 break; 00368 } 00369 00370 pc.printf("set_eixos= %s\r\n", set_eixos); 00371 00372 } 00373 00374 if(set_eixos[0] == 'M' & set_eixos[1] == 'P' & estado_botao_emergencia_in == false) { 00375 00376 rotina_pega(); 00377 00378 } 00379 00380 00381 if(set_eixos[0] == 'M' & set_eixos[1] == 'S' & estado_botao_emergencia_in == false) { 00382 00383 switch(set_eixos[2]) { 00384 00385 case '1': 00386 00387 j = 5; 00388 rotina_movimenta(); 00389 00390 break; 00391 case '2': 00392 00393 j = 8; 00394 rotina_movimenta(); 00395 00396 break; 00397 case '3': 00398 00399 j = 11; 00400 rotina_movimenta(); 00401 00402 break; 00403 case '4': 00404 00405 j = 14; 00406 rotina_movimenta(); 00407 00408 break; 00409 case '5': 00410 00411 j = 17; 00412 rotina_movimenta(); 00413 00414 break; 00415 case '6': 00416 00417 j = 20; 00418 rotina_movimenta(); 00419 00420 break; 00421 case '7': 00422 00423 j = 23; 00424 rotina_movimenta(); 00425 00426 break; 00427 case '8': 00428 00429 j = 26; 00430 rotina_movimenta(); 00431 00432 break; 00433 case '9': 00434 00435 j = 29; 00436 rotina_movimenta(); 00437 00438 break; 00439 00440 } 00441 00442 pc.printf("set_eixos= %s\r\n", set_eixos); 00443 00444 } 00445 00446 if(set_eixos[0] == 'C' & set_eixos[1] == 'I' & estado_botao_emergencia_in == false) { 00447 00448 pc.printf("Maquina em ciclo \r\n"); 00449 00450 velocidade = 0.003; 00451 pc.printf("Posicao_desejada= %f, Posicao_atual= %f \r\n", posicoes[1], deslocamento_Y); 00452 00453 rotina_pega(); 00454 rotina_aciona_pipeta(); 00455 rotina_solta(); 00456 00457 } 00458 } 00459 } 00460 } 00461 00462 00463 00464 void rotina_botao_reset() 00465 { 00466 00467 pc.printf("Maquina em RESET \r\n"); 00468 00469 estado_referenciamento = false; 00470 velocidade = 0.003; 00471 NVIC_SystemReset(); //Reset 00472 } 00473 00474 void rotina_emergencia_in() 00475 { 00476 00477 if(debounce2.read_ms() >= 25) { 00478 00479 motor_x = 0x00; //Não permite que pulsos sejam enviados para o motor do eixo X 00480 motor_y = 0x00; //Não permite que pulsos sejam enviados para o motor do eixo Y 00481 motor_z = 0x00; //Não permite que pulsos sejam enviados para o motor do eixo Z 00482 00483 contador_emergencia += 1; 00484 00485 debounce2.reset(); 00486 pc.printf("contador_emergencia= %d\r\n", contador_emergencia); 00487 00488 } 00489 00490 if(contador_emergencia == 1) { 00491 00492 recebe_arduino.printf("E1\n"); //Indica que o botão de emergência foi apertado 00493 00494 estado_referenciamento = false; //Solicita um novo referenciamento 00495 estado_botao_emergencia_in = true; 00496 00497 } 00498 00499 if(contador_emergencia == 2) { 00500 00501 NVIC_SystemReset(); //Reset 00502 00503 } 00504 } 00505 00506 00507 void rotina_velocidade_eixo() 00508 { 00509 //Define o tempo de acionamento a ser utilizada 00510 switch(set_eixos[0]) { 00511 case '1': 00512 tempo_acionamento = 3180; //Desloca 1mm 00513 break; 00514 case '2': 00515 tempo_acionamento = 15924; //Desloca 5mm 00516 break; 00517 case '3': 00518 tempo_acionamento = 47780; //Desloca 15mm 00519 break; 00520 } 00521 00522 pc.printf("tempo_acionamento= %d \r\n", tempo_acionamento); 00523 00524 } 00525 00526 00527 void rotina_deslocamento_eixo() 00528 { 00529 //Calcula os deslocamentos no eixo Z 00530 deslocamento_X = (passo_fuso*pulsos_X*passo_motor)/360; 00531 deslocamento_Y = (passo_fuso*pulsos_Y*passo_motor)/360; 00532 deslocamento_Z = (passo_fuso*pulsos_Z*passo_motor)/360; 00533 00534 recebe_arduino.printf("X%3.2f\n", deslocamento_X); 00535 recebe_arduino.printf("Y%3.2f\n", deslocamento_Y); 00536 recebe_arduino.printf("Z%3.2f\n", deslocamento_Z); 00537 00538 pc.printf("X%3.2f\n", deslocamento_X); 00539 pc.printf("Y%3.2f\n", deslocamento_Y); 00540 pc.printf("Z%3.2f\n", deslocamento_Z); 00541 } 00542 00543 00544 //=================================== Referenciamento X ====================================== 00545 00546 void referenciamento_X() 00547 { 00548 00549 while(estado_referenciamento_X == false & estado_botao_emergencia_in == false & contador_SELECT_X == 1) {//W1 00550 00551 for(i = 0; i < 4; i++) { 00552 motor_x = 1 << i; 00553 wait(0.003); 00554 } 00555 00556 if(contador_rise_X == 1) {//if1 00557 00558 while(estado_referenciamento_X == false & estado_botao_emergencia_in == false & contador_rise_X == 1) {//W2 00559 00560 for(i = 3; i > -1; i--) { 00561 motor_x = 1 << i; 00562 wait(0.01); 00563 00564 } 00565 00566 if(contador_rise_X == 2) {//if2 00567 00568 while(estado_referenciamento_X == false & estado_botao_emergencia_in == false & contador_rise_X == 2) {//W3 00569 00570 for(i = 0; i < 4; i++) { 00571 motor_x = 1 << i; 00572 wait(0.01); 00573 } 00574 00575 if(contador_rise_X == 3) {//if3 00576 00577 while(seguranca_fdc_X != 8 & estado_referenciamento_X == false & estado_botao_emergencia_in == false & contador_rise_X == 3) {//W4 00578 for(i = 3; i > -1; i--) { 00579 motor_x = 1 << i; 00580 wait(0.01); 00581 00582 } 00583 seguranca_fdc_X += 1; 00584 00585 }//Fecha W4 00586 00587 estado_referenciamento_X = true; 00588 contador_rise_X = 0; 00589 seguranca_fdc_X = 0; 00590 deslocamento_X = 0; //Define o deslocamento linear total 00591 pulsos_X = 0; 00592 deslocamento_max_X = 100; //Define o deslocamento linear total 00593 tempo_acionamento = 3180; 00594 velocidade = 0.003; 00595 rotina_deslocamento_eixo(); 00596 00597 }//Fecha if3 00598 }//Fecha W3 00599 00600 }//Fecha if2 00601 }//Fecha W2 00602 }//Fecha if1 00603 }//Fecha W1 00604 motor_x = 0x00; 00605 motor_y = 0x00; 00606 motor_z = 0x00; 00607 }//Fecha funcao 00608 00609 00610 void rotina_fdc_rise_X() 00611 { 00612 if(debounce3.read_ms() >= 50 & estado_botao_emergencia_in == false & estado_referenciamento_X == false & contador_SELECT_X == 1) { 00613 contador_rise_X += 1; 00614 pc.printf("contador_rise=%d\n", contador_rise_X); 00615 debounce3.reset(); 00616 } 00617 } 00618 00619 //=================================== Referenciamento Y ================================================== 00620 00621 void referenciamento_Y() 00622 { 00623 00624 while(estado_referenciamento_Y == false & estado_botao_emergencia_in == false & contador_SELECT_Y == 1) {//W1 00625 00626 for(i = 0; i < 4; i++) { 00627 motor_y = 1 << i; 00628 wait(0.003); 00629 } 00630 00631 if(contador_rise_Y == 1) {//if1 00632 00633 while(estado_referenciamento_Y == false & estado_botao_emergencia_in == false & contador_rise_Y == 1) {//W2 00634 00635 for(i = 3; i > -1; i--) { 00636 motor_y = 1 << i; 00637 wait(0.01); 00638 00639 } 00640 00641 if(contador_rise_Y == 2) {//if2 00642 00643 while(estado_referenciamento_Y == false & estado_botao_emergencia_in == false & contador_rise_Y == 2) {//W3 00644 00645 for(i = 0; i < 4; i++) { 00646 motor_y = 1 << i; 00647 wait(0.01); 00648 } 00649 00650 if(contador_rise_Y == 3) {//if3 00651 00652 while(seguranca_fdc_Y != 8 & estado_referenciamento_Y == false & estado_botao_emergencia_in == false & contador_rise_Y == 3) {//W4 00653 for(i = 3; i > -1; i--) { 00654 motor_y = 1 << i; 00655 wait(0.01); 00656 00657 } 00658 seguranca_fdc_Y += 1; 00659 00660 }//Fecha W4 00661 00662 estado_referenciamento_Y = true; 00663 contador_rise_Y = 0; 00664 seguranca_fdc_Y = 0; 00665 deslocamento_Y = 0; //Define o deslocamento linear total 00666 pulsos_Y = 0; 00667 deslocamento_max_Y = 100; //Define o deslocamento linear total 00668 tempo_acionamento = 3180; 00669 velocidade = 0.003; 00670 rotina_deslocamento_eixo(); 00671 00672 }//Fecha if3 00673 }//Fecha W3 00674 00675 }//Fecha if2 00676 }//Fecha W2 00677 }//Fecha if1 00678 }//Fecha W1 00679 motor_x = 0x00; 00680 motor_y = 0x00; 00681 motor_z = 0x00; 00682 }//Fecha funcao 00683 00684 00685 void rotina_fdc_rise_Y() 00686 { 00687 if(debounce3.read_ms() >= 50 & estado_botao_emergencia_in == false & estado_referenciamento_Y == false & contador_SELECT_Y == 1) { 00688 contador_rise_Y += 1; 00689 pc.printf("contador_rise=%d\n", contador_rise_Y); 00690 debounce3.reset(); 00691 } 00692 } 00693 00694 //========================================== Referenciamento Z ==================================== 00695 00696 00697 void referenciamento_Z() 00698 { 00699 00700 while(estado_referenciamento_Z == false & estado_botao_emergencia_in == false & contador_SELECT_Z == 1) {//W1 00701 00702 for(i = 0; i < 4; i++) { 00703 motor_z = 1 << i; 00704 wait(0.003); 00705 } 00706 00707 if(contador_rise_Z == 1) {//if1 00708 00709 while(estado_referenciamento_Z == false & estado_botao_emergencia_in == false & contador_rise_Z == 1) {//W2 00710 00711 for(i = 3; i > -1; i--) { 00712 motor_z = 1 << i; 00713 wait(0.01); 00714 00715 } 00716 00717 if(contador_rise_Z == 2) {//if2 00718 00719 while(estado_referenciamento_Z == false & estado_botao_emergencia_in == false & contador_rise_Z == 2) {//W3 00720 00721 for(i = 0; i < 4; i++) { 00722 motor_z = 1 << i; 00723 wait(0.01); 00724 } 00725 00726 if(contador_rise_Z == 3) {//if3 00727 00728 while(seguranca_fdc_Z != 8 & estado_referenciamento_Z == false & estado_botao_emergencia_in == false & contador_rise_Z == 3) {//W4 00729 for(i = 3; i > -1; i--) { 00730 motor_z = 1 << i; 00731 wait(0.01); 00732 00733 } 00734 seguranca_fdc_Z += 1; 00735 00736 }//Fecha W4 00737 00738 estado_referenciamento_Z = true; 00739 estado_referenciamento = true; 00740 00741 contador_rise_Z = 0; 00742 seguranca_fdc_Z = 0; 00743 deslocamento_Z = 0; //Define o deslocamento linear total 00744 pulsos_Z = 0; 00745 deslocamento_max_Z = 100; //Define o deslocamento linear total 00746 tempo_acionamento = 3180; 00747 velocidade = 0.003; 00748 rotina_deslocamento_eixo(); 00749 recebe_arduino.printf("D\n"); //Done referenciamento 00750 00751 }//Fecha if3 00752 }//Fecha W3 00753 00754 }//Fecha if2 00755 }//Fecha W2 00756 }//Fecha if1 00757 }//Fecha W1 00758 motor_x = 0x00; 00759 motor_y = 0x00; 00760 motor_z = 0x00; 00761 }//Fecha funcao 00762 00763 00764 void rotina_fdc_rise_Z() 00765 { 00766 if(debounce3.read_ms() >= 50 & estado_botao_emergencia_in == false & estado_referenciamento_Z == false & contador_SELECT_Z == 1) { 00767 contador_rise_Z += 1; 00768 pc.printf("contador_rise=%d\n", contador_rise_Z); 00769 debounce3.reset(); 00770 } 00771 } 00772 00773 00774 void rotina_JOG() 00775 { 00776 if(sizeof(set_eixos) == 0) { 00777 motor_x = 0x00; 00778 motor_y = 0x00; 00779 motor_z = 0x00; 00780 } 00781 00782 else { 00783 //============== Movimenta Eixo Y ====================================== 00784 00785 if (set_eixos[0] == '-' & set_eixos[1] == 'Y') { 00786 tempo_motor.start(); 00787 while(tempo_motor.read_ms() <= tempo_acionamento & deslocamento_Y > 0 & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 00788 for(i = 0; i < 4; i++) { 00789 motor_y = 1 << i; 00790 pulsos_Y-=1; 00791 wait(velocidade); 00792 rotina_velocidade_eixo(); 00793 rotina_deslocamento_eixo(); 00794 00795 } 00796 } 00797 tempo_motor.reset(); 00798 tempo_motor.stop(); 00799 } 00800 00801 if(set_eixos[0] == '+' & set_eixos[1] == 'Y') { 00802 tempo_motor.start(); 00803 while(tempo_motor.read_ms() <= tempo_acionamento & deslocamento_max_Y > deslocamento_Y & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 00804 for(i = 3; i > -1; i--) { 00805 motor_y = 1 << i; 00806 pulsos_Y+=1; 00807 wait(velocidade); 00808 rotina_velocidade_eixo(); 00809 rotina_deslocamento_eixo(); 00810 00811 } 00812 } 00813 tempo_motor.reset(); 00814 tempo_motor.stop(); 00815 } 00816 00817 //============== Movimenta Eixo X ====================================== 00818 00819 if (set_eixos[0] == '-' & set_eixos[1] == 'X') { 00820 tempo_motor.start(); 00821 while(tempo_motor.read_ms() <= tempo_acionamento & deslocamento_X > 0 & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 00822 for(i = 0; i < 4; i++) { 00823 motor_x = 1 << i; 00824 pulsos_X-=1; 00825 wait(velocidade); 00826 rotina_velocidade_eixo(); 00827 rotina_deslocamento_eixo(); 00828 00829 } 00830 } 00831 tempo_motor.reset(); 00832 tempo_motor.stop(); 00833 } 00834 00835 if(set_eixos[0] == '+' & set_eixos[1] == 'X') { 00836 tempo_motor.start(); 00837 while(tempo_motor.read_ms() <= tempo_acionamento & deslocamento_max_X > deslocamento_X & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 00838 for(i = 3; i > -1; i--) { 00839 motor_x = 1 << i; 00840 pulsos_X+=1; 00841 wait(velocidade); 00842 rotina_velocidade_eixo(); 00843 rotina_deslocamento_eixo(); 00844 00845 } 00846 } 00847 tempo_motor.reset(); 00848 tempo_motor.stop(); 00849 } 00850 00851 00852 //============== Movimenta Eixo Z ====================================== 00853 00854 if (set_eixos[0] == '-' & set_eixos[1] == 'Z') { 00855 tempo_motor.start(); 00856 while(tempo_motor.read_ms() <= tempo_acionamento & deslocamento_Z > 0 & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 00857 for(i = 0; i < 4; i++) { 00858 motor_z = 1 << i; 00859 pulsos_Z-=1; 00860 wait(velocidade); 00861 rotina_velocidade_eixo(); 00862 rotina_deslocamento_eixo(); 00863 00864 } 00865 } 00866 tempo_motor.reset(); 00867 tempo_motor.stop(); 00868 } 00869 00870 if(set_eixos[0] == '+' & set_eixos[1] == 'Z') { 00871 tempo_motor.start(); 00872 while(tempo_motor.read_ms() <= tempo_acionamento & deslocamento_max_Z > deslocamento_Z & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 00873 for(i = 3; i > -1; i--) { 00874 motor_z = 1 << i; 00875 pulsos_Z+=1; 00876 wait(velocidade); 00877 rotina_velocidade_eixo(); 00878 rotina_deslocamento_eixo(); 00879 00880 } 00881 } 00882 tempo_motor.reset(); 00883 tempo_motor.stop(); 00884 } 00885 00886 motor_x = 0x00; 00887 motor_y = 0x00; 00888 motor_z = 0x00; 00889 } 00890 } 00891 00892 void rotina_solta() 00893 { 00894 //============== Movimenta Eixo Y ====================================== 00895 rotina_deslocamento_eixo(); 00896 00897 for(int a = 3; a < (3*(tubos_usados + 1)); a=a+3) { 00898 00899 quantidade_depositada = 0; 00900 tubo_atual++; 00901 00902 while(quantidades[tubo_atual] > quantidade_depositada & estado_botao_emergencia_in == false) { 00903 00904 //============== Movimenta Z para posição de segurança ================= 00905 00906 if(Z_seguranca >= deslocamento_Z) { 00907 00908 while(deslocamento_Z < Z_seguranca & deslocamento_max_Z > deslocamento_Z & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 00909 for(i = 3; i > -1; i--) { 00910 motor_z = 1 << i; 00911 pulsos_Z+=1; 00912 wait(velocidade); 00913 rotina_velocidade_eixo(); 00914 rotina_deslocamento_eixo(); 00915 00916 } 00917 pc.printf("Z= %f \r\n", deslocamento_Z); 00918 } 00919 pc.printf("Z seguro atingido \r\n"); 00920 } 00921 00922 00923 00924 if (posicoes[a+1] <= deslocamento_Y) { 00925 while(deslocamento_Y > posicoes[a+1] & deslocamento_Y >= 0 & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 00926 for(i = 0; i < 4; i++) { 00927 motor_y = 1 << i; 00928 pulsos_Y-=1; 00929 wait(velocidade); 00930 rotina_velocidade_eixo(); 00931 rotina_deslocamento_eixo(); 00932 00933 } 00934 pc.printf("Y= %f \r\n", deslocamento_Y); 00935 } 00936 00937 00938 } else motor_y = 0x00; 00939 00940 if(posicoes[a+1] >= deslocamento_Y) { 00941 00942 while(deslocamento_Y < posicoes[a+1] & deslocamento_max_Y >= deslocamento_Y & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 00943 for(i = 3; i > -1; i--) { 00944 motor_y = 1 << i; 00945 pulsos_Y+=1; 00946 wait(velocidade); 00947 rotina_velocidade_eixo(); 00948 rotina_deslocamento_eixo(); 00949 00950 } 00951 pc.printf("Y= %f \r\n", deslocamento_Y); 00952 } 00953 00954 } else motor_y = 0x00; 00955 00956 //============== Movimenta Eixo X ====================================== 00957 00958 if (posicoes[a] <= deslocamento_X) { 00959 00960 while(deslocamento_X > posicoes[a] & deslocamento_X >= 0 & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 00961 for(i = 0; i < 4; i++) { 00962 motor_x = 1 << i; 00963 pulsos_X-=1; 00964 wait(velocidade); 00965 rotina_velocidade_eixo(); 00966 rotina_deslocamento_eixo(); 00967 00968 } 00969 pc.printf("X= %f \r\n", deslocamento_X); 00970 } 00971 00972 } else motor_x = 0x00; 00973 00974 if(posicoes[a] >= deslocamento_X) { 00975 00976 while(deslocamento_X < posicoes[a] & deslocamento_max_X > deslocamento_X & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 00977 for(i = 3; i > -1; i--) { 00978 motor_x = 1 << i; 00979 pulsos_X+=1; 00980 wait(velocidade); 00981 rotina_velocidade_eixo(); 00982 rotina_deslocamento_eixo(); 00983 00984 } 00985 pc.printf("X= %f \r\n", deslocamento_X); 00986 } 00987 00988 } else motor_x = 0x00; 00989 00990 00991 //============== Movimenta Eixo Z ====================================== 00992 00993 if (posicoes[a+2] <= deslocamento_Z) { 00994 00995 while(deslocamento_Z > posicoes[a+2] & deslocamento_Z > 0 & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 00996 for(i = 0; i < 4; i++) { 00997 motor_z = 1 << i; 00998 pulsos_Z-=1; 00999 wait(velocidade); 01000 rotina_velocidade_eixo(); 01001 rotina_deslocamento_eixo(); 01002 01003 } 01004 pc.printf("Z= %f \r\n", deslocamento_Z); 01005 } 01006 01007 } else motor_z = 0x00; 01008 01009 if(posicoes[a+2] >= deslocamento_Z) { 01010 01011 while(deslocamento_Z < posicoes[a+2] & deslocamento_max_Z > deslocamento_Z & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 01012 for(i = 3; i > -1; i--) { 01013 motor_z = 1 << i; 01014 pulsos_Z+=1; 01015 wait(velocidade); 01016 rotina_velocidade_eixo(); 01017 rotina_deslocamento_eixo(); 01018 01019 } 01020 pc.printf("Z= %f \r\n", deslocamento_Z); 01021 } 01022 01023 } else motor_z = 0x00; 01024 01025 motor_x = 0x00; 01026 motor_y = 0x00; 01027 motor_z = 0x00; 01028 01029 rotina_aciona_pipeta(); 01030 rotina_pega(); 01031 rotina_aciona_pipeta(); 01032 quantidade_depositada++; 01033 pc.printf("quantidade_depositada= %d \r\n", quantidade_depositada); 01034 } 01035 } 01036 } 01037 01038 01039 void rotina_pega() 01040 { 01041 01042 //============== Movimenta Z para posição de segurança ================= 01043 01044 if(Z_seguranca >= deslocamento_Z) { 01045 01046 while(deslocamento_Z < Z_seguranca & deslocamento_max_Z > deslocamento_Z & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 01047 for(i = 3; i > -1; i--) { 01048 motor_z = 1 << i; 01049 pulsos_Z+=1; 01050 wait(velocidade); 01051 rotina_velocidade_eixo(); 01052 rotina_deslocamento_eixo(); 01053 01054 } 01055 pc.printf("Z= %f \r\n", deslocamento_Z); 01056 } 01057 pc.printf("Z seguro atingido\r\n"); 01058 } 01059 01060 //============== Movimenta Eixo Y ====================================== 01061 rotina_deslocamento_eixo(); 01062 01063 if (posicoes[1] <= deslocamento_Y) { 01064 while(deslocamento_Y > posicoes[1] & deslocamento_Y >= 0 & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 01065 for(i = 0; i < 4; i++) { 01066 motor_y = 1 << i; 01067 pulsos_Y-=1; 01068 wait(velocidade); 01069 rotina_velocidade_eixo(); 01070 rotina_deslocamento_eixo(); 01071 01072 } 01073 pc.printf("Y= %f \r\n", deslocamento_Y); 01074 } 01075 01076 01077 } else motor_y = 0x00; 01078 01079 if(posicoes[1] >= deslocamento_Y) { 01080 01081 while(deslocamento_Y < posicoes[1] & deslocamento_max_Y >= deslocamento_Y & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 01082 for(i = 3; i > -1; i--) { 01083 motor_y = 1 << i; 01084 pulsos_Y+=1; 01085 wait(velocidade); 01086 rotina_velocidade_eixo(); 01087 rotina_deslocamento_eixo(); 01088 01089 } 01090 pc.printf("Y= %f \r\n", deslocamento_Y); 01091 } 01092 01093 } else motor_y = 0x00; 01094 01095 //============== Movimenta Eixo X ====================================== 01096 01097 if (posicoes[0] <= deslocamento_X) { 01098 01099 while(deslocamento_X > posicoes[0] & deslocamento_X >= 0 & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 01100 for(i = 0; i < 4; i++) { 01101 motor_x = 1 << i; 01102 pulsos_X-=1; 01103 wait(velocidade); 01104 rotina_velocidade_eixo(); 01105 rotina_deslocamento_eixo(); 01106 01107 } 01108 pc.printf("X= %f \r\n", deslocamento_X); 01109 } 01110 01111 } else motor_x = 0x00; 01112 01113 if(posicoes[0] >= deslocamento_X) { 01114 01115 while(deslocamento_X < posicoes[0] & deslocamento_max_X > deslocamento_X & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 01116 for(i = 3; i > -1; i--) { 01117 motor_x = 1 << i; 01118 pulsos_X+=1; 01119 wait(velocidade); 01120 rotina_velocidade_eixo(); 01121 rotina_deslocamento_eixo(); 01122 01123 } 01124 pc.printf("X= %f \r\n", deslocamento_X); 01125 } 01126 01127 } else motor_x = 0x00; 01128 01129 01130 //============== Movimenta Eixo Z ====================================== 01131 01132 if (posicoes[2] <= deslocamento_Z) { 01133 01134 while(deslocamento_Z > posicoes[2] & deslocamento_Z > 0 & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 01135 for(i = 0; i < 4; i++) { 01136 motor_z = 1 << i; 01137 pulsos_Z-=1; 01138 wait(velocidade); 01139 rotina_velocidade_eixo(); 01140 rotina_deslocamento_eixo(); 01141 01142 } 01143 pc.printf("Z= %f \r\n", deslocamento_Z); 01144 } 01145 01146 } else motor_z = 0x00; 01147 01148 if(posicoes[2] >= deslocamento_Z) { 01149 01150 while(deslocamento_Z < posicoes[2] & deslocamento_max_Z > deslocamento_Z & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 01151 for(i = 3; i > -1; i--) { 01152 motor_z = 1 << i; 01153 pulsos_Z+=1; 01154 wait(velocidade); 01155 rotina_velocidade_eixo(); 01156 rotina_deslocamento_eixo(); 01157 01158 } 01159 pc.printf("Z= %f \r\n", deslocamento_Z); 01160 } 01161 01162 } else motor_z = 0x00; 01163 01164 motor_x = 0x00; 01165 motor_y = 0x00; 01166 motor_z = 0x00; 01167 01168 } 01169 01170 01171 void rotina_aciona_pipeta() 01172 { 01173 if(estado_botao_emergencia_in == false) { 01174 sinal_pipeta = 1; //Despeja qualquer residuo restante 01175 wait(tempo_pipeta); 01176 sinal_pipeta = 0; //Coleta volume especificado 01177 } 01178 01179 } 01180 01181 void rotina_movimenta() //j é o ponteiro para sempre inicias em X 01182 { 01183 01184 //============== Movimenta Z para posição de segurança ================= 01185 01186 if(Z_seguranca >= deslocamento_Z) { 01187 01188 while(deslocamento_Z < Z_seguranca & deslocamento_max_Z > deslocamento_Z & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 01189 for(i = 3; i > -1; i--) { 01190 motor_z = 1 << i; 01191 pulsos_Z+=1; 01192 wait(velocidade); 01193 rotina_velocidade_eixo(); 01194 rotina_deslocamento_eixo(); 01195 01196 } 01197 pc.printf("Z= %f \r\n", deslocamento_Z); 01198 } 01199 pc.printf("Z seguro atingido\r\n"); 01200 } 01201 01202 01203 if (posicoes[j+1] <= deslocamento_Y) { 01204 while(deslocamento_Y > posicoes[j+1] & deslocamento_Y >= 0 & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 01205 for(i = 0; i < 4; i++) { 01206 motor_y = 1 << i; 01207 pulsos_Y-=1; 01208 wait(velocidade); 01209 rotina_velocidade_eixo(); 01210 rotina_deslocamento_eixo(); 01211 01212 } 01213 pc.printf("Y= %f \r\n", deslocamento_Y); 01214 } 01215 01216 01217 } else motor_y = 0x00; 01218 01219 if(posicoes[j+1] >= deslocamento_Y) { 01220 01221 while(deslocamento_Y < posicoes[j+1] & deslocamento_max_Y >= deslocamento_Y & pulsos_Y >= 0 & estado_botao_emergencia_in == false) { 01222 for(i = 3; i > -1; i--) { 01223 motor_y = 1 << i; 01224 pulsos_Y+=1; 01225 wait(velocidade); 01226 rotina_velocidade_eixo(); 01227 rotina_deslocamento_eixo(); 01228 01229 } 01230 pc.printf("Y= %f \r\n", deslocamento_Y); 01231 } 01232 01233 } else motor_y = 0x00; 01234 01235 //============== Movimenta Eixo X ====================================== 01236 01237 if (posicoes[j] <= deslocamento_X) { 01238 01239 while(deslocamento_X > posicoes[j] & deslocamento_X >= 0 & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 01240 for(i = 0; i < 4; i++) { 01241 motor_x = 1 << i; 01242 pulsos_X-=1; 01243 wait(velocidade); 01244 rotina_velocidade_eixo(); 01245 rotina_deslocamento_eixo(); 01246 01247 } 01248 pc.printf("X= %f \r\n", deslocamento_X); 01249 } 01250 01251 } else motor_x = 0x00; 01252 01253 if(posicoes[j] >= deslocamento_X) { 01254 01255 while(deslocamento_X < posicoes[j] & deslocamento_max_X > deslocamento_X & pulsos_X >= 0 & estado_botao_emergencia_in == false) { 01256 for(i = 3; i > -1; i--) { 01257 motor_x = 1 << i; 01258 pulsos_X+=1; 01259 wait(velocidade); 01260 rotina_velocidade_eixo(); 01261 rotina_deslocamento_eixo(); 01262 01263 } 01264 pc.printf("X= %f \r\n", deslocamento_X); 01265 } 01266 01267 } else motor_x = 0x00; 01268 01269 01270 //============== Movimenta Eixo Z ====================================== 01271 01272 if (posicoes[j+2] <= deslocamento_Z) { 01273 01274 while(deslocamento_Z > posicoes[j+2] & deslocamento_Z > 0 & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 01275 for(i = 0; i < 4; i++) { 01276 motor_z = 1 << i; 01277 pulsos_Z-=1; 01278 wait(velocidade); 01279 rotina_velocidade_eixo(); 01280 rotina_deslocamento_eixo(); 01281 01282 } 01283 pc.printf("Z= %f \r\n", deslocamento_Z); 01284 } 01285 01286 } else motor_z = 0x00; 01287 01288 if(posicoes[j+2] >= deslocamento_Z) { 01289 01290 while(deslocamento_Z < posicoes[j+2] & deslocamento_max_Z > deslocamento_Z & pulsos_Z >= 0 & estado_botao_emergencia_in == false) { 01291 for(i = 3; i > -1; i--) { 01292 motor_z = 1 << i; 01293 pulsos_Z+=1; 01294 wait(velocidade); 01295 rotina_velocidade_eixo(); 01296 rotina_deslocamento_eixo(); 01297 01298 } 01299 pc.printf("Z= %f \r\n", deslocamento_Z); 01300 } 01301 01302 } else motor_z = 0x00; 01303 01304 motor_x = 0x00; 01305 motor_y = 0x00; 01306 motor_z = 0x00; 01307 01308 rotina_aciona_pipeta(); 01309 rotina_pega(); 01310 rotina_aciona_pipeta(); 01311 quantidade_depositada++; 01312 pc.printf("quantidade_depositada= %d \r\n", quantidade_depositada); 01313 } 01314 01315 void recebe_dados(unsigned char *data_buf, int numchar) 01316 { 01317 int count=0; 01318 if(numchar == 0) { 01319 numchar = sizeof(data_buf); 01320 } 01321 01322 while(count < 5) { 01323 if(recebe_arduino.readable()) { 01324 *data_buf = recebe_arduino.getc(); 01325 data_buf+=1; 01326 count++; 01327 } 01328 } 01329 }
Generated on Fri Jul 29 2022 12:35:16 by
1.7.2