Hi all,
I got my hands on a few DC motors (no label/name except 12v/5A and hall sensor name sharpied on it) with this hall effect sensor soldered to it. Pages 4&5 have the specs. I have a 5V power supply used for the sensor.
set up:
Same code, different pins used, difference is using this SN74 logic shifter with the teensy.
I have 2 software debounced switches, some motor driver board, and this sensor. All from the same 2 channel power supply unit, one with a 12v rail to the motor driver for the motor, the other via a step down converter to 5v to power the teensy and the hall sensor.
My issue is I am unable to read the hall sensor data in my 4.1 board via interrupts. I was able to get this working correctly using an Arduino Mega board, but not with the Teensy 4.1 I think because the logic voltage.
Code used:
What I have tried:
2 logic level converters/shifters
1. TXS0108E. I think same issue as with the SN74, but gave up early with this.
2. SN74AHCT125 (saw this suggested in various threads here). I realized this is used for 3.3v ->5v, but the adafruit website said if I powered it with 3.3v and had a 5v input, it'll have a 3.3v friendly output.
Correct:
In the arduino mega board, the hall output directly connected to the arduino I/O pin. It was pulled high, triggered on LOW as seen in the code. So at default, the hall outputs 5v, and testing the halls across 5 motors gave an avg ~6000 pulses/second at full speed.
Incorrect:
In the teensy, I use the SN74 logic shifter. I have 1OE to GND to activate it, 1A to the hall 5v output, and 1Y to the teensy 4.1 I/O pin. Same code as above, hall pulled high, triggered on LOW. So at default/rest (motor not moving), the hall reads the correct 3.3V, but when I push my switch to rotate the motor, the SN74 hall sensor output doesn't trigger the LOW ISR signal.
- I tried 2 things.
1. SN74 output not connected to teensy. When switch pressed, motor rotates, voltage will show the 3.3v to 1.65v when the motor is on (I think it shows 1.65v bc it's the mean/rms of 0v and 3.3v)
2. SN74 output connected to teensy 4.1 pin 4, most times the switch and motor no longer work (ie pressed switch and no motor rotation, and thus, no hall voltage changes).
If I change the ISR to "CHANGING," and plug in the SN74 output to my teensy, my ISR triggers when the motor is rotating and the hall count gives me insanity levels of pulse counts that make zero sense (ie like 100,000+ counts within 2-3 seconds). I get why the changing is no good as it's in the middle/floating b/w a low and high logic lvl.
My ideas:
I don't have an oscilloscope, but I think I need one. I have a pack of resistors, capacitors, and zener diodes.
Few thoughts:
1. SN74 datasheet says "All unused inputs of the device must be held at VCC or GND to ensure proper device operation. Refer to the TI application report,
Implications of Slow or Floating CMOS Inputs, literature number SCBA004. So since these OE pins are active when pulled to low/ground, I should pull the unused OE pins/channels to VCC?
2. Buy the 74LVC125, which is designed for 5v -->3.3v logic direction. Or if there's a "newer/better" chip/component?
3. his post here mentions decoupling capacitors. Lowest capacitor I have is 0.1uF. Should I attached this b/w ground and hall sensor Voltage input using the correct polarity? I noticed my halls on the arduino would slowly trigger (1-2 triggers every 2-3s) even when my motors weren't rotating. I assume this is the noise issue that the 0.1uf capacitor could resolve.
Besides those ideas, I have no clue what to do and would appreciate any suggestions/input. I am currently learning about basic electronics so I am not too great with understanding how to resolve what appears to be a simple issue.
I got my hands on a few DC motors (no label/name except 12v/5A and hall sensor name sharpied on it) with this hall effect sensor soldered to it. Pages 4&5 have the specs. I have a 5V power supply used for the sensor.
set up:
Same code, different pins used, difference is using this SN74 logic shifter with the teensy.
I have 2 software debounced switches, some motor driver board, and this sensor. All from the same 2 channel power supply unit, one with a 12v rail to the motor driver for the motor, the other via a step down converter to 5v to power the teensy and the hall sensor.
My issue is I am unable to read the hall sensor data in my 4.1 board via interrupts. I was able to get this working correctly using an Arduino Mega board, but not with the Teensy 4.1 I think because the logic voltage.
Code used:
Code:
//global:
volatile long hallCount=0;
void setup()
{
pinMode(hallSensor1, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(hallSensor1), hallCounter, LOW);
}
//I tried changing the ISR to changing/rising, no luck.
void hallCounter() {
if (motorFWDS== 0) //a flag to add/subtract the hall pulse depending on motor direction
hallCount= hallCount+1;
else
hallCount= hallCount-1;
}
What I have tried:
2 logic level converters/shifters
1. TXS0108E. I think same issue as with the SN74, but gave up early with this.
2. SN74AHCT125 (saw this suggested in various threads here). I realized this is used for 3.3v ->5v, but the adafruit website said if I powered it with 3.3v and had a 5v input, it'll have a 3.3v friendly output.
Correct:
In the arduino mega board, the hall output directly connected to the arduino I/O pin. It was pulled high, triggered on LOW as seen in the code. So at default, the hall outputs 5v, and testing the halls across 5 motors gave an avg ~6000 pulses/second at full speed.
Incorrect:
In the teensy, I use the SN74 logic shifter. I have 1OE to GND to activate it, 1A to the hall 5v output, and 1Y to the teensy 4.1 I/O pin. Same code as above, hall pulled high, triggered on LOW. So at default/rest (motor not moving), the hall reads the correct 3.3V, but when I push my switch to rotate the motor, the SN74 hall sensor output doesn't trigger the LOW ISR signal.
- I tried 2 things.
1. SN74 output not connected to teensy. When switch pressed, motor rotates, voltage will show the 3.3v to 1.65v when the motor is on (I think it shows 1.65v bc it's the mean/rms of 0v and 3.3v)
2. SN74 output connected to teensy 4.1 pin 4, most times the switch and motor no longer work (ie pressed switch and no motor rotation, and thus, no hall voltage changes).
If I change the ISR to "CHANGING," and plug in the SN74 output to my teensy, my ISR triggers when the motor is rotating and the hall count gives me insanity levels of pulse counts that make zero sense (ie like 100,000+ counts within 2-3 seconds). I get why the changing is no good as it's in the middle/floating b/w a low and high logic lvl.
My ideas:
I don't have an oscilloscope, but I think I need one. I have a pack of resistors, capacitors, and zener diodes.
Few thoughts:
1. SN74 datasheet says "All unused inputs of the device must be held at VCC or GND to ensure proper device operation. Refer to the TI application report,
Implications of Slow or Floating CMOS Inputs, literature number SCBA004. So since these OE pins are active when pulled to low/ground, I should pull the unused OE pins/channels to VCC?
2. Buy the 74LVC125, which is designed for 5v -->3.3v logic direction. Or if there's a "newer/better" chip/component?
3. his post here mentions decoupling capacitors. Lowest capacitor I have is 0.1uF. Should I attached this b/w ground and hall sensor Voltage input using the correct polarity? I noticed my halls on the arduino would slowly trigger (1-2 triggers every 2-3s) even when my motors weren't rotating. I assume this is the noise issue that the 0.1uf capacitor could resolve.
Besides those ideas, I have no clue what to do and would appreciate any suggestions/input. I am currently learning about basic electronics so I am not too great with understanding how to resolve what appears to be a simple issue.
Last edited: