|
Page 1 of 1
|
[ 4 posts ] |
|
Delay with HTIRL using new driver
| Author |
Message |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 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: 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 |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Sat Oct 16, 2010 9:13 am |
|
 |
|
DiMastero
Expert
Joined: Wed Jun 30, 2010 7:15 am Posts: 179
|
 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 |
|
 |
|
ivanseidel
Rookie
Joined: Tue Sep 07, 2010 10:56 am Posts: 43
|
 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:
_________________ My creations: techlego.blogspot.com
|
| Sat Oct 16, 2010 11:34 am |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
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
|
|