Jump to content

Recommended Posts

Posted

I'm trying to create what I thought would be a simple program for communication between 2 NXTs.  When a touch sensor is pressed on the master NXT, send a BT message to a slave NXT to run a motor for half a second in one direction, and the opposite direction when the sensor is released.  This also needs to be done for another sensor and motor between the two NXTs. Once that is working I want 2 more touch sensors on the master to send BT commands to tell the second NXT to send Power Functions commands from a HiTechnic sensor.  I'll post what I have so far in NXT-G.  If need be I can use NXC to program them, I'm just unsure how the HiTechnic PF commands work in NXC and I'm not the best programmer (I'm more of a hardware guy not so much software).  I've used NXT-G to send train PF commands to a PF servo at power level 7 in each direction or return to center.

The problem I have is most of the BlueTooth commands aren't being received.  It just randomly works when it wants to, which isn't often.  In my limited understanding I'd say it's on the receiving end since I'm using 4 loops to read the commands (It would eventually be 8).

All this is for an automated monorail layout.  It will be controlled by a Lego Dacta Control Lab Serial Interface controlling motors which press and release the NXT touch sensors on the Master NXT.  When one of the touch sensor states change it would send commands via BlueTooth to the slave NXT to control the motors for the switchtracks.  The direction switches for the monorail will use a PF servo to change directions or stop the monorail motor.  Why go through all this trouble?  Because I like a good challenge and am obsessed with the Dacta Control Lab and its accompanying software.  I'm am fully aware there are more simple ways to do this.  BlueTooth communication is the only thing holding me back at this point.  Without it I will have to use the main NXT to control the switchtracks which means they have to be very close to the main control center.  All of this would be duplicated between 2 other NXTs.

I hope I have explained everything in a somewhat intelligible way, feel free to ask any questions you have or tell me I'm crazy.  The main question I have here is do I need to switch over to NXC or is this possible using NXT-G?

 

Master Program

Local2

Slave Program

remote2

 

Posted

I believe the "wait for message" loop in Philo's NXT-G receive program is essential.

As far as I remember, a buffer "read" (e.g. into a variable = store the message buffer content) clears the message buffer. Then evaluate/manipulate the variable (again as in Philo's program, e.g. scale the value) and then do the action using/based on the variable but not the message buffer content.

Best,
Thorsten

Posted

I didn't see the replies for until late last night, I forgot to follow the topic.  I see now my first instinct should have been "what does Philo have to say on the subject" :pir_laugh2:  Thanks for the replies, it led me down the right path.

I'm still trying to figure out what the exclamation mark means for the Bluetooth sensor block (Philo's has it, during troubleshooting I tried without it).  What did the trick was using a switch block in tabbed mode and each action being assigned to a number.  Everything is working great!  Now I can do the same thing for the other 2 NXTs :classic:.

 

remote2 working

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...