Hi, Newbie to NXT |(5 months) and Robot C (10days). Despite being able to write half decent VBA code I am struggling. Found NXT-G too "foreign" despite doing all tutorials etc, some am trialling (and will buy) Robot C. Have worked thru tutorials and spent a lot of time correcting typo's

So 2 questions both based on Brian D's JenToo nesting program (in NXT-G)
I would like to code first part in Robot C, ie rotate through 360 degrees, so have used nSnychMotor and tried to use the encoder to rotate for given number of "ticks", I want to scan with US (sonar) and determine closest detected object, store as variable? and then move towards it.

Secondly I can't find an idiots guide to datalogging, as I'd also like to be able to record US value for every motor encoder increment. So in this case say ca 540 data points and send to PC.

What I have found that for me some coding in Robot C has allowed me to progress with NXT-G and vica versa.

I really like the debugging and variable watch etc rather than having to guess what has gone wrong.

Any help welcomed.

Mon Nov 12, 2007 11:00 am

Dick Swan

Creator

Joined: Fri Feb 09, 2007 9:21 amPosts: 615

For DataloggingDouble click on the "Datalog" heading on the ROBOTC left window pane -- the "pane" with all the built in variables displayed. If datalogging is not showing up as a heading, then set the "user level" to "expert" to get the more advanced items displayed.
Open the sample program "NXT Datalog text.c" and study it. It's heavily commented.
If you're still having problems, post again. For faster response, send me an email or PM.

If all you want is a log of 500 points or so, you could also consider simply using a single indexed linear array to hold the values. ANd then watch them using the "Global Variables" debugger window.

Tue Nov 13, 2007 12:14 am

Dick Swan

Creator

Joined: Fri Feb 09, 2007 9:21 amPosts: 615

Pseudo-code for above:for (angle = 0; angle < 360; angle += 30)
{
move 30 degrees;
wait about 100 msec for sonar to take a reading<BR> if no item found at this angle then continue to next item in loop
if no closest item has been set (i.e. targetAngle < 0) then store angle and distance
if this item is closer than previous closest item then store this angle and disance
}

if item was found in the above loop
{
turn to the angle of the item
move straight forward for a littel distance and stop
}
repeat above again

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum