Reading two magnetic sensors on one controller

8 years 4 months ago #29529870 by timj0909
I have an HBL2360 and two MGS1600s for an AGV I would like to operate bi-directionally. Thus, I have one sensor mounted on the front and one on the back of the vehicle so it can turn in both directions. How can I query both sensors in the MicroBasic language? It appears that using the built-in read Magnetic Sensor commands such as MGT and MGM don't let you select which magnetic sensor you wish to read if more than one is present. It would be nice to pass an argument to the query commands to select which sensor/input to read. Can you even configure more than one of the pulse inputs to be a MagSensor?

My current thinking is that I'll have to configure one as a MagSensor, and the other as a generic PWM input, and then manually do the processing to convert the duty cycle into mm for the second sensor.

Any help on how to easily get data from two magnetic sensors on one controller would be appreciated.

Please Log in or Create an account to join the conversation.

8 years 4 months ago #29529872 by TechSupport
We have a sample AGV script in the following link below. Sample Microbasic scripts.

dev.roboteq.com/dev1/index.php/support/downloads

The magsensor provides these pieces of information on the multi-pwm signal out of the magsensor to the controller.

1 Magsensor is sufficient. If 2 are required, you would need to use another pulse input from the magsensors pulse output. You would need to read from them one at a time using the scripting.

Please Log in or Create an account to join the conversation.

8 years 4 months ago #29529875 by timj0909
1 magnetic sensor is *not* sufficient if it is mounted on the front (or back) of the AGV. The AGV will not be able to properly navigate turns when operating in reverse. The sensor used to guide the cart needs to always be in front of the wheels with regards to the direction of motion. 2 directions = 2 sensors.

When you say use the pulse output, I'm assuming you mean the the multi-PWM out of pin 15 from the sensor.

My original question still remains: Can the HBL2360 be configured in Roborun+ to accept two magnetic sensor inputs (So you can get info like track and marker detect with the built in MicroBasic commands?). If so, how do you differentiate in the MGM, MGS, and MGT commands between which sensor you are reading?


If this is not possible, do I have to read the raw PWM individually for each sensor, and then convert that to track position manually? Or is there another way?

Please Log in or Create an account to join the conversation.

8 years 4 months ago #29529876 by TechSupport
You have to write a script that tells it which sensor to read from. If you use the script that was pre-written for use for you to modify, then this can be accomplished.

Only one sensor can be read at a time. Multi-pwm output is pin 15.

You have to wire up the pulse output pin 15 of each magsensor to the controllers pulse inputs. Only 1 can be used at a time.

Your script has to tell the controller which magsensor to gather the data from. If you look at the magsensor utiluty and issue those command in the presence of magnetic tape, or without the tape present, either a value 0> or < 0 will be issued, or it will be a logic 1 or logic 0.

You pwm out can be read from the controller via the pulse input it is wired to. serial command ?pi # where # refers to the pulse input. In scripting, it is something like this.

dim sensor1 as integer
top:
sensor1 = getvalue(_PI, 1) ' reads pulse input 1

Please Log in or Create an account to join the conversation.

8 years 2 months ago #29529976 by timj0909
I'm still having issues getting info from two sensors on one controller. Here's what I've tried:

Configuring one pulse input as MagSensor with only one magnetic sensor works independently on both sensors.
Configuring a second pulse input as a MagSensor also overwrites the first MagSensor (I knew this would happen).
Configuring a second pulse input as either Duty Cycle or Pulse Width produces erratic values. They jump from ~500 to ~1600, and then ~3300 (raw) without any pattern or predictability, without regards to Duty Cycle vs Pulse Width Config. This is repeatable with both sensors.

Configuring an Analog Input with the connection to the Analog Out of the sensor doesn't work either. I've confirmed the voltage with a voltmeter (ranging from 1 to 2 volts depending on tape position), but the controller doesn't see the appropriate values. It mostly stays at 0 and occasionally, very rapidly jumps to ~10 or ~60 mV. I have it configured Low = 0 mV, high = 3000 mV, Absolute, and Direct conversion. Also repeatable with both sensors.

Both sensors have their factory defaults--I haven't reprogrammed them or looked at them with the computer magnetic sensor utility.

Any comments on why I can't get the pulse input OR the analog inputs to work? The only thing that works is the MagSensor configuration. I've single and double checked my wirings to make sure the pins are connected to the appropriate ones on the sensor and the controller.

Please Log in or Create an account to join the conversation.

8 years 2 months ago #29529983 by TechSupport
You can't have both sensors active at the same time. So in your script, you need to make it configure each pulse input accordingly.

So let's just assume you are using pulse input 1 for the forward sensor travel, and pulse input 2 for the reverse sensor travel. When you are going forward, then the pulse input 2 is deactivated; conversion type - disabled, input use none. Then when you want to go reverse, it would be the pulse input 1 gets disabled via script.

Please Log in or Create an account to join the conversation.

Time to create page: 0.078 seconds