1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

Line Following with HiTechnic Sensor Multiplexer

Discussion specific to the intelligent brick, sensors, motors, and more.

Line Following with HiTechnic Sensor Multiplexer

Postby creator1 » 22 Feb 2012, 07:29

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
creator1
 
Posts: 10
Joined: 28 Mar 2011, 16:25

Re: Line Following with HiTechnic Sensor Multiplexer

Postby doc-helmut » 22 Feb 2012, 09:53

my guess: the more sensors you'll attach at 1 port the slower it will become
regards,
HaWe
±≠≈αγδεωΔΦΣ∫√∅∞
NXC CHESS for NXT: http://www.mindstormsforum.de/viewtopic.php?f=70&t=6790
indispensable for NXC + EV3-C: easy + trouble-free network & sensor+motor remote control for rs485, BT, USB!
User avatar
doc-helmut
 
Posts: 2424
Joined: 29 Sep 2010, 14:25

Re: Line Following with HiTechnic Sensor Multiplexer

Postby mightor » 22 Feb 2012, 10:12

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
| 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)
User avatar
mightor
Site Admin
 
Posts: 1060
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands

Re: Line Following with HiTechnic Sensor Multiplexer

Postby hassenplug » 22 Feb 2012, 14:00

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.
---> Link to lots of MINDSTORMS stuff under my picture --->
User avatar
hassenplug
 
Posts: 346
Joined: 27 Sep 2010, 03:05

Re: Line Following with HiTechnic Sensor Multiplexer

Postby creator1 » 22 Feb 2012, 14:45

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.


This is how I arrange the 4 sensors.

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 ?
creator1
 
Posts: 10
Joined: 28 Mar 2011, 16:25

Re: Line Following with HiTechnic Sensor Multiplexer

Postby hassenplug » 22 Feb 2012, 15:26

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
---> Link to lots of MINDSTORMS stuff under my picture --->
User avatar
hassenplug
 
Posts: 346
Joined: 27 Sep 2010, 03:05

Re: Line Following with HiTechnic Sensor Multiplexer

Postby creator1 » 22 Feb 2012, 16:57

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
creator1
 
Posts: 10
Joined: 28 Mar 2011, 16:25

Re: Line Following with HiTechnic Sensor Multiplexer

Postby hassenplug » 22 Feb 2012, 17:11

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
---> Link to lots of MINDSTORMS stuff under my picture --->
User avatar
hassenplug
 
Posts: 346
Joined: 27 Sep 2010, 03:05

Re: Line Following with HiTechnic Sensor Multiplexer

Postby creator1 » 23 Feb 2012, 12:29

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
creator1
 
Posts: 10
Joined: 28 Mar 2011, 16:25

Re: Line Following with HiTechnic Sensor Multiplexer

Postby gloomyandy » 23 Feb 2012, 12:53

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
User avatar
gloomyandy
 
Posts: 320
Joined: 29 Sep 2010, 05:03

Next

Return to Mindstorms Hardware

Who is online

Users browsing this forum: No registered users and 2 guests