Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTRSensors Library for Pinguino P8 and P32
21-06-2016, 11:28 PM,
#11
RE: QTRSensors Library for Pinguino P8 and P32
Leonardo,
 any luck with 8 bit?
 thank you
fred
Reply
25-06-2016, 01:03 PM, (This post was last modified: 28-06-2016, 05:35 PM by Leonardo. Edit Reason: Updated library link )
#12
RE: QTRSensors Library for Pinguino P8 and P32
Hi Fred

Sorry for the delay in the response!
I am short of time due to a secondary school robotic championship that I am organizing.

Anyway, I think that I managed to solve the compilation and library problems.
The compilation problems were due to the use of reserved words in P8, like for example GO that is used by the ADC.
In the case of the library, the problem was the function micros() that does not exist on P8, so I had to change the code to replace the work performed by the micros function.

I had no time to test it in hardware, could you please give a try on the PIC18F4550 and tell me how it goes?

Here is the link to the new library and example code for PIC18F4550

https://drive.google.com/open?id=0BwlBs9...HkzNW5VcXc

Let me know if you have any trouble with the new library modifications and example code.

Regards,

Leonardo.
Reply
26-06-2016, 07:06 PM, (This post was last modified: 26-06-2016, 08:18 PM by derf158.)
#13
RE: QTRSensors Library for Pinguino P8 and P32
Leonardo,
 i have test the new library and this is the output form my terminal

Welcome to minicom 2.7
QTRSensors library test software
OPTIONS: I18n 
Compiled on Jan  1 2014, 09:30:18.
Port /dev/ttyACM0, 12:59:45

Press CTRL-A Z for help on special keys                                       
                                                                              
* QTR TEST LIBRERIA *                                                         
* Inicializando sensores... *                                                 
* Coloque los sensores sobre linea blanca *                                   
* Presione una tecla para proceder... *
* Inicializando sensores... *
* Coloque los sensores sobre linea blanca *
* Presione una tecla para proceder... *

cdc did not print any values

thank you
fred
Reply
26-06-2016, 10:02 PM, (This post was last modified: 26-06-2016, 10:10 PM by Leonardo.)
#14
RE: QTRSensors Library for Pinguino P8 and P32
Hi Fred

I have tried the code in the Pinguino PIC18F4550 and find a behaviour quite deceptive of the code.

In the code you call the function QTRSensor.calibrate(QTR_EMITTERS_ON) twice. One for calibrate the white color, in line 41, and one to calibrate the black color, in line 47.

If you comment one of the calls, the code works ok.

Please try to comment out one of the function calls and let me know the results in your hardware

i.e.
// QTRSensor.calibrate(QTR_EMITTERS_ON);

And also add the following line at the beginning of the setup code, just in case

ADCON1 = 0x0F;

I will try to figure out what is the problem. Seems that we are losing something in the compilation process.

Sorry for the inconvinience

Regards,

Leonardo.

EDIT: I found that if you duplicate the first call the code works ok!! Please try duplicate the first call and let me know the results!
Reply
27-06-2016, 02:25 AM,
#15
RE: QTRSensors Library for Pinguino P8 and P32
Code:
/*-----------------------------------------------------
Author:  Leonardo Alvarez
Date: 2016-05-10
Description:
   QTRSensors library test software
   
   Utiliza 5 sensores para detectar una linea
   blanca sobre una superficie negra.
  sudo minicom -o -D /dev/ttyACM0
-----------------------------------------------------*/
// Sensores
#define NUMBER_SENSORS 5    // Defino la cantidad de sensores que se utilizaran
#define LINE_WHITE 1            // Defino el color de la linea blanca
#define LINE_BLACK 0            // Defino el color de la linea negra
#define TIME_OUT     2500         // Defino el tiempo maximo de espera
unsigned char c = 0;
unsigned char pins[NUMBER_SENSORS]={0,1,2,3,4};
unsigned int values_sensors[NUMBER_SENSORS];
unsigned char i = 0;
void setup() {
delay(500);
   // put your setup code here, to run once:
   //unsigned char c = 0;//unsigned char c = 0;
  //unsigned char i = 1000;
   
   //c = CDC.getKey();//key0= CDC.getKey();
   CDC.printf(" QTR TEST LIBRARY \n\r" );
   CDC.printf(" initializing sensors...\n\r" );
   CDC.printf(" Press any key to proceed...\n\r"  );
   c = CDC.getKey();
   // Initialize the sensors
   // Initialize the sensors routine
   // 5 sensors
   // No emitter pin. All sensors directly connected to GND
   // timeout 2000 * micros processing time
   QTRSensors.init(pins,NUMBER_SENSORS,QTR_NO_EMITTER_PIN,TIME_OUT);
   delay(500);
   CDC.printf("Place the sensors on WHITE line \n\r"  );
   CDC.printf(" Press any key to proceed...\n\r"  );
    c = CDC.getKey();
   CDC.printf(" calibrating WHITE, wait...\n\r");
   QTRSensors.calibrate(QTR_EMITTERS_ON);
   delay(1000);
   CDC.printf(" Place the sensors on BLACK line \n\r" );
   CDC.printf(" Press any key to proceed...\n\r");
   c = CDC.getKey();
   CDC.printf(" calibrating BLACK, wait...\n\r");
   //QTRSensors.calibrate(QTR_EMITTERS_ON);
   delay(1000);
    // I show the calibration between 0 and 1000 for each sensor
   CDC.printf("* Calibrated sensor reading... *\n\r");
   QTRSensors.readCalibrated(values_sensors,QTR_EMITTERS_ON);
   for(i=0;i<NUMBER_SENSORS;i++){    
       CDC.printf("%d",values_sensors[i]);
       CDC.printf("\t");
   }
   CDC.printf("\n\r");
   CDC.printf("* Calibration values *\n\r");
   CDC.printf("* Values calibratedMaximumON *\n\r");
   for(i=0;i<NUMBER_SENSORS;i++){
       CDC.printf("S[%d] = %d",i,calibratedMaximumOn[i]);
       CDC.printf("\t");
   }
   CDC.printf("\n\r");
   CDC.printf("* Values calibratedMinimumON *\n\r");
   for(i=0;i<NUMBER_SENSORS;i++){
       CDC.printf("S[%d] = %d",i,calibratedMinimumOn[i]);
       CDC.printf("\t");
   }
   CDC.printf("\n\r");
   CDC.printf("* Values calibratedMaximumOFF *\n\r");
   for(i=0;i<NUMBER_SENSORS;i++){
       CDC.printf("S[%d] = %d",i,calibratedMaximumOff[i]);
       CDC.printf("\t");
   }
   CDC.printf("\n\r");
   CDC.printf("* Values calibratedMinimumOFF *\n\r");
   for(i=0;i<NUMBER_SENSORS;i++){
       CDC.printf("S[%d] = %d",i,calibratedMinimumOff[i]);
       CDC.printf("\t");
   }
   CDC.printf("\n\r");
   CDC.printf("* Press a key to continue... *\n\r");
   c = CDC.getKey();
   
   
}

void loop() {
   // put your main code here, to run repeatedly:
   unsigned char i = 0;
   int Line = 0;
       
   // Read the line

   Line = QTRSensors.readLine(values_sensors,QTR_EMITTERS_ON,LINE_BLACK);
   // Show the results
   for(i=0;i<NUMBER_SENSORS;i++){    
       CDC.printf("%d",values_sensors[i]);
       CDC.printf("\t");
   }
   CDC.printf("Line %d",Line);
   CDC.printf("\t");
   CDC.printf("\n\r");
   
   
   delay(100);

}
Leonardo,
 this what i did and it seems to be working fine i will continue testing.

fred
Reply
29-06-2016, 01:45 AM, (This post was last modified: 29-06-2016, 01:53 AM by derf158.)
#16
RE: QTRSensors Library for Pinguino P8 and P32
Leonardo,
how did you calibrate?

back and fourth over a white line then
back and fourth over a black line?

thank you 
fred
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)