View unanswered posts | View active topics It is currently Sat Aug 30, 2014 4:31 pm






Reply to topic  [ 4 posts ] 
Delay with HTIRL using new driver 
Author Message
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post Delay with HTIRL using new driver
Hi there,

I wrote this program and tested it, but I get a delay between pressing/releasing the touch sensor and the motors. Furthermore, they don't start and stop at the same time. This is my code:

Code:
#pragma config(Sensor, S1,     HTIRL,               sensorLowSpeed)
#pragma config(Sensor, S2,     TouchSensor,         sensorTouch)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "drivers/HTIRL-NG-driver.h"

int speed;

task main() {
  while (true){
   
    PFMotor(pfmotor_S1_C4_A, (ePWMMotorCommand)speed);
    PFMotor(pfmotor_S1_C4_B, (ePWMMotorCommand)speed);
   
    if (SensorValue (TouchSensor) == 1){
      speed = 7;
    }
    else{
      speed = 0;
    }
  }
}


I don't get what's wrong, so does anyone have any suggestions?

thx,
DiMastero

EDIT:

I tried it again using this program:

Code:
#pragma config(Sensor, S1,     HTIRL,               sensorLowSpeed)
#pragma config(Sensor, S2,     TouchSensor,         sensorTouch)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "drivers/HTIRL-NG-driver.h"

task main() {
  while (true){
   
    if (SensorValue (TouchSensor) == 1){
      PFMotor(pfmotor_S1_C4_A, (ePWMMotorCommand)7);
      PFMotor(pfmotor_S1_C4_B, (ePWMMotorCommand)7);
    }
    else{
      PFMotor(pfmotor_S1_C4_A, (ePWMMotorCommand)0);
      PFMotor(pfmotor_S1_C4_B, (ePWMMotorCommand)0);
    }
  }
}


It got rid of most of the delay between pressing the button and the motors starting/ stopping, but the delay between the two motors stays. Again, does anyone know how to solve my problem?

thx,
DiMastero

_________________
leonoverweel.com


Sat Oct 16, 2010 9:04 am
Profile WWW
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3203
Location: Rotterdam, The Netherlands
Post Re: Delay with HTIRL using new driver
They don't stop and start at the same time due to the way the retransmissions work. The driver will retransmit a command several times to ensure that it has arrived (there is no way to verify). This delay is what you are seeing.

In the next release I intend to make this retransmission part a configurable option. However, it is completely according to the Power Function specifications. If you want, you can hack the transmitIR(tSensors link, tByteArray &oBuffer, int channel) function yourself and remove the 3rd, 4th and 5th retransmission commands.

As a work-around, you could use a PFcomboPwmMode() command for both motors at once and then issue the PFMotor commands to ensure the motors continue to run afterwards. You can use PFcomboPwmMode() to stop both motors at the same time as well.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sat Oct 16, 2010 9:13 am
Profile WWW
Expert

Joined: Wed Jun 30, 2010 7:15 am
Posts: 181
Post Re: Delay with HTIRL using new driver
thank's a lot! that explains it. I guess I'll just wait for the next release then, because the other option is a bit to complex for me :p..

_________________
leonoverweel.com


Sat Oct 16, 2010 10:01 am
Profile WWW
Rookie

Joined: Tue Sep 07, 2010 10:56 am
Posts: 43
Post Re: Delay with HTIRL using new driver
Yes, it's reetransmiting the same code many times.
I would create another variable, the lastSpeed, and "if the lastSpeed != speed" send the code, and then set the speed to lastSpeed, so, if the speed == lastSpeed, i wouldn't send any command...

Try this:
Code:
#pragma config(Sensor, S1,     HTIRL,               sensorLowSpeed)
#pragma config(Sensor, S2,     TouchSensor,         sensorTouch)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "drivers/HTIRL-NG-driver.h"

int speed=0,lastSpeed=0;

task main() {
  while (true){
    if(lastSpeed!=speed){
        PFMotor(pfmotor_S1_C4_A, (ePWMMotorCommand)speed);
        PFMotor(pfmotor_S1_C4_B, (ePWMMotorCommand)speed);       
        lastSpeed=speed;
    }

   
    if (SensorValue (TouchSensor) == 1){
      speed = 7;
    }
    else{
      speed = 0;
    }
  }
}

_________________
My creations: techlego.blogspot.com


Sat Oct 16, 2010 11:34 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.