Subject:
|
Who to control MANAS with RCX2 and NQC
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Wed, 15 May 2002 11:06:46 GMT
|
Original-From:
|
Marco Correia <marco@NOSPAMsoporcel.pt>
|
Reply-To:
|
<{marco@soporcel.}Spamless{pt}>
|
Viewed:
|
628 times
|
| |
| |
> "Marco Correia" <marco@soporcel.pt> wrote in message
> > news:<002e01c1fa6c$dd4a98b0$610b010a@soporcel.pt>...
> > I'm using MANAS sets to expand the outputs. Not a perfect
> > solution, but it's better than nothing.
>
> From: Ron Witkamp [mailto:ron@witkamp.net] Sent: Tuesday, May 14, 2002 6:45 PM
>
> How do you do that, use manas set for output expansion?
>
> Ron
> Holland
Hi Ron :)
This is an example of how you can control 3 Bionicle Manas.
Since so many people contributed to this, I edited the last
version of the demo source, I could find at lugnet.robotics,
to include a "Thanks to" and some more comments.
The version I use (don't have it here) has some optimisations
related to the number of MANAS sets I wish to control, etc...
but that's an easy thing to do.
mc.
----------------8<---------------------------------------------------------
//
// NQC source for MANAS control with RCX (RCX2 firmware)
//
// #8539 Bionicle Manas set info/pics at:
// http://shop.lego.com/productinfo.asp?product_number=8539
//
// Thanks go to:
//
// John Barnes [barnes@sensors.com]
// for decoding the protocol
// Zhengrong Zang [mikezang@iname.com]
// for talking about SetSerialComm(SERIAL_COMM_4800)
// Pink Tail [pinkmice@borg.com]
// for the 1st working NQC example (2xMANAS)
// Dennis Williamson [dennis@NOJUNKnetstrata.com]
// for 2nd version (3xMANAS) redefining FLOAT/OFF states
#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; //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;
// DEMO starts here
//
while (true)
{
em1=EM_FLOAT;
em2=EM_FLOAT;
em3=EM_FLOAT;
em4=EM_FLOAT;
em5=EM_FLOAT;
em6=EM_FLOAT;
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);
}
}
//
// DEMO ends here
// 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 if you don't want to 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);
}
}
|
|
Message has 1 Reply:
2 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
Active threads in Robotics
|
|
|
|