Two questions regarding analog comparator

Go To Last Post
79 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello

I have a sensor that outputs a value not higher than 8,19mA +/- 8%, and down to 0.01V. I use a pull-down resistor with a value of 330ohm to get a voltage U=R*I<3,4V (less than 3,4V).

I want to connect this output to the non-inverting input on the analog comparator integrated in the ATmega128RFA1. I want to use a voltage of 0.5V on the inverting input on the comparator.
Regarding this, I have two questions:

  1. When I measure the voltage at the output of the sensor (with no signal on the sensor) without connecting it to the STK600, I get as expected 0,01V. I should then expect that the comparator outputs 0. The problem is that when I connects it to the AIN0-pin and measure the voltage, I actually have 0,7V, which is higher than 0,5V and I get "1" on the comparator output. When I increase the inverting voltage to 0,8V, I get "0" output. If I measure the voltage on the AIN0-pin with nothing connected to it, I measure a voltage of 0,9V. All this is without pull-up resistor enabeled. If I enable the pull-up, I measure 3,4V on the AIN0-pin.
    The solution I made for that, is to use an external op-amp as a buffer-circuit. I connect the output of the sensor to the non-inverting input of the external op-amp. The inverting input of the external op-amp is connected to the output of the op-amp, and the output of the op-amp is also connected to the non-inverting input of the built-in analog comparator. This is working perfectly, but I would like to know why I has to do it this way, and if there are a better solution.

  2. At this site at the bottom, you can read that I should use a security-resistor at the input to avoid current above 1mA. Is this necessary when I already has calibrated the pull-down resistor of 330ohm described in the introduction? And is it necessary when/if I use the external op-amp? If I need it, would it be correct that it should be R=Umax/Imax=3,4V/1mA=3400 ohm?
    Quote:

Thanks for answers :D

PS: Please ask if you want any clarification of what I wrote.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

r2d290 wrote:
... a sensor that outputs a value not higher than 8,19mA +/- 8%, and down to 0.01V.
...........
r2d290 wrote:
I use a pull-down resistor with a value of 330ohm to get a voltage U=R*I<3,4V (less than 3,4V).
...........
r2d290 wrote:
PS: Please ask if you want any clarification of what I wrote.
What does "not higher than 8,19mA +/- 8%, and down to 0.01V." mean ? You start off with a spec that starts with a current value (including a meaningless comma) and end with a voltage at pretty much ground potential.
What does "U=R*I" mean ? Or did you mean V=I*R

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello, sorry for the confusion.

I'll try again:
It's a weft sensor which detects how many yarns/treads is moving.

If zero yarns are moving, it outputs less than 0.1mA
1 yarn moving = 2,73mA
2 yarns moving = 5.46mA
3 or more yarns moving = 8.19mA.

When i use a pull-down resistor of 330 ohm on these different current values, i get voltages between 0,01V and around 2.8V (which is less than 3.4V).

In Europe, we use U as the unit for voltage and V as the quantity for voltage. I think that is done because we don't want to mix the unit with the quantity. In the same way as we use I and A to difference between the quantity and unit for current :)
But yes, U=R*I is the same as V=R*I

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

r2d290 wrote:

In Europe, we use U as the unit for voltage and V as the quantity for voltage. I think that is done because we don't want to mix the unit with the quantity. In the same way as we use I and A to difference between the quantity and unit for current :)
But yes, U=R*I is the same as V=R*I

Actually it's just the other way around: the unit for the electric potential (voltage) is the SI defined Volt, expressed by the symbol V, whereas U is the symbol of the physical quantity you're talking about.

So you either state that U = R*I (voltage is resistance times current),

or you state that V = [Ohm] * A (Volts is Ohms times Amperes).

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yeah, I confused myself with the quantity and unit. But I see from the English Wikipedia that they are actually using V=R*I on the other side of the ocean. So, let's live in peace even though we are different :)

But, please don't get off topic ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I thi k we need to see a schematic of what you're proposing. You mention an opamp, but we have no idea of how you've powered it and what sort of opamp it is. This may determine if you need a 'security' resistor.

Somehow you think the AVR is leaking voltage into your circuit. The input impedance of the AVR is quite high, so i would be surprised this is happening. Why did you not use the adc to measure the voltage rather than the comparator? If you want a comparator, why did you use a opamp? Why not an external comparator?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do not need an opamp at all, and you do need to use ADC instead of comparator since you want to determine more states than just on/off. A "security" resistor is a good measure against excess ADC input current. Add a 10 nF capacitor at the ADC input to filter possible voltage glitches.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The external op-amp is a 741. The supply-voltage on this is +12V and -15V. The plan is to use a rail-to-rail op-amp LMC6041, because we do not have negative power supply available in our finished product (we have a negative power supply for testing).
As you can see from my schematic, I'm wondering if the R2 resistor is necesary and why I need the U1 op-amp (or if there are any way to skip it). As mentioned, if I have zero threads moving (0,1mA out), I measure 0,7V on PE2 if I skip the op-amp U1 and the resistor R2 (I have not yet tested with the R2). And if I remove everything, I have 0,9V on the PE2.
And again, if i skip the op-amp and R2, I measure 0,01V on the "positive" pin of R1 just untill I connect it to PE2.

And as soon as I added the 741 as buffer, everything works smooth.

Quote:
Why did you not use the adc to measure the voltage rather than the comparator?

Two reasons: I want to use the interrupt-functionality of the comparator. It's also because I wanted to learn a something new, I've already tried ADC in a previously project.

Quote:
If you want a comparator, why did you use a opamp? Why not an external comparator?

with "opamp" I assume you are talking about my external 741? Are you asking me why I don't use an external comparator when I first uses an external op-amp? Well, I'm using the multiple input-functionality with one input on the ADC0-pin, and uses the MUX to switch between these negative inputs. On the ADC0-pin, I'm using a 1,5V supply.
The reason why I added the op-amp was just to remove the problem with voltage leakage, but I need to have a good reason why I need to use it if I use it.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In any case you do not need an opamp at all. Besides, are you sure your sensor should be loaded with a parallel resistor instead of commonly used series one?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The input impedance of tbe 741 is somewhat lower than the AVR. The configuration of your sensor seems a little strange. If it can output 8mA, then the input impedance of the AVR is negligable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You do not need an opamp at all

Then, what can I do to avoid my problem that i have 0,7V on the non-inverting input, and that I therefore have to increase the inverting powersupply to more than 0,7 to get zero on the analog comparator?

Quote:
and you do need to use ADC instead of comparator since you want to determine more states than just on/off.

I'm only interested in on/off. I want to find out whether there's no threads moving at all, or not. That's only on/off, and I can't see why I can't use analog comparator. Actually, I am using the analog comparator, and it is working. I just need to use the 741 op-amp :P

Quote:
A "security" resistor is a good measure against excess ADC input current.

Then I will use this resistor. Have I calculated it correctly as 3400 Ohm?
I'll also add the capasitor. That should be connected from the input on the STK600, down to ground?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 741 ouput can swing towards either of the power rails, so you need to take that into account.

With the leakage, something doesn't sound right. It shouldn't happen. Something is not correct with your circuit.

Check the schematic of the stk600. Maybe there is something connected on that board.

Last Edited: Mon. May 7, 2012 - 01:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:
In any case you do not need an opamp at all. Besides, are you sure your sensor should be loaded with a parallel resistor instead of commonly used series one?

Yes, I hope I can remove it, but if I do, I need to know why I get these 0,7V on the PE2-pin. I get 0,01V on the PE2-pin when I have the 741 buffer circuit (when the ThreadSensor outputs 0,1mA).

Are you sure you are talking about current-output sensors, and not voltage-output sensors? Well, I'm not sure of anything. But I asked the thread sensor company if I could do it like that with a pull-down resistor, and I also asked my employer who confirmed it (I'm a student, working with a bachelor project).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
The input impedance of tbe 741 is somewhat lower than the AVR. The configuration of your sensor seems a little strange. If it can output 8mA, then the input impedance of the AVR is negligable.

And the conclusion about this negligable impedance is?
What does that mean for my problem? :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Current flows in a loop. That's why the resistor is usually in series.

Earlier you say that you get 3.4v with the pullup enabled. This does not make sense as the pullup resistor is 10's of kiloohms into a 330 ohm resistor. You havent turned on the pullups, you've enabled the output. Look at tne stk600 to see if it has some circuitry connected and repeat your tests. Something fundamental is going wrong.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Work it all back to ohms law. There is no magic.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
The 741 ouput can swing towards either of the power rails, so you need to take that into account.

With the leakage, something doesn't sound right. It shouldn't happen. Something is not correct with your circuit.

Check the schematic of the stk600. Maybe there is something connected on that board.

Yes, I know that the 741 can swing towards either of the power rails. However, as far as I can understand, I'm not even close to any of these rails. I'm never below 0V, or above 2.7V.

I'll do some more tests without "all the other stuff" connected to it. I will remove all the other wires connected to the pins on the STK600, so that there are nothing else but this circuit connected.

Btw: What voltage am I supposed to have on the PE2 when it is configured as non-inverting input without pull-up resistor? And is it correct that it should not be pull-up resistor on it?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Current flows in a loop. That's why the resistor is usually in series.

Earlier you say that you get 3.4v with the pullup enabled. This does not make sense as the pullup resistor is 10's of kiloohms into a 330 ohm resistor. You havent turned on the pullups, you've enabled the output. Look at tne stk600 to see if it has some circuitry connected and repeat your tests. Something fundamental is going wrong.

I hear what you say about series/paralell, but as you can see from the picture above, I get the voltage as expected when I do it that way. How would the schematic on the circuit look like if I connects it in series? I'm willing to try that if you could please explain how.

What you are saying about 3.4V sounds logic. I can do a new test on this tomorrow to find out if I was wrong, and report back what I get if I do a new attempt to enable the pull-up instead of enabeling output.

I will do some more tests with only this circuit connected (remove all other circuits).

Thank you so far!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What voltage on PE2? Depends how you measure it. It should be 0volts. You could meadure the current from the pin to 0v. It should be nanoamps( if your meter can measure that low), again, i repeat that you look at the schematic of the stk600. It may have a led or something connected to PE2. You don't want the pullup enabled.

Simple test. PE2 to 330r to 0v. How many volts across tne 330r resistor? Should be zero. If not calculate the leakage resistance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are the sensor GND terminal and the +-12V supply midpoint (0V) terminal connected to STK GND?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I measure it from the pin to gnd. I'm asking basic questions, yes, but I get confused when I get the resaults I do.

Thank you for the tips of simple test. I will test that ASAP.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:
Are the sensor GND terminal and the +-12V supply midpoint (0V) terminal connected to STK GND?

Note that I don't have +-12V, but +12V and -15V. But yes, everything has common ground. Both the sensor, the supply for op-amp, supply V1 (on the schematic), and the STK600 is grounded together.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I've done some tests now. The first thing I did, was to disconnect every connected cables from the pins, and I'm only using GND on the STK600, all other GND-sources is disconnected.

I've used the following code:

#include
#include 
#include
int main()
{
   //DDRB=0x04;
   //PORTB=0x04;
   DDRE=0x04;
   PORTE=0x04;
 
   while(1)
   {      
   }
   return 0;
}

The first test I did was to do voltage measurements directly on the pins without any connected resistors.
I did tests with both 0 and 4, both on the DDRx and the PORTx. I think PortB is working properly, and that something is wrong with PortE:

DDRB = Low and PortB = Low -> 0,00V
DDRB = Low and PortB = High -> 3,36V
DDRB = High and PortB = Low -> 0,00V
DDRB = High and PortB = High-> 3,38V

DDRE = Low and PortE = Low -> 1,91V
DDRE = Low and PortE = High -> 3,36V
DDRE = High and PortE = Low -> 0,11V
DDRE = High and PortE = High-> 3,38V

Then I did the test I were told to, and measure the voltage over a 330 ohms resistor. I then got:

DDRB = Low and PortB = Low -> 0,00V
DDRB = Low and PortB = High -> 0,00V
DDRB = High and PortB = Low -> 0,00V
DDRB = High and PortB = High-> 2,77V

DDRE = Low and PortE = Low -> 0,61V
DDRE = Low and PortE = High -> 0,62V
DDRE = High and PortE = Low -> 0,10V
DDRE = High and PortE = High-> 2,76V

What can be wrong here? Are there any way to fix it, or do I have damaged hardware?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

r2d290 wrote:
I'm only using GND on the STK600, all other GND-sources is disconnected.
Absolutely stupid decision. All GNDs must be connected together, and the opamp must be thrown away along with its +- supplies.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read the whole sentence ;)

Quote:
The first thing I did, was to disconnect every connected cables from the pins, and I'm only using GND on the STK600

There are nothing but the STK600, a multimeter and a 330ohms resistor in this test. So, there are nothing to ground, except for the 330ohms resistor and the multimeter (and of course the STK600). The sensor, op-amp, power supply for the op-amp and the other power supply for the inverting input on the analog comparator, are totally removed from the system.

So, There must be something unusual wrong here? Can it in any way be fixed?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds like something is connected to that port pin on the stk600. Contact Atmel support or visually trace the pcb tracks from the chip.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the support :)

I've tried to moved the 128RFA1 to an other STK600 with the same resault, so I think I will conclude with that something is wrong with the 128RFA1. I can't visually see anything wrong.
I sendt a mail to atmel support, and hope they can help me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Without the avr module plugged in, do you still have the problem?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you mean without the 128RFA1? If so, then I have 0.00V on the output.

Btw: I talked with my analog circuits teacher now. He has no specific knowledge on the atmel, but he is a Doctor. He told me that I really should use the 741 buffer circuit together with built in comparator. I did not catch the reason why, so I will ask him again later. He also told me that it necessarily was not something wrong. He wanted me to open the data sheet and find out what the Input bias current, and common mode current range is.

So, I'll try to do that, to find out what he has to say :)

Btw: The reason why i should i should find out about "Input bias current" and "Common mode current range" is that the op-amp might have a minimum of input voltage, so that it won't work below this. Sounds weard to me, but I'll read about it, and then come back to him later.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thell him he's a stupid Doctor then :lol:

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's almost a given that the professors out here know FA about the real world. Sad but true.

The reality is that we have a cmos chip vs a bipolar chip. Another point is that opamps (especially 741s) make crap comparators. Use something like a lm339 and use another port pin. Sounds like you may have zapped PE2. Time to get the hot air rework tool out to replace the dud chip.

Nexttime, see the doctor when you have a headache, or the crabs or whatever...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, I talked with the stupid Doctor (he laughed when I said that :P ). The reason why he told me to use the voltage-follower, was if the input had high capasitance (even if it has high impedance) AND the frequency were high. The reason why this is an idea, is because if this is not done, I could risk a floting voltage. But when I told him that the frequency is not higher than about 1Hz (one thread) per second, he agree with you that it SHOLUD not be necessary with the op-amp.

But the funny thing here, is that the op-amp in this particular case is necessary to "fix" my voltage leakage problem. I need to have the op-amp to get zero voltage on the input of the comparator when zero threads are pulled. The problem with this, he said, is that when you have a voltage out of the 741 op-amp, and also a "reverse" voltage from the atmel, then this will generate heat.

The conclusion we made was one of two:
1) We have done something random with a random register, which overrides a function. If this is the case, this must be a register that do not reset when I upload new code to the micro controller. Is this even possible?

2) There have been some damage on the microcontroller, and some of the functions are not working properly.

What do you think?

I'm still waiting for an answer from Atmel support.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What does "FA" mean? :P

Quote:
Sounds like you may have zapped PE2. Time to get the hot air rework tool out to replace the dud chip.
Jepp, it looks like you are correct. I'm looking forward to tell our employers that we have destroyed their 128RFA1 :P

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BTW, something I maybe should have added for a long time ago:

All this was working perfectly, until we start changing some registers and the clock cycle regarding the USART. The day after we did these changes, the errors started to occure. Is it possible that these changes can have something to do with this?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A proper (not damaged) MCU will not introduce or cause any "voltage leak", so you should first fix the "leakage" issue which is all in your code/schematics I suppose.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now I got confused.

You can see my code Posted: May 07, 2012 - 06:25 PM

Is it possible that something in that code can cause this leakage?

You say that it can be something in the schematics. I know now for sure that it's nothing wrong with the STK600 developer kit, so it must be something on the 128RFA1 attached to it. I can't visually see any short circuits on the 128RFA1, and I'm not connecting anything to it. So, if it is something in the schematics, it's something invisible.

You say that a proper (not damaged) MCU will not introduce or cause any "voltage leak". But is it not now most likely that it IS damaged? Or am I just paranoid?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Connect a pot instead of a sensor to point #2 and check the voltage in a whole pot range.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What do you mean with point #2? Do you mean PE2?

In other words, do you want me to connect the PE2 to a pot, and then out of the pot down to GND? The same as I did with the 330 ohms resistor, only with a pot? And remove the rest of the circuit?

kilo ohm--------volt
,272 = ,54
,322 = ,60
,370 = ,65
,408 = ,69
,451 = ,73
,528 = ,79
,578 = ,82
,640 = ,87
,707 = ,90
,813 = ,95
,931 = 1,00
1,13 = 1,07
1,41 = 1,14
1,85 = 1,22
2,15 = 1,26
2,84 = 1,32
4,29 = 1,40
11,35 = 1,53

Do you want me to continue?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I mean connecting the ends of a pot to GND and VCC, and its wiper to the left terminal of R2 marked with a red "2".

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

God, i feel stupid now. Where's the left terminal of r2 marked red '2' :p on the 128rfa1?
I have it not available the next 12 hours, but will do a new attempt then.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Dude, I refer to the schematics you've posted above - what f.cking R2 could be in the 128rfa1?

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ohh, I see. I think it's time to sleep now :P

Will give you the results tomorrow.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, here is my new attempt. The circuit is attached in this post. I did voltage measurements both in poin#1 and point#3. The kiloohm-value is from Point#1 to GND.

kilo ohm---Point#3 (V)---Point#1(V)
0,00----------0,36------------0,00
0,29----------1,38------------0,11
0,36----------1,38------------0,14
0,40----------1.38------------0,16
0,54----------1,39------------0,21
0,67----------1,40------------0,25
0,89----------1,41------------0,32
1,12----------1,42------------0,38
1,92----------1,44------------0,56

Did I do it correct this time?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Gibberish. With your 2k pot the "1" voltage should vary from 0 to VCC even if the PORTE.2 is damaged. Check your wiring.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's a 100k pot, not 2k if that does matter? I just did not turn the pot longer than 2k because I did not know if it was safe. If I turned it to 100k, it would maybe be vcc.

So, you want me to take the whole range up to 100k?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Get a 1..2k pot and redo the whole range measurements.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"1..2k"... Did you mean 1.2k? Or from 1k to 2k? Or something between 1k and 2k?

I could not find a 1.2k pot, but I have both a 1k and a 2k pot. Which should I use?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I mean 1k..2k pot (the lesser the better). For correct measurement results the pot's output resistance (~Rpot/2) must be substantially lower than your R2 value.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I've not used pots verry much. As mentioned, I have one pot that goes from 0ohm to 2k, and another pot that goes from 0ohm to 2k.

If I do understand you correct, you want me to use a pot that start at 1k and goes up to 2k. Am I correct?

The school does not have this kind pot. Can I use my 2k pot, and let it start in the middle posision (1k) and then increase it to 2k?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm pretty sure MBedder want you to use either a 1K pot or a 2K pot and sweep it from end to end.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Certainly.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks :)

Will do that if I get the 128RFA1 available today :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kilo ohm---Point#3 (V)---Point#1(V)
0,00----------0,36------------0,00
0,06----------1,39------------0,21
0,10----------1,42------------0,36
0,15----------1,45------------0,55
0,20----------1,47------------0,74
0,25----------1,50------------0,91
0,30----------1,54------------1,10
0,35----------1,57------------1,25
0,40----------1,62------------1,47
0,45----------1,70------------1,65
0,50----------1,84------------1,84
0,60----------2,24------------2,24
0,70----------2,66------------2,66
0,80----------3,09------------3,09
0,87----------3,38------------3,38

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now you can clearly see that your 128rfa1 is pulling the pot output high with ~100 uA current (I=(0.36V-0V)/3.4k). This current value suggests again that you failed to turn off the PORTE.2 pullup resistor - actually you did the opposite in your code (PORTE=0x04 line). Replace it with PORTE=0 and check for the effect.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've done all the last tests with DDRE=0x00 and PORTE=0x00.

I tried now to change it to PortE=0x04, and did measurements on 0,00k-ohm, 0,10k-ohm, 0,30k-ohm, 0,50k-ohm and 0,80k-ohm.

On these five tests, there was NO difference from the test I did above with PortE=0x00, except for 0,5k-ohm. Here I get 1,84V on #1, and 1,9V on #3. When I changed it back to 0x00, it jumped down to 1,84.

So... The pull-up does not deactivate when it is suposed to? Is that the error?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Check your entire code for ANY wrires to PORTE.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is my entire code. I really can't understand that it can be anything "wrong" in this simple code?

/*
 *  Written in AVR Studio 5
 *  Compiler: AVR GNU C Compiler (GCC)
 *
 *  Author: AVR Tutorials
 *  Website: www.AVR-Tutorials.com
*/
 
#include
#include 
#include



 
int main()
{
   DDRE=0x00;
   PORTE=0x00;
 
    
   while(1)
   {
       
   }
 
   return 0;
}
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Never used 128RFA1, does it possibly have JTAG pins on PORTE?
If so disable JTAG fuse.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Make sure nothing of STK600 is connected to PORTE.2. Since the analog comparator's inputs can be connected to some other chip pins by ADMUX settings, remap the AC inputs to some other ANx inputs and check over if you still have problems.

Also make sure the STK600 is smart enough to have the [not AVCC, corrected->]AVDD pin connected to the VCC.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

Last Edited: Wed. May 9, 2012 - 06:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lennart wrote:
Never used 128RFA1, does it possibly have JTAG pins on PORTE?
If so disable JTAG fuse.

Uhm. I have a 10-pin cable from JTAG to a 10-pin just next to the JTAG-port on the STK600. But these are definitely not on the PORTE or any other ports. It's seperated on its own section of the STK600. So, I don't think so?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder wrote:
Make sure nothing of STK600 is connected to PORTE.2. Since the analog comparator's inputs can be connected to some other chip pins by ADMUX settings, remap the AC inputs to some other ANx inputs and check over if you still have problems.

Also make sure the STK600 is smart enough to have the AVCC pin connected to the VCC.

I don't know how I can make sure that nothing of STK600 is connected to PORTE.2. Well, isn't it obviously that the STK600 is connected to the PORTE.2? Isn't that kind of the point with the STK600? Anyway, I'm sure that nothing "else" is connected to my circuit.

About what you say regarding ADMUX and remapping: I depend on to use the MUX-functionality because I use both AIN1 and ADC0 as the inverting inputs for the comparator. I'm positive to your idea to remap the input-pins for the comparator, because it seems that it's only PortE.2, PortE.3 and PortE.4 that is damaged (or having the same problems). How can I learn how to do this?

The word "AVCC" is not existing, neither in the 128RFA1-datasheet or the STK600-datasheet. Could you please tell me more about this?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I mean AVDD. And by STK600 I mean any components of STK600 PCB.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

But these are definitely not on the PORTE or any other ports.

??? So, how does the JTAG work, if not connected to your target chip? ESP?

What does the datasheet say? You can look at the pinout diagram, or the JTAG section, or the pin descriptions, or the alternate function tables, or ...

Anyway, JTAG is on port F.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I connect the stk600 JTAG programmer signal to the JTAG pins target device as ilustrated in these pictures:

Does that mean that the PORTF and the "JTAG Pins target device" is basicly the same port? Could I connect the "stk600 JTAG programmer signal" to the PORTF instead?

I will look more on AVDD tomorrow. Tomorrow I will also take the 128RFA1 to my employer, so I can compare it to another 128RFA1 that they have. Maybe I can borrow an functioning 128RFA1, or maybe is is able to find the problem.

I'll give you report :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Does that mean that the PORTF and the "JTAG Pins target device" is basicly the same port? Could I connect the "stk600 JTAG programmer signal" to the PORTF instead?
No, only 4 pins of JTAG are connected to PortF.
Don't know where reset pin is located on that chip but reset is one of the pins used by JTAG.
In short, use JTAG connector for JTAG.
You might want to remember which pins on PortF that are JTAG cause they will behave odd as long as JTAG is enabled.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for the clarification :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm. My employer also have stk and rfa1. He measured almost the same as me. Conclusion: nothing is specifically wrong with my rfa1, but it seems to be a common 'error'. I just think it's wierd that it's not a known error :s

But should I then use the voltage follower op-amp to get a working solution for our presentation, or do you have any other suggestion?

Last Edited: Thu. May 10, 2012 - 07:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since the STK600 schematics is still top secret, you should inspect the whole PE2 trace on STK600 PCB and find all PCB components connected to it. Another solution is to throw away the STK and either route your own M128RFA1 breakout board or get the ready made one like this.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that would be way more than what we are able to do in 19 days. I've now got answers from Atmel support, so I think I will continue with them. I will reply here if I get a working solution. But realy... Thank you guys for the support! :D

Quote:

We have observed the following behaviour at our side, where the voltage measurements (using multimeter) directly on the PE2 and PB2 pins of on the ATmega128RFA1-EK + STK600 :

DDRB = Low and PortB = Low -> 0.2V
DDRB = Low and PortB = High -> 3.3V
DDRB = High and PortB = Low -> 0.002V
DDRB = High and PortB = High-> 3.3V

DDRE = Low and PortE = Low -> 1.85V
DDRE = Low and PortE = High -> 3.3V
DDRE = High and PortE = Low -> 0.1V
DDRE = High and PortE = High-> 3.3V

Ther variation between the two ports shall be due to the difference in the alternate port function (refer section 14.3 Alternate Port Functions in datasheet).

We assume you are trying to input sensor reading to Analog comparator. Do you find any wrong results in analog comparator? If so please provide the code and output results.

Please explain the actual issue that you are facing at your side.

Best Regards,
Sivagurunathan S
Atmel Technical Support Team

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sivagurunathan S wrote:
Ther variation between the two ports shall be due to the difference in the alternate port function
Email him he's an ignorant idiot. Period.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The alternate port function for PE2 is Analog Comparator Positive Input (surprise??!!).
Someone with a bigger brain than me maybe can explain why 1.85V is the "normal" value to be expected.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MBedder: Could you please be more specific? As the noob I am, I don't think it's a good idea for me to walk around and call everyone "Stupid Doctor" and "Ignorant idiot" =)
Why do you think he is ignorant? Because he is neglecting the fact that I got almost 2V on my input? He is pointing out that it has something to do with the comparator, and it seems like he wants to help me?
Constructive feedback will be appreciated :)

But yes, I'm really wondering the same thing as Lennart. Why the F... is it like this :S

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The first thing which he must have checked is the STK600 schematics which he as a techsupport guy should have an access to. Instead, he was blindly repeating your experiment which obviously has shown nearly the same results as yours.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mhm, I see. I will try to formulate a reply to him tomorrow =)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Feel free to supply a link to my posts to him :lol:

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok, new reply from AVR support.

Quote:
Please understand that we have the LED and Resistor connected to PE2 pin in the ATmega128RFA1-EK card. This might affect your expected results.

Please refer the schematics of ATmega128RFA1-EK board, you can find this document in the location -> http://www.atmel.com/tools/ATMEG...

Try removing the resistor which is connected to PE2 pin, this will isolate the pin from VTG_INT.

Hope this solves the issue.

I assume that they are referring to the R8=470R and green D2 in the upper right corner of the schematics.

Does anyone of you know how I "remove" the resistor? Do they actually mean physically to remove that little resistor with a soldering iron?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Please understand that we have the LED and Resistor connected to PE2 pin in the ATmega128RFA1-EK card. This might affect your expected results.
Bingo! That's exactly why I said he's an idiot when I saw he's doing the measurements without trying to locate and disconnect all external components from PE2. Nevertheless, that had to be the first thing you had to do yourself - checking the available schematics.

Yes, you have to desolder the resistor.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry :/

That part in the upper right corner was outside my screen, so I did not notice it.

I know you have told me to remove all the external components, but could not imagine that you were referring to the the external components that was soldered on the 128RFA1 by the manufacturers :)

But thank you so much for your help and time! I'll try to do this tomorrow if I'm allowed by my employer. Can't understand that I can do this without killing the guarantee :O