Line Following with HiTechnic Sensor Multiplexer
Line Following with HiTechnic Sensor Multiplexer
Programming environment: NXTG
Test 1:
2 color sensors on port 1 and 4, 2 light sensors on port 2 and 3.
Following black line with right angle smoothly with no problem.
Test 2:
2 color sensors on port 1 and 4, 2 light sensors on HiTechnic Sensor Multiplexer (nxt port 2, multiplexer port 1 and 2)
With the same programming logic, the response of NXT become slow (not smooth on straight line and always miss the right angle).
The reason for using the multiplexer is to free up more sensor ports ( no other sensor is added to the NXT in Test 2)
Is there any way to improve the performance with the multiplexer.
Thank you
Test 1:
2 color sensors on port 1 and 4, 2 light sensors on port 2 and 3.
Following black line with right angle smoothly with no problem.
Test 2:
2 color sensors on port 1 and 4, 2 light sensors on HiTechnic Sensor Multiplexer (nxt port 2, multiplexer port 1 and 2)
With the same programming logic, the response of NXT become slow (not smooth on straight line and always miss the right angle).
The reason for using the multiplexer is to free up more sensor ports ( no other sensor is added to the NXT in Test 2)
Is there any way to improve the performance with the multiplexer.
Thank you
Re: Line Following with HiTechnic Sensor Multiplexer
my guess: the more sensors you'll attach at 1 port the slower it will become
Re: Line Following with HiTechnic Sensor Multiplexer
The SMUX does not read more slowly when there are more sensors attached to it. It just takes longer to do multiple calls to the SMUX to get the info for each sensor.
However, if you know what you're doing and are willing to move away from NXT-G, you can read both channel 1 and 2's analogue values in one go. This will greatly speed things up. The analogue values for each channel are stored as 10 bit values from register 0x36 to 0x3D. The default type for a channel type is analogue, so it should work out of the box. Otherwise take a look at the tutorial I made a while back: http://www.breigh.com/xander/HTSMUX-Tutorial-LATEST.pdf , it has both NXC and ROBOTC example code in it.
- Xander
However, if you know what you're doing and are willing to move away from NXT-G, you can read both channel 1 and 2's analogue values in one go. This will greatly speed things up. The analogue values for each channel are stored as 10 bit values from register 0x36 to 0x3D. The default type for a channel type is analogue, so it should work out of the box. Otherwise take a look at the tutorial I made a while back: http://www.breigh.com/xander/HTSMUX-Tutorial-LATEST.pdf , it has both NXC and ROBOTC example code in it.
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: Line Following with HiTechnic Sensor Multiplexer
Are you actually using the two color sensors for line following?
I would assume the two light sensors do most of the work. I would connect them directly to the NXT, and put the color sensors on the mux.
I would assume the two light sensors do most of the work. I would connect them directly to the NXT, and put the color sensors on the mux.
---> Link to lots of MINDSTORMS stuff under my picture --->
Re: Line Following with HiTechnic Sensor Multiplexer
This is how I arrange the 4 sensors.hassenplug wrote:Are you actually using the two color sensors for line following?
I would assume the two light sensors do most of the work. I would connect them directly to the NXT, and put the color sensors on the mux.
Color light light color
The two light sensors in the middle following the left and right edge of the black line. The two color sensors are used to handle sharp right angle and prevent the NXT to lose the line.
I have tried with two light sensors. I divide the cases into four:
white white= both wheel forward
black white = left wheel backward, right wheel forward
white black = right wheel backward, left wheel forward
black black = ( don't know what to do)
Would you please tell me a smarter way ?
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: Line Following with HiTechnic Sensor Multiplexer
Actually, your approach sounds like a good one.
I suggest you try this:
Test 3
Light sensors on port 2 & 3. Color sensors connected to the HiTechnic sensor multiplexer (NXT port 1, multiplexer port 1 & 2)
Same programming logic.
See how that works.
Next, you can try doing more with the logic to smooth out the turns. For example, you don't list how you're using the color sensors. With the logic you listed, they may not be needed. But they would be helpful if you want to go faster.
A couple other things you could try:
Instead of: black white = left wheel backward, right wheel forward
you could try: black white = left wheel stop, right wheel forward
OR: white black white white = left wheel stop, right wheel forward
and black black white white = left wheel backward, right wheel forward
OR: white white = forward,forward
and: gray white = slow, forward
and: black white = stop, forward
As you make the robot go faster, you may discover that it's important to know how long the sensor has been on/off the line. That will point you towards something called PID.
Steve
I suggest you try this:
Test 3
Light sensors on port 2 & 3. Color sensors connected to the HiTechnic sensor multiplexer (NXT port 1, multiplexer port 1 & 2)
Same programming logic.
See how that works.
Next, you can try doing more with the logic to smooth out the turns. For example, you don't list how you're using the color sensors. With the logic you listed, they may not be needed. But they would be helpful if you want to go faster.
A couple other things you could try:
Instead of: black white = left wheel backward, right wheel forward
you could try: black white = left wheel stop, right wheel forward
OR: white black white white = left wheel stop, right wheel forward
and black black white white = left wheel backward, right wheel forward
OR: white white = forward,forward
and: gray white = slow, forward
and: black white = stop, forward
As you make the robot go faster, you may discover that it's important to know how long the sensor has been on/off the line. That will point you towards something called PID.
Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Re: Line Following with HiTechnic Sensor Multiplexer
This is the hardware setup:
C1= color sensor on port 1
L2 = light sensor on port 2
L3 = light sensor on port 3
C4 = Color sensor on port 4
C = Left motor
B = Right motor
C1 L2 L3 L4
C B
This is the programming logic:
B is directly proportional to L3 while inversely proportional to L2
C is directly proportional to L2 while inversely proportional to L3
Using above logic with calculations, NXT can follow straight line and curve smoothly with no oscillation.
However, when the curve is too tight or it is a right angle. The NXT (L2 and L3) will lost the line.
Before NXT totally lost the line, C1 and C4 can help.
I am not sure if it is a PID control, even it is, if only use the proportional part.
Please advice to make it work better, especially if it is possible to use L2 and L3 only while still handling the tight turns and right angles?
Thank you
C1= color sensor on port 1
L2 = light sensor on port 2
L3 = light sensor on port 3
C4 = Color sensor on port 4
C = Left motor
B = Right motor
C1 L2 L3 L4
C B
This is the programming logic:
B is directly proportional to L3 while inversely proportional to L2
C is directly proportional to L2 while inversely proportional to L3
Using above logic with calculations, NXT can follow straight line and curve smoothly with no oscillation.
However, when the curve is too tight or it is a right angle. The NXT (L2 and L3) will lost the line.
Before NXT totally lost the line, C1 and C4 can help.
I am not sure if it is a PID control, even it is, if only use the proportional part.
Please advice to make it work better, especially if it is possible to use L2 and L3 only while still handling the tight turns and right angles?
Thank you
-
- Posts: 346
- Joined: 27 Sep 2010, 03:05
- Contact:
Re: Line Following with HiTechnic Sensor Multiplexer
Sorry, there was a lot of stuff in my previous message. Back to your original question, I suggest you try this:
Test 3
Light sensors on port 2 & 3. Color sensors connected to the HiTechnic sensor multiplexer (NXT port 1, multiplexer port 1 & 2)
Same programming logic.
Steve
Test 3
Light sensors on port 2 & 3. Color sensors connected to the HiTechnic sensor multiplexer (NXT port 1, multiplexer port 1 & 2)
Same programming logic.
Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Re: Line Following with HiTechnic Sensor Multiplexer
Test 3 setup:
Light sensors on port 2 & 3. Another two light sensors connected to the HiTechnic sensor multiplexer (NXT port 1, multiplexer port 1 & 2)
<because the mux does not support Lego color sensor in NXTG>
Same programming logic.
Test 3 result:
NXT go smoother on straight line and curve. However it will sometimes "forget" about the outermost light sensors which is used to detect tight curve and right angle.
I would like to make it simpler, if two light sensors can do the job. My target is to follow the line closely while accuracy is more important than speed.
Thank you
Light sensors on port 2 & 3. Another two light sensors connected to the HiTechnic sensor multiplexer (NXT port 1, multiplexer port 1 & 2)
<because the mux does not support Lego color sensor in NXTG>
Same programming logic.
Test 3 result:
NXT go smoother on straight line and curve. However it will sometimes "forget" about the outermost light sensors which is used to detect tight curve and right angle.
I would like to make it simpler, if two light sensors can do the job. My target is to follow the line closely while accuracy is more important than speed.
Thank you
-
- Posts: 323
- Joined: 29 Sep 2010, 05:03
Re: Line Following with HiTechnic Sensor Multiplexer
Does the mux support Lego color sensors using any language? The HiTechnics page does not list them as a supported device. They are a very odd beast to interface to...
Andy
Andy
Who is online
Users browsing this forum: Semrush [Bot] and 0 guests