WEEK 11 - INPUT DEVICES

hero shot


testing the encoder of my final project with hall effect sensor i made this week

After a tedious machine week we are back to the usual flow. this week i planning to play with hall effect sensor which i can probably use in my final project.

assignment

individual assignment

  • measure something: add a sensor to a microcontroller board that you have designed and read it
    group assignment
  • probe an input device's analog levels and digital signals

about hall effect sensor

Hall-effect sensors are integrated circuits that transduce magnetic fields to electrical signals with accuracy, consistency, and reliability.

*from how to MECHATRONICS - how hall effect works*

MT811X

i am using the available 811 in our fablab inventory.The MT811X family of Hall effect sensors represents a cutting-edge solution for precise and reliable magnetic field detection in a variety of applications, with a particular focus on automotive systems. Built using advanced BCD (Bipolar, CMOS, DMOS) technology, these sensors offer exceptional performance and robustness.

Pasted image 20240416204815.jpg

from DATA SHEET of mt811x

BCD Technology: This technology likely refers to "Bipolar, CMOS, DMOS" technology, a common process for integrated circuits that combines Bipolar and CMOS transistors with DMOS (Double-diffused Metal-Oxide Semiconductor) transistors, offering benefits like high power efficiency and integration.

Pasted image 20240416204949.jpg

pin out and package of 811

Pasted image 20240416205133.jpg

811 is sensitive to the magnetic field component that is perpendicular to the top of the package

so the sensor doesn't measure magnetic flux but just says which is north and which south by turning high and low.

Pasted image 20240416205413.jpg

functional block diagram of 811

operating voltage - 2.8v - 24v
supply current - 3.5 - 6 mA

typical output of the ic is given below

Pasted image 20240416205714.jpg
Digital Output vs. Magnetic Flux Density

making the breakout board

Pasted image 20240602163555.jpg

the data sheet have a general application circuit DIAGRAM . i decided to mill the same board.

rl = 1KOhms to 10KOhms

Pasted image 20240415125017.jpg
schematics i done using kicad

note : in my schematic c1 =1nf and c2=100nf

then i routed the ic .

Screenshot 2024-04-15 at 1.46.08 PM.jpg

layout from kicad

then i milled the circuit and soldered it. you can refer WEEK 8 - ELECTRONICS DESIGN for more details about electronics designing

IMG_8302.jpG

811 breakout board i have done

testing the output

i am not getting proper reading from the board when i uploaded sample code to analog output.
Pasted image 20240506202720.jpg

error readings

. so decided to probe the board using an OSCILLOSCOPE.

we can use OSCILLOSCOPE an electronic test instrument which can be used to display varying voltages of one or more signals as a function of time.

i am using a bench power supply to power my sensor

Pasted image 20240417131632.jpg

power supply

Pasted image 20240417131134.jpg

probe pinout

Pasted image 20240417131930.jpg

the tektronix 5 series mixed signal oscilloscope i am using

Pasted image 20240417145327.jpg

from manual of this device

pin labels

  1. Acquisition and Cursors controls: Manage waveform acquisition, enable fast acquisition mode, set cursor parameters, and clear current acquisitions.
  2. Multipurpose knobs: Control cursor movement and configuration menu input values, with the ability to switch to Fine mode for precise adjustments.
  3. Trigger controls: Force trigger events, set trigger level and slope, and toggle between auto and normal trigger modes.
  4. Vertical controls: Adjust waveform position and scale, toggle channel display, and manage math, reference, and bus waveforms.
  5. Horizontal controls: Shift waveform position, adjust time scale, zoom in/out, and navigate through waveform records.
  6. Miscellaneous controls: Toggle touch screen, save instrument settings or screen captures, restore default settings, and perform autoset.
  7. Ground and Probe Compensation connectors: Provide grounding for anti-static protection and a source for probe compensation.
  8. USB Host ports: Connect USB flash drives or peripheral devices for data transfer or instrument control.
  9. FlexChannel probe connectors: Support various measurement probes and cables for signal acquisition.

Pasted image 20240417130855.jpg
connection setup

i took some neodymium magnets to test the sensor and anticipating to get low and high by moving magnets.


testing the magnets and getting digital output

OSCILLOSCOPE output

Pasted image 20240417140827.jpg

The current taken by the sensor during it's working at 5V constant ,It's about 0.00675 A only and the the output wave form we observe a straight line with out any operation.When we approach the magnet it goes high and when changed direction or removed magnet it goes low

programming with the sensor

i connected the sensor to the board i made in WEEK 8 - ELECTRONICS DESIGN and uploaded code to detect magnet.
Pasted image 20240417183336.jpg


me the testing sensor

Pasted image 20240624182146.jpg
circuit diagram

const int hallEffectPin = 31; // Pin connected to the output of the Hall effect sensor

  

void setup() {

pinMode(hallEffectPin, INPUT); // Set the pin as input

Serial.begin(9600); // Initialize serial communication

}

  

void loop() {

int sensorValue = digitalRead(hallEffectPin); // Read the digital value from the sensor

if(sensorValue == HIGH) {

Serial.println("No magnet detected"); // Print message if magnet is detected

} else {

Serial.println("Magnet detected!"); // Print message if no magnet is detected

}

delay(500); // Delay for stability

}

code- generated using chat gpt

Pasted image 20240506204134.jpg
this part code runs this loop digital read logic high and low and display the CORRESPONDING message saying whether amgnet DETECTED or not

final testing

code is designed to read and interpret signals from a Hall effect sensor, which detects the presence of a magnetic field. The Hall effect sensor is connected to pin 31 on the SAMD11 microcontroller. In the setup function, the code initializes pin 31 as an input and starts serial communication at a baud rate of 9600 for data transmission to a computer or serial monitor. In the loop function, the code continuously reads the digital signal from the Hall effect sensor. If the sensor outputs a high signal (HIGH), it indicates that no magnet is detected, and the message "No magnet detected" is printed to the serial monitor. Conversely, if the sensor outputs a low signal (LOW), it indicates the presence of a magnet, and the message "Magnet detected!" is printed. The delay(500) function pauses the loop for 500 milliseconds to ensure stable and readable output.

application

i included the hall effect sensor for Final project which is an encoder wheel embedded with 6 magnets in it.

tesing the encoder as a counter

// Define the pin for the hall effect sensor

const int hallEffectPin = 31;

  

// Variable to store the count of magnet detections

int magnetCount = 0;

  

// Flag to track whether the sensor was already triggered

bool sensorTriggered = false;

  

void setup() {

// Initialize serial communication

Serial.begin(9600);

  

// Set the hall effect sensor pin as input

pinMode(hallEffectPin, INPUT);

}

  

void loop() {

// Read the state of the hall effect sensor

int sensorState = digitalRead(hallEffectPin);

  

// If the sensor detects a magnet (LOW state) and it wasn't triggered before

if (sensorState == LOW && !sensorTriggered) {

// Increment the magnet count

magnetCount++;

  

// Print the current magnet count

Serial.print("Magnet detected! Count: ");

Serial.println(magnetCount);

  

// Set the sensor triggered flag to true

sensorTriggered = true;

}

// If the sensor is not detecting a magnet (HIGH state)

// reset the sensor triggered flag to false

if (sensorState == HIGH) {

sensorTriggered = false;

}

  

// // A short delay to prevent rapid counting due to sensor noise

// delay(100);

}

the code

this is how th code works

The hall effect sensor is connected to pin 31 of the microcontroller. The setup function initialises serial communication at a baud rate of 9600 and sets the hall effect sensor pin as an input. In the loop function, the program continuously reads the state of the hall effect sensor. When the sensor detects a magnet (indicated by a LOW state) and it wasn't previously triggered, it increments the magnetCount variable, prints the current count to the serial monitor, and sets a flag (sensorTriggered) to true to indicate that the sensor has been triggered. If the sensor no longer detects the magnet (indicated by a HIGH state), the flag is reset to false, allowing the sensor to detect the magnet again the next time it passes by. A short delay, commented out in the code, can be used to prevent rapid counting due to sensor noise.

group assignmnet

You can find our group page here and this week is here
Pasted image 20240417130855.jpg
setup of - us testing a hall effect sensor in for group assignment

reflection

This week, I learned the importance of deep diving into datasheets for any board we use. With a well-documented datasheet, I realized that we can figure out anything we need to know. This experience also brought me a step closer to my final project and boosted my confidence significantly.