Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding current sensor with fault protection unit support in ATmega32u4 #2

Open
cinderblock opened this issue May 26, 2016 · 0 comments

Comments

@cinderblock
Copy link
Owner

cinderblock commented May 26, 2016

I'm working on version 2 of the ATmega32u4 based PCB. Instead of working on it privately, I'm just going to post my thoughts here. Comments appreciated.

The main feature I want to add is an aggregate current sensor for all channels. I'm not targeting support for FOC just yet so no need for a per channel measurement. I'd also like to minimize the BOM cost and to that end, ideally use the internal 1/10/40/200x gain amplifier instead of an external instrumentation amp. The main drawback I'm seeing is reduced resolution on the ADC values.

If 1x, 10x, or 40x gain is used, 8-bit resolution can be expected. If 200x gain is used, 7-bit resolution can be expected.

I'd also like to add support for triggering the built-in fault protection unit in TIMER4.

There are two ways to trigger a TIMER4 fault, INT0 or the internal comparator output:

image

I'd like to use an external comparator to trigger INT0. It would allow use of an external resistor resistor divider to set an arbitrary trip point that could be adjusted for different sense resistors or with with an RC-filter off of a separate PWM channel to set a trip point in software.

The other reason to use an external comparator is that we'd like to keep the internal one available for hardware back EMF sensing. The current design allows the output of the ADC multiplexer to use the internal hardware comparator to trigger an interrupt, based off of either the internal 1.1V bandgap reference or an external reference at AIN0:

image

Unfortunately, my current application uses I2C communications. SDA and INT0 share the same pin and cannot be used in conjunction. Therefore, I need to use the internal comparator as the trigger for TIMER4's Fault Protection Unit and cannot use it for automatic Back EMF sensing. But that's fine since I'm only currently interested in speeds covered by the magnetic shaft sensor's update rate.

If I'm going to use the internal comparator, we'd like to not use an external one. If I connect the top of my current shunt to AIN0, I can setup the comparator between that and the 1.1V bandgap reference. Unfortunately, that means a 1.1V drop across the resistor would be needed to trip. Supposing a 30A limit, V = IR, 1.1V / 30A = 37mOhm. But that's also 33Watts (P = VI, 1.1V * 30A = 33W) through that resistor, way to much for the small components I'm hoping to use. For a 1210 resistor, the largest current we could hope to dissipate is 1W which, at 30A, gives us a .033V signal.

It would be nice to use one for the ADC inputs via the multiplexer to allow setting arbitrary trip values with an external resistor divider. Unfortunately, the ADC multiplexer is in use if we want to use the ADC at all.

image

We could choose our inputs such that with the ADC multiplexer settings are correct for both the current sensing ADC and using an external reference to set the fault level on AIN0. The downside would be that we couldn't use any of the other ADC channels.

The alternative is to add a single external comparator IC and feed its output to AIN0. This would enable the use of other ADC channels. That's a trivial extra part for a good amount of extra flexibility, so I think it's worth it.

For now, I'm also not targeting higher voltage drives. No need to complicate things with a separate gate drive voltage yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant