thank you!
it's rather late here tonight in Europe so I'll try it probably tomorrow.
If you don't mind, I'll link your post / your code to the German Mindstorms forum so that more people may test it and have a benefit.
the code e.g. for a simple RCX motor control on a remote NXT currently goes like this to drive a RCXmotor1 to the down, or the medium, or the upper positions, running in seperate tasks to be stoppable at any time by
remote-void MotorOff(const byte &port),
using touch sensors S1 (dn), S2 (md), S3 (up) which indicate the correct position
(2 additional RCX motors (not in that code) are running the pneumatic pressure pump and the electromagnetic pneumatic valves).
The remote1-RCX motor is attached to a remote-MS-Mmux.
Code: Select all
//------------------------------------------------------------------------------
char CmdRdy;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
inline void MotorOff(const byte &port)
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
{
SetOutput(port, Power, 0,
OutputMode, OUT_MODE_COAST,
RegMode, OUT_REGMODE_IDLE,
RunState, OUT_RUNSTATE_IDLE,
UpdateFlags, UF_UPDATE_MODE + UF_UPDATE_SPEED);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
task Claw_up() {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CmdRdy=false;
OUT_MSMux(RCXMMux_Port, OUT_Claw, 1024);
Wait(1);
while(!(SensorValue(S3))) { // dn pos = S3
OUT_MSMux(RCXMMux_Port, OUT_Claw, -100);
Wait(1);
if (SensorValue(S3)) {
OUT_MSMux(RCXMMux_Port, OUT_Claw, 1024);
Wait(50);
}
}
OUT_MSMux(RCXMMux_Port, OUT_Claw, 0);
CmdRdy=true;
Wait(1);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
task Claw_md() {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
char speed ;
speed=100;
CmdRdy=false;
OUT_MSMux(RCXMMux_Port, OUT_Claw, 1024);
Wait(1);
while(!(SensorValue(S2))) {
if(SensorValue(S1)) speed=-100;
OUT_MSMux(RCXMMux_Port, OUT_Claw, speed);
Wait(1);
if (SensorValue(S2)) { // dn pos = S1
OUT_MSMux(RCXMMux_Port, OUT_Claw, 1024);
speed=0;
Wait(50);
}
}
OUT_MSMux(RCXMMux_Port, OUT_Claw, 0);
CmdRdy=true;
Wait(1);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
task Claw_dn() {
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
CmdRdy=false;
OUT_MSMux(RCXMMux_Port, OUT_Claw, 1024);
Wait(1);
while(!(SensorValue(S1))) {
OUT_MSMux(RCXMMux_Port, OUT_Claw, 100);
Wait(1);
if (SensorValue(S1)) { // dn pos = S1
MotorOff(OUT_Claw);
Wait(50);
}
}
OUT_MSMux(RCXMMux_Port, OUT_Claw, 0);
CmdRdy=true;
Wait(1);
}
I will have to try to run the 3 RCX1 motor tasks and the motor stop procedure at a remote-MS-mMux remote-controlled by rs485.
The master has to know at any time if remote-RCX1 is busy or idle.
Because all over 3 RCX motors are currently running via a MS RCX MMux at remote-S4, I will have to attach the sensors S1/2/3 to a remote HT touch mux at remote1-S1, remote1-S2 then will be needed for a pneumatic pressure sensor (currently at master-S4), the RCX mMux is switched to remote1-S3, and both master-S4 and remote1-S4 will be free for rs485 cable connection.
Then I will have to run the remote1-RCX2 and remote1-RCX3 motor tasks also attached to the remote1-MS-mMux via rs485.
The next step will be to pass an array char[129] plus about 8 extra char values from the master to 1 - 2 (-10 -20 -30) different slaves, start remote calculation tasks based on these arrays and extra values on all of them (while running the same calculations locally), and all return the calculation status (calc_busy or calc_finished) and, in case, remote results (int) to the master when finished. The master has to recognize when any has finished or may interrupt any remote calculations on demand.
I will report and start a new thread in case it's useful.
Looking forward to a more relaxed and more professional way of cooperation.