Hi
I intend to use the internal analog comparator to detect sinewave ( positive half wave 3V3 pp ) zero crossing to drive triacs safely.
Is there an application note for this purpose, already?
Thanks
Sergio
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi
I intend to use the internal analog comparator to detect sinewave ( positive half wave 3V3 pp ) zero crossing to drive triacs safely.
Is there an application note for this purpose, already?
Thanks
Sergio
Hi Amit
Sorry due delay to answer to you.
I am using the analog comparator with a sinewave decoupled from AC line and subtratec from a 3V3 DC voltage and as a result, the signal injected in C- input it is a 3V3 DC modulated with the same sinewave. So, controlling the internal REF we can generate a square-wave syncronized with different sinusoidal phases.
Follows the code used to initialize the ANALOG COMPARATOR 2:
void Init_CompC2(void)
{
GPIOPinConfigure(GPIO_PD2_C2O); // configure PD2 as C2O
GPIOPinTypeComparator(GPIO_PORTP_BASE, GPIO_PIN_1); // define PP1 as C2-
ComparatorIntRegister(COMP_BASE, 2 , INT_COMP2Handler);// this line is issuing compiler error ( see in the end of this post )
// COMP0 must be enabled first
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_COMP0);
//
// Configure the internal voltage reference.
//
ComparatorRefSet(COMP_BASE, COMP_REF_1_65V);
//
// Configure comparator 2.
//
ComparatorConfigure(COMP_BASE, 2, (COMP_TRIG_NONE | COMP_INT_RISE | COMP_ASRCP_REF | COMP_OUTPUT_NORMAL));
//
//
ComparatorIntEnable(COMP_BASE,2);
IntEnable(INT_COMP2);
}
void INT_COMP2Handler(void)
{
contador_comp2++;
ComparatorIntClear(COMP_BASE,2);
}
/*
The problem we are facing now is that the compiler send following error:
<Linking>
"../EK_TM4C1294XL.cmd", line 38: error #10099-D: program will not fit into available memory. run placement with alignment fails for section ".vtable" size 0x26c , overlaps with ".vecs", size 0x360 (page 0)
error #10010: errors encountered during linking; "TIO_BRASCONTROL_v20.out" not built
If I comment out the above line in BLUE, the compiler error dissapears.
Could you advice why is this error ocurring, please?
Sergio
Hi Amit
It is in BLUE, in previous post:
.
.
.
ComparatorIntRegister(COMP_BASE, 2 , INT_COMP2Handler);
.
.
void INT_COMP2Handler(void)
{
contador_comp2++;
ComparatorIntClear(COMP_BASE,2);
}
Amit Ashara said:First thing first.
Ahem - really - 10 posts in - yet dare this reporter, "bomb-throw" by suggesting that such, "Voltage crossing thru 0V is far easier - and better - and faster handled via long standard, simple analog hardware!" We note that poster has "subtracted" - likely via an op-amp - so "additional, external HW is (already) in play!
Our tech firm has (for decades) achieved such "zero crossing detection" via simple XX339 (analog comparator) - which enables wide, flexible & precise "comparator switch-point" hysteresis settings/adjustments. Run from a -5V charge pump (7660) there's "no need" for "subtraction" - nor to "struggle to master" (and further burden Amit) that which is clearly & greatly detailed w/in readily available analog tech documentation.
Yes the (unthinking) trend is toward, "MCU as kitchen sink." Yet that sink often proves, "Far from stainless" - and faster, FAR easier, inexpensive (external) methods deserve fair (i.e. some) consideration... [should the volume potential approach "serious" (a possible justification) - it's doubtful that such a question would "land" here...]
Master Yoda ( cb1_mobile ).
Your words are so complex as are your thoughts.
In a world so troubled nowadays, simple words are better for a fully understanding. Simple that.
Are you suggesting to use EXTERNAL analog comparator to detect zero-crossing?
Sergio
Sergio Kamakura said:Are you suggesting to use EXTERNAL analog comparator to detect zero-crossing?
Yes indeed - that method is so much faster, easier & more flexible to implement.
An external analog comparator (available in tiny sot-23) easily accepts your negative-going input signal - yet supplies a proper (0V - 3V3) output signal to your MCU's GPIO. Many, many examples exist detailing the implementation. (you'll have to limit the comparator's output swing to 0V - simple divider/diode combination - achieve that)
Note that it has recently been suggested that you employ (both) the MCU's ADC (and) a digital comparator - which further delays, complicates, and lessens the "robustness" of so complex a method! (the more items involved - the greater the chance for problems...)
There's yet another key/critical point in favor of this, "Use an external, analog comparator" suggestion. My firm - only and always - does this! Why?
Because to use the MCU's built-in comparator practically, "Locks you in" to that device! Thus - when a newer/better MCU arrives - what then? (you'll have a whole new "learning curve" to enjoy - and likely "wind up" right back here @ the forum - seeking help!) Our method (external analog comparator) is simply, "Gerber (pcb file) Cut/Pasted" from board to board - freeing us entirely to focus upon the new design - not the mastery of an arcane, overly complex MCU sub-system - which is better achieved via low cost, known good/proven, external hardware...
If you'd be good enough to "list" those words which you believe "unclear" I'll gladly offer definition. By the way - do you find the MCU manual completely clear? (often several "reads" of a tech document prove normal/customary) You suggest "simple words" - yet who is to define such?
Hi cb1_mobile
With all due respect cb1, if I have an analog comparator inside TM4C1294ncpdt that we have already paid for it, why not use it? And it is already integrated with interrupt structure of the processor, is that right?
We have AC zero-crossing detector using LM339 already fully operational in other projects, but, we want to try to use all resources available inside the TM4C1294ncpdt. Is no sin, isn't?
Regarding the manual, until now, I consider the TI's manuals, the best in the world. Since the 8080's era, I have read tons of manuals, and TI's is far, the best.
As I always say: not just talk, you have to make himself understood.
Sergio
udpEcho_TivaTM4C1294NCPDT.zipHi Amit
Follows zip file with entire project UDP_Echo modified with routines that gives link problem, as you requested.
Thanks,
Sergio
Amit
And what about the C2O pin ( PD2 ) that is not responding accordingly?
I am using the following command in EK_TM4C1294XL_initGPIO():
GPIOPinConfigure(GPIO_PD2_C2O);
Hope that this pin doesn't need special configuration such PD7 ( NMI ).
Do you have recommendations about PD2 configuration as C2O?
Thanks,
Sergio
Sergio Kamakura said:I am sure that the engineers from TI, spent a lot of time and effort to integrate an analog comparator inside a digital kernel for a reason: use it because it is good.
I would suggest fitness for purpose is a far better criteria.
Reduction in parts != reduction in complexity, besides adding a level shift to remove a comparator hardly seems an advance.
And Amit's suggestion that there is no hysteresis seems a step backwards. I rather hope that's an exaggeration on his part.
One thing to consider is that such circuits in a micro are generally less robust to external signals than their discrete counterparts.
Robert
Hi Robert
Thank you for your considerations. That's great.
But, what is in focus in this post is a linker problem. I could repeat the same problem in udp_Echo example. Amit wonder that is a startup file problem.
I have a problem in PD2 pin as C2O output also. I already posted explanation about.
I have a lot of reasons why I chose to use internal analog comparator. After fix those 2 issues, I will be glad to discuss those reasons.
Thanks,
Sergio