Sensor Orientation Options In order to facilitate the investigation of different sensor orientation options, included here is the code for a MATLAB script that will show the response of a sensor in different orientations to a changing magnetic field around a straight wire. The graphs plotted show the voltage induced across the inductor plotted against the perpendicular distance from the wire, which is assumed to be straight and infinitely long on the calculations. The variables: Sensor orientation is determined by two variables (theta and phi) that give its orientation in spherical coordinates. The angle the car makes with the track is specified by the variable alpha. The height of the sensors from the floor, and the magnitude of the current in the wire, are determined by H and I respectively. Theta and phi: These two variables specify the sensor orientation in spherical coordinates. Spherical coordinates use the three variables (r, theta, phi). Here two of the coordinates are angles, while ‘r’ is the actual distance from the origin to the point. Since only the orientation of the sensor interests us, ‘r’ is set equal to one. The magnetic field inside the sensor is assumed to be homogenous, so the sensor is assumed to be a point sensor. The angles theta and phi are shown below. Using this diagram, the wire is assumed to lie along the x-axis, with the forward direction being in the negative x direction (x-axis being the x1-axis, y-axis being the x2-axis, etc). The sensor orientation is such that an axis through the center of the inductor is parallel to the vector specified by (r, theta, phi), ie. The inductor coils would be wrapped around the vector er as in the diagram above. The relationship between spherical and Cartesian coordinates is as follows: x = rsin(theta)cos(phi) y = rsin(theta)sin(phi) z = rcos(theta) Alpha, H and I: Alpha is a variable describing the angle the car makes with the track, measured clockwise from the x-axis. H describes the height of the sensor above the track, and the value of I is irrelevant for the program as it stands, since the program shows only how the sensor output will vary on a relative scale. Constants of proportionality could be introduced to find the exact theoretical voltage that should be induced across the snsor for different properties if the sensor, but there are so many other factors interfering with such small measurements that such an exercise would probably be useless. The script first calculates the sensor orientation in Cartesian coordinates, and converts this to a unit vector. The voltage induced across the sensor is then proportional to the dot product of the magnetic field vector and the sensor orientation. The script then calculates for each value of d (distance from the track): (1) ‘r’, which is the distance of the sensor from the wire. This is used to calculate B, which is proportional to the magnitude of the magnetic field at that point. (2) Beta, which is the angle shown in the diagram above (the track is the negative xaxis, going into the page). As can be seen, the direction of the magnetic field, BD, is such that theta = pi/2 + beta, and phi = 0, in spherical coordinates. Finally, BD is found in Cartesian coordinates, and found as a unit vector. The dot product of this value with the sensor orientation unit vector, multiplied by the strength of the magnetic field, will give a value that is proportional to the voltage that will be induced across the sensor for each point in the specified range. Provided below are a few plots for some values of theta and phi, and the code for the script at the end: Theta = 0, phi = anything (vertically oriented sensor) Theta = pi/2, phi = 0 (sensor parallel to track) This would give results of zero, but the Matlab plot will show very small values due to the program’s limitations in it’s number of significant figures. Theta = pi/2, phi = pi/2 (horizontally oriented sensors perpendicular to track) Theta = pi/4, phi = pi/2 (just for fun) h = .1 % sensor is .1 meter off the ground I = 1 % current = 1 amp theta = pi/2 % sensor orientation in spherical coordinates phi = 0 % sensor orientation in spherical coordinates alpha = 0 % Angle car makes with wire sensOrient = [1, theta, phi - alpha] %sensor orientation correcting for car angle SO = sensOrient SOxyz = [SO(1)*sin(SO(2))*cos(SO(3)), SO(1)*sin(SO(2))*sin(SO(3)), SO(1)*cos(SO(2))] %sensor orientation in cartesian coordinates unitSensOrient = SOxyz/(dot(SOxyz, SOxyz)) %SOxyz as a unit vector USO = unitSensOrient for j = 1:100; % repeat loop 100 times d(j) = j/100 - .5; % d ranges from -.5 meter to .5 meter % each value of d is stored in a vector d for plotting % the semicolon after the statement suppresses printing every % command when you run this file in matlab r = sqrt(d(j)^2 + h^2); B(j) = (I/r); beta = atan(d(j)/h); %angle of sensor from track, clockwise from vertical BD = [1, (pi/2 + beta), pi/2]; %Direction of B BDxyz = [BD(1)*sin(BD(2))*cos(BD(3)), BD(1)*sin(BD(2))*sin(BD(3)), BD(1)*cos(BD(2))]; %Direction of B in cartesian coordinates unitBDxyz = BDxyz/(dot(BDxyz, BDxyz)); %BDxyz as a unit vector UBD = unitBDxyz; V(j) = dot(UBD, USO)*B(j); end plot(d,V)