TasV Posted July 24, 2013 Posted July 24, 2013 (edited) I've posted this over on Mindboards but it seems a bit slow over there atm... I hope it's in the right place here. I'm trying to do a basic linefollow program which I can do without using variables easily enough but I thought I'd try and be a little more creative and put a calibration routine in, based loosely on the nxtprograms.com smoothfollow program calibration routine. As such I have four variables; White, Black, Grey, and Light. Light is a dynamic variable that is frequently rewritten from the light intensity value (0-100) from a single light sensor. White and Black are measured by scanning to the left (and back again) whilst values are continually fed back so that the max. is set as White and the min. is set as Black. Grey is just (Black + White)/2. This, and the turn on green routine I've made, work but the line follow part based on the light sensors data and the variables don't work. What I want to do is use these variables to control the duration of a motor block. I want it to move either left or right until it is either greater or less than Grey but nothing I've tried works. So far I've been doing things like this: and These do not work and I can't see why... how can I make this work? Can someone tell me what's wrong with my thinking here? TIA, Simon Edited July 24, 2013 by TasV Quote
bats Posted July 24, 2013 Posted July 24, 2013 What exactly is happening? You will need to stop the motors at some point. You turn the motors on for unlimited and there is no block stopping the motors. I don't know if you stop them in some other place in the program, but that could be the problem if your robot is just spinning. Quote
TasV Posted July 24, 2013 Author Posted July 24, 2013 Spinning around is one of the things it does... it doesn't seem to be sensing the black line. I've backed the power right down while we are getting it right so it doesn't spin out of control... it just doesn't seem to be sensing the line and if it does it does not correct itself... more like a little pause in its motion and on it goes. I've put a motion block after the switch now and set it to all motors stopped to see if that helps. Quote
Someonenamedjon Posted July 25, 2013 Posted July 25, 2013 You have to use the "3" to 3 block. (speech number to computer number) Quote
bats Posted July 25, 2013 Posted July 25, 2013 A problem I have had with line following programs is the lighting. Often my lighting wasn't strong enough for my sensor to work properly. Try shining a flashlight on the path of your robot. That really helped me. Quote
TasV Posted July 25, 2013 Author Posted July 25, 2013 (edited) I have LED lights connected to a motor port that is run by a parallel program all the time. This largely overcomes the lighting issues. This is a programming issue, somewhere, and I can't work out where I've made a mistake. Why would I need to convert the sensor values to text? Adding stops to the motors helped it track but it crawled at a snails pace. Edited July 25, 2013 by TasV Quote
Someonenamedjon Posted July 25, 2013 Posted July 25, 2013 I have LED lights connected to a motor port that is run by a parallel program all the time. This largely overcomes the lighting issues. This is a programming issue, somewhere, and I can't work out where I've made a mistake. Why would I need to convert the sensor values to text? Adding stops to the motors helped it track but it crawled at a snails pace. The nxt recognizes it as text when it comes out. Quote
TasV Posted July 25, 2013 Author Posted July 25, 2013 Would that mean the compare block wouldn't work then? Quote
TasV Posted July 26, 2013 Author Posted July 26, 2013 That's what I meant... I've actually got this working today. No need to convert anything to text... Quote
Someonenamedjon Posted July 26, 2013 Posted July 26, 2013 That's what I meant... I've actually got this working today. No need to convert anything to text... oh, ok then. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.