But as soon as I add the line#include "JoystickDriver.c"The program quits straight away.

That's interesting. Do you get any error code on the NXT screen as it crashes? Do the motors move at all or does it crash even before that?

Try adding that joystick driver to one of Xanders dIMU sample programs. If this works, then the issue in the Segway program may be the parallel tasks. A known issue is that if multiple tasks try to refer to common.h from Xanders driver suite at the same time, a crash can result.

I don't know the details of "JoystickDriver.c", though. How can it affect the code when you include it even when you make no other references to the code?

Tue Mar 13, 2012 4:41 am

vlad2048

Rookie

Joined: Mon Mar 12, 2012 7:13 pmPosts: 3

Re: Dexter Gyro + JoystickDriver.c problem

Ok thanks I've updated to the new segway-driver-lv.h just to be sure but it doesn't make a difference for my problem (the differences are small).

Quote:

That's interesting. Do you get any error code on the NXT screen as it crashes? Do the motors move at all or does it crash even before that?

There is no error on the NXT screen, just "Segway-NoAction Running" and very shortly after "Segway-NoAction Done". The motors don't move at all.

Quote:

Try adding that joystick driver to one of Xanders dIMU sample programs.

I suppose you're referring to the official Dexter Gyro tests. This works ! I've added #include "JoystickDriver.c" to DIMU-test1.c and was able to read the Gyro sensor off the NXT screen.

So indeed the problem seems to be the #include "segway-driver-lv.h" with StartTask(balancing); which starts up another task.

Quote:

A known issue is that if multiple tasks try to refer to common.h from Xanders driver suite at the same time, a crash can result.

JoystickDriver.c doesn't include any file

Quote:

I don't know the details of "JoystickDriver.c", though. How can it affect the code when you include it even when you make no other references to the code?

"JoystickDriver.c" starts up its own task automatically by doing that:

Code:

#pragma autoStartTasks // Automatically start this task when the main user program starts.

So yeah the problem comes from 2 tasks starting at the same time. Maybe I could unify these 2 tasks into 1 ? I would need to understand how both work a bit better though, it's not obvious.

And I removed the loop in pollJoystick() that was going through all the messages and it seems to work now. Maybe that was the culprit in the first place.Balancing and joystick reading are working at the same time. The controls are not very effective though (modifying the speed variable doesn't have a very clear effect), it might be due to 3 things:- me updating segway-driver-lv.h, it contains new parameters now- the USB cable tugging at the bot. I can't get the Bluetooth to work again after reinstalling my PC (pairing works fine, but RobotC can't see the brick for some reason)- the batteries level going down

I suppose I need to investigate a bit more and fix my Bluetooth !

Tue Mar 13, 2012 5:13 pm

laurens200

Rookie

Joined: Wed Apr 04, 2007 1:13 pmPosts: 4

Re: Dexter Gyro + JoystickDriver.c problem

Quote:

I suppose you're referring to the official Dexter Gyro tests. This works ! I've added #include "JoystickDriver.c" to DIMU-test1.c and was able to read the Gyro sensor off the NXT screen.(...)

So yeah the problem comes from 2 tasks starting at the same time. Maybe I could unify these 2 tasks into 1 ? I would need to understand how both work a bit better though, it's not obvious.

Thanks for narrowing down the problem there. An easy way to combine tasks is to read the Joystick within the main control loop of the Segway. If you open up "segway-driver-lv.h", you'll find some sensor and variable declaration code and then a loop for the balance control. Insert the code to poll the joystick just before this snippet:

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