Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

T1677. UNO & NANO. INTERNAL COMPARATOR

2 posters

Go down  Message [Page 1 of 1]

1T1677. UNO & NANO. INTERNAL COMPARATOR Empty T1677. UNO & NANO. INTERNAL COMPARATOR Tue Jun 06, 2023 1:34 pm

Defran

Defran

By changing the ACME bit of the ADCSRB register, the negative input of the comparator always stays pointed to pin D7. It should be:
0: -COMP to D7, 1: -COMP to MUX for inputs A0 to A5.

T1677. UNO & NANO. INTERNAL COMPARATOR Inter11
Attachments
T1677. UNO & NANO. INTERNAL COMPARATOR AttachmentINTERNAL_COMP_TEST.zip
You don't have permission to download attachments.
(10 Kb) Downloaded 2 times



Last edited by Defran on Thu Jun 08, 2023 10:54 am; edited 2 times in total

arcachofo

arcachofo

Thanks, I will have a look.

Defran

Defran

In reality both conditions work fine:

ADEN=0, (COMP-) to D7
ADEN=1, (COMP-) to the AMUX.

I have tested in the pin D7 and in the pins A0 - A5, all OK but in the reality.

But remember, this failure happens with UNO and NANO, maybe with other Arduinos too.

Thanks for your attention.



Last edited by Defran on Wed Jun 07, 2023 9:43 am; edited 3 times in total

Defran

Defran

Another bit that fails is ACIE of the ACSR register. It is a bit related to the ANALOG INTERRUPTIONS, but for Simulide it must be set to 1. In the rality it does not matter if the interruptions are not used. I have tested it also.

arcachofo

arcachofo

Another bit that fails is ACIE of the ACSR register. It is a bit related to the ANALOG INTERRUPTIONS, but for Simulide it must be set to 1. In the rality it does not matter if the interruptions are not used. I have tested it also.
I don't understand this one.
"for Simulide it must be set to 1" ... for what?

Defran

Defran

Now, with the bit ACBG is possible to switch the input COMPARATOR+ between D6 and 1.2V (internal voltage reference). This operation works but only if the bit ACIE is 1. This is a failure, because the function of ACIE is only to activate the analog interruptions, not to operate with the comparator.

The other falilure is in the input COMPARATOR- that it should switch between D7 and ADMUX (to access the analog pins A0 to A5) with the logic of ACME and ADEN bits, but the input COMPARATOR- is fixed always ponting to D7 (regarless of the values of the ACME and ADEN bits). See my schematics and test it with my program or see the datasheet, chapter 22.

Tell me, please, if it is clear now.



Last edited by Defran on Wed Jun 07, 2023 9:42 am; edited 1 time in total

arcachofo

arcachofo

Now, with the bit ACBG is possible to switch the input COMPARATOR+ between D6 and 1.2V (internal voltage reference). This operation works but only if the bit ACIE is 1. This is a failure, because the function of ACIE is only to activate the analog interruptions, not to operate with the comparator.
Yes, that is in the real device.

But Simulide does not run the comparator continuously, this would use cpu even when it is not needed, specially in this case because comparator is enabled by default.
So the comparator only runs when interrupt is enabled or ACO is readed.
Triggering a compare action when ACO is readed was failing, that is why it was not running properly if interrupt was not enabled.

Similar things happen with most peripherals, for example Timers are not running continuously, they calculate when some event will happen in the future and schedule an event for that time.

This makes things much more complicated, but much more efficient.
Running the MCU's cpu and 15 or 20 peripherals continuously would use a lot of cpu in your PC.

The other falilure is in the input COMPARATOR- that it should switch between D7 and ADMUX (to access the analog pins A0 to A5) with the ACME and ADEN bits, but it is fixed always ponting to D7 (regarless of the values of the ACME and ADEN bits). See my schematics and program or see the datasheet, chapter 22.
Connecting Comparator to ADC multiplexer was not implemented.
I'm working in it and it's mostly completed.

Defran

Defran

It's good to know about the internal comparator in Simulide, thanks.

Will the ADMUX be ready for the next Simulide release?

For now I'm going to continue testing the analog interruptions and the timers...

9T1677. UNO & NANO. INTERNAL COMPARATOR Empty Re: T1677. UNO & NANO. INTERNAL COMPARATOR Wed Jun 07, 2023 12:07 am

arcachofo

arcachofo

Will the ADMUX be ready for the next Simulide release?
Yes, I will upload new files soon.

10T1677. UNO & NANO. INTERNAL COMPARATOR Empty Re: T1677. UNO & NANO. INTERNAL COMPARATOR Wed Jun 07, 2023 3:51 pm

arcachofo

arcachofo

Both issues solved at Rev 1697.

11T1677. UNO & NANO. INTERNAL COMPARATOR Empty Re: T1677. UNO & NANO. INTERNAL COMPARATOR Wed Jun 07, 2023 7:10 pm

Defran

Defran

Bien!!!

Thank you so much.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum