BabySpinach
Active member
Hello All,
I'm attempting to read a sensor value with a digital pin on a Teensy 3.2. This sensor value is a Variable reluctance sensor in an automotive transmission. Here are the waveforms on my oscilloscope, both at once:
https://i.imgur.com/YzvjOrI.jpg
Here is the filtered square wave, which runs through an op amp circuit. This is probed as it would be received by the Teensy 3.2:
https://i.imgur.com/wkjfOGR.jpg
Here is my sensor read function, which is supposed to increment an unsigned long variable each time a high is detected:
https://i.imgur.com/YQ2LVd1.jpg
Here is the main loop code. The sample value is 250MS. I'm trying to take a differential of the sensor count every 250MS. That differential is used to derive an RPM/Roadspeed:
https://i.imgur.com/ifG6ogo.jpg
The problem I am having is that the differential gets SMALLER as the driveshaft spins. This should be opposite.. To make it worse, it normalizes somewhere around 10MPH. I've taken a few pics with the actual calibrated roadspeed in the background and the Teensy serial data on the laptop screen. You can see the roadspeed value, which is just the current count of highs minus the last count 250ms earlier, gets smaller as the speed of the driveshaft increases. Is there something wrong with my code? Is there a special way the teensy needs to read these values?
I previously had an arduino uno reading these pulses just fine.
Mostly working at this specific speed:
https://i.imgur.com/ktMjEyV.jpg
Completely broken as speed increases:
https://i.imgur.com/B4HdrKm.jpg
I'm attempting to read a sensor value with a digital pin on a Teensy 3.2. This sensor value is a Variable reluctance sensor in an automotive transmission. Here are the waveforms on my oscilloscope, both at once:
https://i.imgur.com/YzvjOrI.jpg
Here is the filtered square wave, which runs through an op amp circuit. This is probed as it would be received by the Teensy 3.2:
https://i.imgur.com/wkjfOGR.jpg
Here is my sensor read function, which is supposed to increment an unsigned long variable each time a high is detected:
https://i.imgur.com/YQ2LVd1.jpg
Here is the main loop code. The sample value is 250MS. I'm trying to take a differential of the sensor count every 250MS. That differential is used to derive an RPM/Roadspeed:
https://i.imgur.com/ifG6ogo.jpg
The problem I am having is that the differential gets SMALLER as the driveshaft spins. This should be opposite.. To make it worse, it normalizes somewhere around 10MPH. I've taken a few pics with the actual calibrated roadspeed in the background and the Teensy serial data on the laptop screen. You can see the roadspeed value, which is just the current count of highs minus the last count 250ms earlier, gets smaller as the speed of the driveshaft increases. Is there something wrong with my code? Is there a special way the teensy needs to read these values?
I previously had an arduino uno reading these pulses just fine.
Mostly working at this specific speed:
https://i.imgur.com/ktMjEyV.jpg
Completely broken as speed increases:
https://i.imgur.com/B4HdrKm.jpg