Making my PF bot go backwards?

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
jaspy
Posts: 8
Joined: 24 Jan 2011, 19:37

Making my PF bot go backwards?

Post by jaspy »

Here is a video of a robot I made to test out my new IR Link:


http://www.youtube.com/watch?v=79fq7T6lpKk

When I was first ready to test it, the motor on the bot that was linked to the motor in port B of the NXT ran backwards.
I thought, 'no problem' and multiplied the data wire in the program by -1. This made my robot run fine apart from one thing, when I pushed the paddles backwards on the remote, the robot went forwards, and when I pushed them forwards it still went forwards? :?: I cannot think what to try next so any help would be greatly appreciated.
p.s. I am still programming in NXG as I am too scared to try anything else. :oops:
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Making my PF bot go backwards?

Post by hassenplug »

It sounds like the reading your getting from the remote control is always a positive number.

In your remote program, check the direction, and multiply by -1, when needed.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
jaspy
Posts: 8
Joined: 24 Jan 2011, 19:37

Re: Making my PF bot go backwards?

Post by jaspy »

:idea: :idea: :idea: :idea: :idea:
I have just realized the problem; after multiplying by -1 I then divide by 7 to give a proportionate value, but of course, dividing a negative number gives a positive result!
To fix it I need to divide then multiply.
Thanks for the reply anyway steve.
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Making my PF bot go backwards?

Post by hassenplug »

jaspy wrote:To fix it I need to divide then multiply.
Love to hear if that solves the problem. However, if I remember my elementary math (from long ago), it shouldn't make any difference.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: Making my PF bot go backwards?

Post by mattallen37 »

No it shouldn't make a difference, if he is using signed variables, but if using an unsigned byte as the variable, it just might.

With the wrapping characteristics of variables that overflow, I think that is the issue. It would have to be a unsigned variable in this case (to cause the issue you observed). Try displaying the values. Try something like a power level of 5, in reverse. Does it display -5 (like you want it to), or something more like 250?
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests