Senior Design Capstone Project Help!!!

I'm an Electro-Mechanical Engineering student at Penn State in my senior year and currently my team and I are working hard at finishing up our project: an inductive wire guided weed wacker (aka Trimbot).

Trimbot is designed to follow a frequency generated wire using two inductors close to the ground to pick up the signal and steer itself along the edge of the yard or building using an Arduino microcontroller.

I found a great reference website where a person designed the same principle project, an inductive wire guided system, to steer a lego mindstorm bot. On this individual's website the code that was used was listed, however no controller was mentioned so I have to use one of my choosing. The link of the code is here:

Here is the link to the whole web page that I visited:

My question is, is if this code is compatible for an Arduino uno microcontroller, and if so, is the syntax essentially the same thing? My coding skills are very dusty and I'm trying to learn as much as I can as fast as I can.

Any help would be tremendously appreciated. My senior design project, Trimbot, needs to be finished by mid April, however I would like to have it done ASAP.

This is meant for NQC programming language (NQC is a programming language/APIs which was designed for the Lego robots)

Right. NQC, "not quite C" is very similar to what it would look like adjusted for the Arduino.

The referenced program is trivial, or should be I would think for a senior in electro-mechanical engineering or someone on the team.

Take a look at a few simple Arduino programs, the big difference is that they do not have a main function but work with a setup()/loop() concept.

I would hope you could mostly fake it by pattern recognition if not real deep understanding - a useful skill.

You'll probably have more fun (cough) getting the sensors to work reliably than trouble reverse engineering and recoding the algorithm for reading them and switching the motors on and off. Which is all the code does: hysteresis, error detection and kinda gross changes to drive.

Welcome to the Forum.

The NQC program;

#define Wireguide SENSOR_1
#define Left OUT_A
#define Right OUT_C
#define Threshold1 10
#define Threshold2 25
#define HysterVal 8

task main ()
  int Offset;
  int Hyster=0;
  int Diff;

  // The wire guidance sensor is used
  // the same way as a Light sensor
  SetSensor (Wireguide, SENSOR_LIGHT);

  // Reads the "no-signal" response. The sensor must
  // be centered on the wire, or generator be off
  Offset = Wireguide;

  // Starts driving

  OnFwd (Left+Right);
  while (true)
    // Reads error signal
    Diff = Wireguide - Offset - Hyster;
    if (Diff >= -Threshold1 && Diff <= Threshold1)
    // We are centered - drive straight
      OnFwd (Left+Right);
      Hyster = 0;
      if (Diff > 0)
        if(Diff > Threshold2)
        // Very off center: turn in place
          OnRev (Left);
          OnFwd (Right);
        // Slightly off center: shallow turn
          Off (Left);
          OnFwd (Right);
        // sets hysteresis to avoid over-turning
        Hyster = HysterVal;
        if(Diff < -Threshold2)
          OnRev (Right);
          OnFwd (Left);
          Off (Right);
          OnFwd (Left);
        Hyster = -HysterVal;

If you are a final year student and have done programming then that simple, commented, code should be no great problem to understand and write your own.

Just a look at an NQC manual/tutorial for the meanings and structure of the commands.

Then layout in pseudo code what you need then code in Arduino C++.

What have you got in hardware to detect the trace wires?
What have you got to move the robot?
What Arduino controller are you going to use?
How are you going to power it?

Tom… :slight_smile:

My apologies about the delayed response.

alto777: I agree, I should be able to duplicate this fairly easy, the code doesn't have any new functions in it which is a plus.

TomGeorge: Thank you! My coding class was about 3 semesters ago, so some of the material is a bit hazy. Just need a simple refresher is all. I found a link that should be very helpful in determining the meaning of the commands, which I will then switch over to my pseudo code then finally into Arduino C++.

We got our drive motors from Anaheim Automation. Two Brushless DC motors, one on each side to drive our robot. (BLWS23)

Our school has Arduino Uno r2 microcontrollers. Essentially a starter kit used earlier in our program.

As for our power, the robot will be using 24V DC, however we have a small circuit that will take that 24VDC down to 12VDC, then that 12VDC to 5VDC using MOSFETs. Then the small output that the Arduino can put out is used in another MOSFET to send the full power to the motor which will be used as the trimmer motor.

Hi, Good to hear you have some hardware to do the job.

What are you going to use to detect the signal from the wire?

Are you going to need forward and reverse control of the motors? If you need speed control, check that the BLDC motors are happy with PWM from a MOSFET.

Can you post a link/data of the motors please.

Tom... :)

The OP links to a page describing the sensors and I think the signal for the wire.

Good luck with your project. NCQ and most light Arduino code is so similar, the hard part is the logic, which looks easy here, and of course all the problems of programming in general. Not specifics of languages all descendants of the old good ones.

Please come back and tell us how it works. I've expressed skepticism, but I'm an old pessimist. Not the software, the sensor/wire combo!

Hmm, maybe get half of it working well with a bump skirt. Divide and conquer anyway always a good strategy.


You need to research your motors.
I googled Anaheim Automation Brushless DC motors BLWS23

And came up with a 3phase brushess motor with hall effect switching that will need a BLDC motor driver module.
A single MOSFET will not control this motor, it is a 3phase delta motor.

Tom… :slight_smile:

Tom: Here is the hardware we are using for our drive motors;




I may have confused you on my previous post. We have 3 motors total in our robot: 1 trimmer motor (used to spin the cutting blades) and 2 drive motors (links above). The MOSFET circuit that we made is used for the trimmer motor, which we just tested today and it works just fine. The drivers for the motors have a Brake, Enable, and Direction port which we will use for our Arduino. Essentially all we need it to do is to send a signal, either high or low, to the driver.

Also, at this moment we are only keeping one motor on if we need to turn. (i.e. right hand turn = left motor ON, right motor OFF).

As for detecting the signal from the wire, I found a circuit in that original link that used two inductors, one on each side, to get a reading from the wire using the Right Hand Rule. It should either give back a voltage reading or an analog number which we will then set thresholds in our code to determine the path of the robot.

Thank you for the extra time you put in to checking out our motors Tom. I spoke with a Sales Engineer from Anaheim Automation around November 2017 and he was the one to help pick the hardware out for us.

alto777: Thank you. The code on paper does look simple, and I agree, the logic is the hard part. I will be coming back to update both of you on this project as we go. Will post some pictures too once we have what we want. The sensor/sire combo is our biggest pain at the moment. We've done all the fabrication work for our project and without a doubt the sensor/wire combo is going to need our full attention.