To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.spyboticsOpen lugnet.robotics.spybotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Spybotics / 256
255  |  257
Subject: 
Spybot studies: SetTxDirection() confusion
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Fri, 7 Nov 2003 04:36:05 GMT
Viewed: 
6362 times
  
John,

I noticed the SetTxDirection() function in your mana_control.nqc program. I
thought it might be useful for my project, so it became my next subject of study.
  The spy.nqh shows this:

   #define TX_DIRECTION_FRONT_LEFT 0
   #define TX_DIRECTION_FRONT_RIGHT 1
   #define TX_DIRECTION_BACK 2
   #define TX_DIRECTION_HIGH_POWER 3
   #define TX_DIRECTION_PC 4

but in the 2.5 SDK, I can only find

[18] Direction
0 == high power
1 == PC

I modified your mana_control program to use each of the above defines. I observed
the Spybot using the laser LED only after executing
SetTxDirection(TX_DIRECTION_FRONT_RIGHT). For all the other values, the infrared
LED in the mid-right side of the Spybot was used. IIRC, this is the only infrared
LED, so what could FRONT_LEFT and FRONT_RIGHT and BACK mean, anyway? Also, the
SDK entry begs the question, how do I set Tx to low power?

Here's my test program, set_tx_direction.nqc:
/* set_tx_direction
  *
  * A study to evaluate the function of
  * the TX_DIRECTION_xxx defines and the
  * SetTxDirection(const int &d) function.
  *
  * Based on John Hansen's mana_control.nqc program.
  */

#include "spy.nqh"

#define MANAS_ALL 4
#define MANAS_1 5
#define MANAS_2 6
#define MANAS_3 7
#define EM_FLOAT 0
#define EM_OFF 8
#define EM_FWD 7
#define EM_REV 15

int em1, em2, em3, em4, em5, em6       ;

task main()
{
   // turn off annoying ping
   SetPingInterval(0);
   // This demo starts the manas comms task, then loops forever.
   // In the loop, it steps through three control phases setting
   // the motors to off, and then paired forward and reverse.

   start manas;
   start tx_direction;

   while (true)
   {
     em1=EM_OFF;
     em2=EM_OFF;
     em3=EM_OFF;
     em4=EM_OFF;
     em5=EM_OFF;
     em6=EM_OFF;

     Wait(100);

     em1=EM_FWD;
     em2=EM_REV;
     em3=EM_FWD;
     em4=EM_REV;
     em5=EM_FWD;
     em6=EM_REV;

     Wait(100);

     em1=EM_FLOAT;
     em2=EM_FLOAT;
     em3=EM_FLOAT;
     em4=EM_FLOAT;
     em5=EM_FLOAT;
     em6=EM_FLOAT;

     Wait(100);

     em1=EM_REV;
     em2=EM_FWD;
     em3=EM_REV;
     em4=EM_FWD;
     em5=EM_REV;
     em6=EM_FWD;

     Wait(100);
   }
}
// The manas task continuously resends the motor settings.
// When the RCX is halted, this task stops and the manas
// motors automatically shut off

task tx_direction()
{
   while (true)
   {
           PlaySound(SOUND_CLICK);
           SetTxDirection(TX_DIRECTION_FRONT_LEFT);  // Observed: IR LED
           Wait(100);
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           SetTxDirection(TX_DIRECTION_FRONT_RIGHT); // Observed: Laser LED
           Wait(100);
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           SetTxDirection(TX_DIRECTION_BACK); // Observed: IR LED
           Wait(100);
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           SetTxDirection(TX_DIRECTION_HIGH_POWER); // Observed: IR LED
           Wait(100);
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           Wait(10);;
           PlaySound(SOUND_CLICK);
           SetTxDirection(TX_DIRECTION_PC); // Observed: IR LED
           Wait(100);
   }
}

task manas()
{
   SetTxType(TX_TYPE_USER);
   SetTxBaud(TX_BAUD_4800);

   while (true)
   {
//    SetTxUserChecksum(TX_USER_NO_CHECKSUM);
//    SetTxUserBiPhase(TX_USER_NO_BIPHASE);
//    SetTxUserPreamblePos(0);
//    SetTxUserPreambleLen(0);

//    SetSerialData(0,0x6f);
//    SetSerialData(1,0x0b);
//    SendSerial(0,2);

//    em1 = 0;
/*
     // Set the first unit two message bytes and send them
     SetSerialData(0,(RC_CHANNEL_BROADCAST+4)*16+em1);
     SetSerialData(1,em2*16+16-(((RC_CHANNEL_BROADCAST+4)+em1+em2) & 16));
     SendSerial(0,2);
*/

     // Set the first unit two message bytes and send them
     SetSerialData(0,MANAS_1*0x10+em1);
     SetSerialData(1,em2*0x10+0x10-((MANAS_1+em1+em2)&0xf));
     SendSerial(0,2);

     // Set the second unit two message bytes and send them
     SetSerialData(0,MANAS_2*0x10+em3);
     SetSerialData(1,em4*0x10+0x10-((MANAS_2+em3+em4)&0xf));
     SendSerial(0,2);

     // Set the third unit two message bytes and send them
     SetSerialData(0,MANAS_3*0x10+em5);
     SetSerialData(1,em6*0x10+0x10-((MANAS_3+em5+em6)&0xf));
     SendSerial(0,2);

     // Delay for a while so we can resend them regularly
     Wait(10);
   }
}



Message has 2 Replies:
  Re: Spybot studies: SetTxDirection() confusion
 
I forgot to mention that the mana (set to channel 3) didn't respond to the laser LED's command message. Is this because the mana isn't sensitive to visible red or because the signal is somehow encoded differently when it comes out the laser? (or (...) (21 years ago, 7-Nov-03, to lugnet.robotics.spybotics)
  Re: Spybot studies: SetTxDirection() confusion
 
(...) This portion of the Spybot NQC API is under substantial revision... :-) I based the constants on those found in Spybot.h which are apparently just plain wrong. The current version of my spy.nqh file has #define SERIAL_CHANNEL_HIGH_POWER 0 (...) (21 years ago, 7-Nov-03, to lugnet.robotics.spybotics)

9 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR