News:

Let's find out together what makes a PIC Tick!

Main Menu

Input level options. (TTL/Schmitt trigger)

Started by david, Nov 19, 2023, 09:56 AM

Previous topic - Next topic

david

Hi All,
Looking for a bit of guidance regarding the input level option of a 16F1824.
Seems I can select Schmitt trigger option for "Port reads and Interrupt on change".   Would it apply to ext interrupt pin or do you think it's quite specific?   
Looking at the specifications for the two types of input, the Schmitt trigger appears to have a hysteresis range that could extend from 1V to 4V (5V supply) but there's no minimum given.
Has anyone used this feature?  I may have to write some code to see if I can measure the threshold and any hysteresis.

Cheers,
David 

tumbleweed

Just be aware that those numbers are the guaranteed specs, and typically the input levels are much different than those shown there.

It's hard to find a datasheet that has the graphs for typical input Vih/Vil but one chip I know of that has them is the 18F26K22. Figures 28-80 through 28-83 show the typical hysteresis could be < 0.5V.
Different family, so take that FWIW.

david

Thanks for your thoughts there.
I'll knock up some basic code to check if the ext int is included in the items with optional thresholds (doubtful).  If it is, I'll take a second step to determine if there is hysteresis.  I accept that it may vary considerably. 
This is a feeble attempt to achieve a bit of noise immunity on the interrupt.

David

trastikata

Quote from: david on Nov 19, 2023, 06:28 PMThis is a feeble attempt to achieve a bit of noise immunity on the interrupt.

Hi David,

In this case, most of the time I am using one of the HW timers that is being started after the interrupt and the Timer overflow interrupt clears the interrupt flag to resume normal operation.

The timer delay is chosen with respect the actual interrupt implementation.

Hope this helps.

david

#4
Hello trastikata,
It's a nice idea and I had considered a delay before clearing the flag but I have about a 30:1 timing range.
I'm not actually using an interrupt - just the latched flag and if the time interval was more constant it would be an ideal way to reduce the time interval over which it could respond.
The application is a 3 phase brushless hub motor and the sensor is a Hall Effect device measuring rotation.  Hub motors have a hollow shaft through which they bring out the 3 phase wires, 3 Hall Effect lines for commutation and a 4th Hall Effect feed for hub speed.  The last sensor is showing capacitive coupling from the phase wires which are switching 24V with both PWM and commutation signals.  Adding some capacitance across the interrupt pin to ground has largely removed the coupled edges but there's still odd interference getting through at some speeds and loads but it is difficult to reliably repeat the effect.  I'm not ruling out inductive coupling either at this stage as phase current can be up around 20A.   An external Hall sensor had no problems but the internal one is inherently there and used by all E-bike controllers so I'm obviously missing something.  Maximum rotation speed is around 30 revs/sec.   Still early days.....

Cheers,
David
 

trastikata

To me it doesn't look a problem that any hysteresis will resolve. In my experience (measuring wave speeds up to 7km/s) even with relatively slow 48MHz micro, the Schmitt triggers are fast and sensitive enough to pick-up transients and trigger the interrupt several times.

Meaning that any glitches are more likely fast transients that the micro will pick-up. Maybe you can employ a some kind of hardware timer delay based on current speed within 4-5 ranges.

Just my thoughts.   

david

I'm not sure it will resolve anything either.  If you have fast edges then even small amounts of capacitance can couple across but this is effectively solved by having a capacitive divider with the C on the Ext Int pin.  It also slows the turn off time of the Hall device (passive pull-up)and hence the pin spends more time in the linear region and is most susceptible to noise. That's why I thought even a small amount of hysteresis may be useful.
What sort of waves were those?  Through rock?

David

trastikata

I'd guess then the time-constant for that cap has to be carefully selected based on experimental data, looks like hard to calculate by technical specs only.
QuoteWhat sort of waves were those?  Through rock?
It was for measuring shock waves in mining ... but not the right place for discussion.  :)

david

The C in this case is just a simple capacitive divider.  The Hall device is inside the motor but is wired out along with the motor phase wires as an 8 core cable and thus affords a good risk of capacitive coupling.
In the simulation I've guesstimated 10pF and have used 100nS rise and fall times.  The 10pF readily couples in to the 2.2k Hall load when it's off but by adding the 1nF to ground the coupling is greatly reduced.
In practical terms 1nF is not quite enough to eliminate the coupling observed - 0.1uF works a treat but seems a ridiculously high value and implies possibly another coupling mechanism.  0.1uF is also going to cause high, short time current spikes in the Hall device as it repeatedly discharges it.  The value of 0.1uF is not a problem for the maximum speed of the motor.

On a different note - I have rigged up the PIC micro and taken a look at the Ext Int pin.  The port is configured for all TTL input levels but I'm sure the Ext Int pin has hysteresis.  Either that or my preset potentiometer has about 30 degrees of backlash.  There's no way I can set it on a critical point and watch it fizz away counting.

David