| | | | |
| |
| In the included message below, I have edited the code from the previous
message to remove some stray characters and to add code for a third
Manas dual-motor unit. I haven't tried to find the address for "all" Manas
units.
In experimenting with control codes, I found that EM_OFF, as defined in
this code as zero, is really a float command and that 8 appears to be
immediate off. I propose that these names and values be used in a way
that parallels the RCX commands. So:
#define EM_FLOAT 0
#define EM_OFF 8
Has anyone else determined what other bit patterns do? Once they are
completely understood, someone should put together a manas.nqh file with
#defines and appropriate function definitions.
It is now possible for an RCX to directly and independently control up
to nine motors! And by slaving Scouts and Micro Scouts...
Dennis Williamson
In lugnet.robotics, "Pink Tail" <pinkmice@borg.com> writes:
> Having decoded the manas remote controllers protocol, with a
> couple of hints from RCX2 users, Zhengrong Zang amongst them,
> I realised the 76kHz, 25% duty cycle, 4800 baud settings were
> exactly those of the Manas.
>
> As a result, I present for your appraisal, a tested nqc program which
> controls all four Manas motors. This could easily be expanded to
> include six, if you have two sets, ie; three receivers.
>
>
#define MANAS_1 5
#define MANAS_2 6
#define MANAS_3 7
#define EM_OFF 0
#define EM_FWD 7
#define EM_REV 15
int em1,em2,em3,em4,em5,em6; //Global motor control locations
task main()
{
// 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;
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_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 manas()
{
while (true)
{
// First ensure serial settings are still ok
SetSerialComm(SERIAL_COMM_4800|SERIAL_COMM_DUTY25|SERIAL_COMM_76KHZ);
SetSerialPacket(SERIAL_PACKET_DEFAULT);
// Set to low power so we don't run the battery down too quick
SetTxPower(TX_POWER_HI);
// 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);
}
}
>
>
> I hope this is encouraging to you as it is to me, it expands the RCX
> output capability greatly.
>
> John Barnes
| | | | | | | | | | | | | Someone pointed out to me that I made a typo in the program lines shown below.
The original program reads:
SetTxPower(TX_POWER_LO);
I had changed it during testing since I was talking to three Manas motor units
and I didn't want to have to be particularly careful to position them and the
RCX precisely enough to have the communication work reliably.
Dennis
In lugnet.robotics, Dennis Williamson writes:
[snip]
> // Set to low power so we don't run the battery down too quick
>
> SetTxPower(TX_POWER_HI);
[snip]
| | | | | | | | | | | | | | | I just wanted to say "thanks" to everyone who contributed to this thread!
After installing NQC and BricxCC last night, and pasting the code you wrote
into a program, my sons (home on Christmas break) are happily making their
RCX drive their manas motors crazy. :)
We even went through the exercise of writing a program to test-send all 16
different codes to the manas units. Good time for all of us, and my sons
are learning a new programming language.
Steve
| | | | | | |