Magnetometers can be used to measure the magnetic fields around a device. You can access this data from qdex using an magnetometer tag. Magnetic fields are output in units of microteslas (one gauss is 100 microteslas).
The magnetometer data is stored inside of an inherent vector called value inside of the onValueChanged event. As with simulations, qdex will not start to read magnetometer data until the magnetometer is started using the Start() method, or signaled from a simulation.
In the following example, the values from the magnetometer are plotted and output to a label.
You can copy this example into your document as-is. It must be contained in a section named section1.
<p name="myLabel" /> <magnetometer name="magnet"> <onValueChanged> myLabel.Text = string.format("%d %d %d", value, value, value) </onValueChanged> </magnetometer> <simulation name="sim"> <onActivePageChanged> if active then sim:Start() else sim:Stop() end </onActivePageChanged> <solver> <series> <signal ref="section1.magnet" width="3" /> <probe ref="section1.magPlot" /> </series> </solver> </simulation> <timePlot name="magPlot" series="3" />