0
\$\begingroup\$

I have recently been trying to transition from Atmel's Atmega 328p avr to the newer (and much smaller) attiny416. The trouble is, the 416 only allows you to choose between two positive inputs and two negative inputs for the analog comparator, and I need only one positive but three negatives to multiplex between.

Because the input pins to the chip are fixed in hardware I couldn't think of much except to add an external multiplexer to the device which is not an option.

The ADC the chip has, however, can take input from almost every pin on the 20 pin chip. I have never worked with the ADCs on these chips, but they may hold the answer. Can an adc on an attiny be programmed to act as an analog comparator without the overhead of a digital conversion? I know at the core of ADCs are comparators but haven't found any grinchy tricks to use them in my solution (one positive input and three negatives to multiplex between).

\$\endgroup\$
3
  • \$\begingroup\$ Technically, this would be a one-bit ADC \$\endgroup\$
    – Hackstaar
    Dec 23, 2018 at 6:47
  • \$\begingroup\$ is your source grounded or isolated? \$\endgroup\$ Dec 23, 2018 at 7:17
  • \$\begingroup\$ @Jasen The source is grounded. Basically, I am reading emf feedback from an electric motor, and have created a neutral point using a resistor network. I am comparing the neutral point to each phase to get an idea of where the motor is. But the analog comparator does not have enough negative channels for me to select all three phases... \$\endgroup\$
    – Hackstaar
    Dec 23, 2018 at 7:49

2 Answers 2

0
\$\begingroup\$

If you compare the resistor derived neutral point against the midpoint of the supply while the other two wires are powered you will get the voltage on the un-powered wire at 1/3 magnitude.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
5
  • \$\begingroup\$ Perhaps I’m totally losing it: the result of the comparator should always be the same as phases are changing right? How could this setup be used to know when to change phase? \$\endgroup\$
    – Hackstaar
    Dec 25, 2018 at 0:54
  • \$\begingroup\$ assuming that at any time two of the phases have constant values supply+ and supply- the third phase will be somewhere in between \$\endgroup\$ Dec 25, 2018 at 5:33
  • \$\begingroup\$ if you want to sense rotation while the motor is not powered you could connect three GPIO to the phases via resistors (drive one high and the other low, and leave the third as an input) the voltage on the third will be respresented to the comparator \$\endgroup\$ Dec 25, 2018 at 5:39
  • \$\begingroup\$ I’m afraid I still don’t see how this will help me. As the motor is powered and running, the comparator output should go high-low or low-high when it is time to change phases. The way I did this previously was to connect the vnp to the ref of the comparator (internal within the chip) and multiplex between the three phases as the (-) input. Then I used an interrupt when the comparator output switched to determine when to change phase. The problem is the new AVR chip doesn’t let you multiplex between the ADC inputs as the (-) input to the comparator. Do you know any tinyAVRs that do? \$\endgroup\$
    – Hackstaar
    Dec 25, 2018 at 6:00
  • \$\begingroup\$ no, because the comparator input is the average of the three phases two of them are known values, (one of them is high the other low), and the third is the one you want to know \$\endgroup\$ Dec 29, 2018 at 7:32
0
\$\begingroup\$

I finally found a solution. I decided in the end to use the attiny1616, which has the same package and similar costs to the 416, but is equipped with 3 analog comparators.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.