ATTiny88 Comparator usage

Hi All,

I am embarking on a new project. I beleive the ATTiny88 has a built in comparator. As speed is not a problem is it worth trying to use it or just compare 2 I/Ps, 1 of which has a voltage divider setting 2.5V and checking if the other I/P is higher or lower?

I am currently using a comparator controlling an UP/DOWN digital pot but now trying to make it even smaller. (because I want to, and it is a learing experience)

There is no reason not to use a microcontroller peripheral as long as it meets the project specifications needs.

AC is basically compared with two inputs, but it is also allowed to connect one to an internal reference voltage of 1.1V.
You can also generate an interrupt when the voltages on the two inputs are swapped.
It has three types of conditions available: rising edge, falling edge, or both.

Of course, it should be noted that only the voltage from GND to VCC can be input.

EDIT:
Also, It should be noted that the output of the comparator is considered to be used in the code (software) most cases, and only some AVRs have the ability to connect directly through to the pin.
Many AVRs (including the ATtiny88), don't allow to directly use the comparator output at any pin.

Thanks for your response.

The input will be 12V but obviously divided down. It will be 2 wires that will change polarity in certain circumstances. If one is positive WRT to the other then it will cause the digital pot to count up otherwise it will count down. I am also guessing the code for this is going to be very small.

What kind of digiPot do you use?
You check regularly which wire has the higher voltage and operate the digiPot, right?
Or do you just switch the digiPot to a specific fixied value the moment the wire polarity changes?
Is that part of the code complete?

I currently use an AD5227 but I am planning on changing this to a MCP4011-103E/MS. My current circuit has no micro, it has the comparator (which I am wondering why I am using it) to activate the CS and one if the inputs as the up/down count. It also has a 555 to clock the up/down. The up/down output goes from 0V to 5V or 5V to 0V depending on polarity and it is to take 0.5s to do so. I have attached a PDF of the current schematic.

Servo_Eliminator_R5.pdf (236.0 KB)

Where will 12V appear?
There is no good place to exceed 12V in this circuit.

There is also a strange point.
There is no pull-down on the negative input of the LM358 (this is an op-amp, not a comparator).
With this, there is no pass for the accumulated charge to be discharged.
Also, if the input voltage is analog, it is not desirable to connect directly to the digiPot's digital input without using a schmitt-trigger.

What is the required output impedance for the Yellow wire (a.k.a. digiPot output) connected to the 5-pin connector?
IMO, by using tiny412 (8PIN AVR), digiPot may not be needed either.
(No 555,No op-amp, No digiPot.)

Yes. I should have labeled the voltage.

The 12V is on pins 1 and 2 (Green and Blue). The output on the Yellow wire goes to the ECU on a motorbike.

How would I use a tiny412 without the digipot?

Is VCC (red wire) a regulated 5V?
In that case, the U/D of the digiPot and LM358 are got overvoltage, which is a mighty problem.

Use the DAC output.

Yes, the red wire is 5V from the ECU. The circuit has been working for years so not sure why it hasn't popped.

Does the tiny88 have a DAC as well?

Okay.

Probably because due to the current limitation by the 10K resistor.
The each IC's internal protection diode is probably passing current to VCC.
I don't recommend this design. (Well, there may be some people who okay it.)

No.
Unfortunately, DACs are only equipped for relatively new ATtiny.

I was hoping to avoid UPDI but if I can do this without the digipot I will put up with it. Thank you for your assistance. I will try and do the schematic and see what you think.

UPDI can be easily run with a standard USB serial adapter, just one diode and one resistor.
Also, there are many excellent models of new AVRs that require UPDI, and I recommend them. :wink:

There are great Arduino Cores.
https://github.com/SpenceKonde/megaTinyCore
https://github.com/SpenceKonde/DxCore
https://github.com/MCUdude/MegaCoreX

I am already using UPDI on a tiny3217 in another project. It works now but had some fun due to a voltage divider on the UPDI pin. Long story but now works.

Cool. :+1:

I recommend keeping the UPDI pin dedicated to UPDI programming. :smirk:

Unfortunately I couldn't. I only had 4 pins to the external world, 12V, GND, Analog in and Digital out. I had to use the UPDI as the Analog in.

@windoze_killa
Ahhh, I remember seeing that topic. :laughing:

BTW, What about the idea of attaching an LPF to the PWM output of the ATtiny88.
I think it works fine because as the final required voltage signal changes slowly (0.5 seconds from maximum to minimum).
In this case, I think even ATtiny85, ATtiny13 and ATtiny10 can do that.
ATtiny10 is so small! :mag:

Well I have done most of the design using the 212/412. The only bit I need to work out is getting the 12V safely down to something that won't pop the chip. Do you think simple voltage dividers would be sufficient with a couple of zeners for protection?

Zener diode doesn't provide protection when the microcontroller has not powered (VCC=0V).
Since the current provided by the voltage divider is likely to be small, Schottky diodes that clamp to VCC and GND are available.

Well, if chosen good resistance with voltage divideder, it may be okay to use the "internal" protection diode as in the your original circuit.
The AVR's internal clamp (protection) diode is not to burn out if the current is less than 1mA.

Also, I'm really sorry. :pensive:

I forgoted that the ATtiny1's DAC can only output maximum voltage up to 4.3V
I recently worked on the AVR DB series in another project, which I forgot because the AVR DB's DAC can output values close to 5V...

What is the resistance value of the digiPot in the original circuit?
Since the digiPot voltage is divided by 1.2K ohm, if a 10K ohm digiPot is used, the output is 0.5V to 4.5V, so there may be no problem.

Not sure what you mean by this. When ever the ignition is on it will have 5V.