PDA

View Full Version : Inconsistent Current with Duty Cycle?



Steel
09-19-2007, 03:47 AM
I have attached a scope capture of using the Counter "Duty" output.

On Rail levels $FFFF_FFFF and $0000_0000, the output current appears quite stable...however when a middle value is sent ($8000_0000, $C000_0000) the output current is quite inconsistent.

Is this a characteristic of the Propeller that needs to be filtered out?

The code is attached.· I have a 10k resistor attached to each output to get the voltage.

Shaun

Paul Baker
09-19-2007, 04:09 AM
You have your scope's averaging filter turned on, since the duty cycle's periodic nature can extend up to nearly a minute (depending on what the value of FRQ is) you should turn off averaging.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

deSilva
09-19-2007, 04:12 AM
(a) I do not fully understand the oscilogram you have posted - is ist assumed to be connected to the low-pass? Why 3 Ampere ??

(b)


djnz Latch, Loop


looks unhealthy. It has to be "#loop" in the first place.

Skogsgurra
09-19-2007, 04:27 AM
First thing: make sure your probes show volts - and the right scale factor. You should have reacted to the amps scale in the first place. Several amps surely heat things up beyond recognition. But the fact that you also mention current in your question makes me wonder if you are aware of the "sublte" difference at all. Then check other settings. Only then is it meaningful to discuss behaviour of the Prop. Also, the missing immediate (#) sign does very bad things to your code. As dS already pointed out.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Steel
09-19-2007, 04:33 AM
So I fixed the "#" in the code. thanks, desilva.

I actually just left the Amps label on the scope accidentally. I was using a current probe prior to this, and just forgot to switch it back. It wasn't reading 3.5A...but 3.5V. Sorry about that.

...And I don't have any averaging on the scope. It is taking 20MS/Second, and displaying those samples. I could do averaging...but I am not.

I am not running a low pass filter on the circuit. I am trying to monitor the 'true' output. I just have a 10k Resistor attached to the pin, and I am reading the voltage on the downstream side of the resistor. The Current across the resistor creates the true voltage and that is what I am monitoring right now.


There is no Cap, because even a .01uF cap on this signal does a great deal of rounding it out, and I would like to keep it as close to the 'real' propeller output as possible.

deSilva
09-19-2007, 04:42 AM
Your descriptionis still confusing....
This 10k... Do you want to say you have connected it to ground?
Al right, this will do no harm...
And the fix of the #-bug has not changed the output?

On the other hand, why do you use an assembly program... there is no need for it and it makes the situation a little bit dubious..

Can you quickly recode it in SPIN and see what happens?

Phil Pilgrim (PhiPi)
09-19-2007, 04:48 AM
Steel,

I think you're seeing sampling errors in your scope. The scope is just showing you what it saw over its 50nS sampling interval. The signal during this interval can have several transistions present, and what the scope samples will vary from interval to interval, depending on the ratio of highs to lows encountered. With an 80MHz clock rate coming from the Propeller, your scope would have to sample at 160Mhz to show you the "true" output. What you could do is slow the Propeller's clock to 10MHz. Then you'll be able to see the output.

-Phil

Post Edited (Phil Pilgrim (PhiPi)) : 9/18/2007 9:00:16 PM GMT

Paul Baker
09-19-2007, 04:53 AM
Thanks Phil, exactly what I was going to say.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

deSilva
09-19-2007, 05:03 AM
To add:
I studied the oscillogram now, and think it is exactly what has to be expected in this somewhat unclear RC situation. Any parasitic capacity (even a finger!) will influence the "integration" behaviour.

When adjusting to the oscilloscope's capability, clean 0/1 patterns should be seen...

Skogsgurra
09-19-2007, 05:05 AM
To really rub it in: The sampling interval is not 50 ns but a whooping 1000 ns (1 microsecond). What the scope catches is entirely arbitrary.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Tracy Allen
09-19-2007, 05:36 AM
To add to what others have said, the true voltage output from the Prop pin at the midpoint, $8000_0000, is alternating 12.5nS full high and 12.5 nS full low. Your 'scope probably does not have the bandwidth to capture that accurately.

The RC low pass filter shown at the top of the program has a time constant of 1 millisecond. Even an RC filter with a microsecond time constant can give significant filtering of the 12.5nS time slots. Where is your 10k resistor? If it goes from the Prop pin to the input of the 'scope, then it would provide 300 nanosecond RC filtering with the ~30pf input capacitance of the 'scope (depending on the probe).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Steel
09-19-2007, 06:36 AM
I am using a Yokogawa DL7440 2GS/s Oscope. I really don't think the sampling time is an issue here...But I could be wrong. This is just the most accurate scope we (and most people) have available.

...Also, if it was a scope issue, then it would show the inconsistencies at the rails ($0000_0000 and $FFFF_FFFF). The only'wobbling' is on the Frequencies between $4000_0000 and C000_0000 (In this test setup)

The 10k resistor is connected directly to the output pin, and the other end is connected directly to the scope probe. There is no capacitor and no extra components. I am just reading the Voltage that directly represents the Current from the pin. There are no fingers

The scope gnd is attached to VSS.

I put it in assembly because I am going to have a lot more in this application that I wish to have in ASM. This is not the only thing that I am doing. Having this code in ASM instead of SPIN should not affect the actual pin characteristics

Paul Baker
09-19-2007, 06:48 AM
You scope may be capable of doing 2GS/s, but only if you specify it to, according to the picture you posted it is performing 1 MS/s and displaying the results at 1 ms/division. You have "zoomed too far out" to be able to see the indvidual pulses. What you are seeing is an aliased version of the real signal. Also the 10k resistor isn't needed if you are using the voltage probe.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker (mailto:pbaker@parallax.com)
Propeller Applications Engineer
[/url][url=http://www.parallax.com] (http://www.parallax.com)
Parallax, Inc. (http://www.parallax.com)

javer
09-19-2007, 07:39 AM
Steel,

Maybe I am wrong, but I think your scope is triggering on both edges.
Did you try to set slope on raising (or faling) edge?

Skogsgurra
09-19-2007, 01:38 PM
Another case of "it is soo expensive, it can't be wrong"

A modern scope is not something you just throw at a signal and then come crying saying your signal is wrong. It needs some practicing, studying and understanding.

Like a gun. It is easy to hurt oneself if one hasn't understood and practiced.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

deSilva
09-19-2007, 01:54 PM
Steel, I dont want to sound rude - it's so easy beeing not in full command of a foreign language - but I think this is the situation quite similar you are in... You are not "in command" of some electronic basics.....

Are you really aware that the "duty"-output is a tiny 12,5 ns spike? There in fact is no need to look at it "as such" (Why?). The tricky things will be to make sure it does what it shall do in the context of your circuit (triggering something, being integrated,....).

Do you understand the concept (and the involved parameters) how a capacitor is used as "low pass filter" or an "integrator"?

Tracy Allen
09-19-2007, 03:47 PM
Leave out the 10k resistor and connect the probe right to the output pin. The 10k resistor in series between the pin and the scope probe (with its capacitance) is going to make a low pass filter, something like 10kohm * 30 pf = 300 nanoseconds, much longer thant he 12.5 ns pulse width.

Or, slow down the Propeller clock to 5 megahertz (leave out the PLL16x), and the logic is all the same, but the output time slots 200 nanoseconds instead of 12.5, easier to capture.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

TomS
09-19-2007, 07:38 PM
Why is everybody saying 12.5nS when it takes a minimum of four clock cycles to execute an instruction?

Steel, You need some capacitance after the 10K resistor. 100nF is too much. Your pulse width looks like its around 500uS so an RC time constant of 10uS should give you plenty of filtering. With a 10K resistor that gives a capacitance of 1nF.

Tom
ps More later, I must leave for work. damn!

Peter Jakacki
09-19-2007, 07:51 PM
The counters are running at 80Mhz = 12.5ns cycle whereas the CPU is operating at 4 clock cycles/instruction = 20MIPS.

BTW Steel, when the output is max or min it is not switching which is why it looks clean no matter what setting you have your dso on. If I may be cheeky, at least with a car you need a license before you can take it out on the road :)

*Peter*
damn! I better do some work!

deSilva
09-19-2007, 10:21 PM
Looking again through this thread I think it could be constructive to explain a little bit, what the "duty cycle" mode the timers really does. First fact is: It has a confusing name http://forums.parallax.com/images/smilies/smile.gif

Second, it sets the output "high" whenever PHSx overflows by adding FRQx each system (!) clock. This is a tiny spike of e.g. 12.5 ns, except when the next addition leads to another overflow...

This is simplicity itself and hardly to misunderstand.
However the consequences might not always be clear....

(1) This it NOT a PWM!
(2) 12.5 ns is not much!
(3) There is generally no strict regularity (!) in the pulses, except FRQx is a power of 2.
(4) for the latter reason, the PLL should ALWAYS be used after the timer

Example: When FRQx is around $F......... PHSx will overflow many times (e.g. 16x) before a tiny zero break will bring the timer back to 16 highs, but sometimes 15 only. This is the trade-off for a very simple and transparent implementation.

Edit: Tried to make it even clearer...

Post Edited (deSilva) : 9/19/2007 3:08:58 PM GMT

TomS
09-19-2007, 10:31 PM
Steel, I would suggest that you output a pulse at the beginning of your spin code loop on a spare pin and use it to trigger your scope.· That would eliminate the overlapping traces.· It won't eliminate your problem but will make it easier to see the program flow.· I also think that you don't have any capacitance after the 10K resistor other than probe capacitance because of the fast rise and fall times seen.· You need some more capacitance as I stated in my previous post.· It may be that what you are seeing is an "alias" caused by the relationship between the propeller clock and the sampling rate of your scope (at 1mS/div the sampling rate is probably much less than 2GB/Sec). What you see isn't always what is truly there, especially with sampling scopes.



Peter, My knowledge of the propeller counters is very limited at this time and I have a problem understanding how an I/O·pin can switch at the full 80MHz rate.· Is this really possible?



Tom

damn! I better do some work now that I'm at work.

deSilva
09-19-2007, 10:41 PM
@Tom: Why not do some reading about the timers/counters? AN001 is very recommendable.

Peter Jakacki
09-19-2007, 10:43 PM
TomS: "is it really possible?"

You better believe it, and it doesn't stop at 80MHz either, more like 128MHz. Have you ever tried the Synth object?

*Peter*

damn! I can't remember what work I was going to do.

TomS
09-19-2007, 10:47 PM
dS,· Will do.



Peter, My next project must use a counter so I suppose I'll be an "Xpurt" by the time I'm done.



Tom

damn! I can't remember what you were supposed to be doing either.

Steel
09-20-2007, 01:25 AM
Im sorry if you guys felt that I came at this with some sort of attitude. Reading the posts referring to me as 'crying', 'needing a license to operate a scope', 'to really rub it in', etc.... struck me as Quite odd, and I hope that I don't have to read through it again in future threads.

I was really just trying to verify that there counter outputs were consistent. It could have been a fairly easy yes/no answer.

The reason why I went into the equipment that I am using is because instead of the yes/no answer, it became a question of my test setup. As far as 'overlapping' signals, those are 2 different signals (as you would see in the code) that I was using for testing.

I don't feel that there is any reason to 'defend' my credentials, background, or equipment knowledge when all of that is a complete sidetrack to the original question.

I am really trying to understand the current/voltage spikes at a low level, and that is it. I just needed to know "Yes, unfortunately because of the way the counters work, there will be 12.5nS changes" or a "No. We tested the current output of the propeller to be stable within a 5% tolerance"

This answer quite suffices: "There is generally no strict regularity (!) in the pulses, except FRQx is a power of 2". -Thank you DeSilva.

If I wanted to be referred to as 'crying'...then I would not have come to a forum for engineers.

Sorry. I just feel that some of the responses were fairly out of line. Thank you to those who helped.

Skogsgurra
09-20-2007, 01:56 AM
steel,

I understand that you refer to my posts, mostly.

We have had some "hopeless" cases lately. So I, for one, was prepared to see yet another round of these endless Q&A sessions, which sometimes gets on your nerves.

I can not judge you from your possibly/probably charming and competent personality. All I have to go after is what you write. And what you wrote did not impress me a bit. You have clearly indicated in the headline that it is about current and not voltage and you are also discussinmg current until corrected. Anyone in this business knows that more than a 20 or 30 mA is next to impossible out of a micro pin. And that 3 A will fry the circuit immediatly. That alone makes me very suspicious.

You also have no clue that you are sampling with a 1 microsecond interval - but say that you have a 2 GS/s (500 ps) going. Another mistake that you would not expect from a person as competent as you say you are. Plus a few other things that I think needed to be mentioned to put you on track.

I am rather tired of the "Hey! This doesn't work!" threads. Especially those where the reason is lack of understanding of basic measurement techniques. They cause a lot of unnecessary confusion.

I understand that you don't like my attitude. I am rather used to that. But I think that a certain degree of technical correctness and fairness should be kept in this thread. I happened to be the bad guy this time. But there are several of us. And I am glad for that.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

TomS
09-20-2007, 04:01 AM
Steel,· I'm sorry if I offended you.· That wasn't my intention.· I guess I totally misunderstood what you wanted.



Tom

Tracy Allen
09-20-2007, 05:21 AM
When you asked a question about consistency, I jumped to the conclusion that you were talking about consistency in amplitude, because it is amplitude stuff that is obvious in your oscilloscope trace. The answer to the question about consistency in amplitude has to be a resounding "yes", the amplitude of the 12.5nS pulses is highly consistent, rail to rail, and that led naturally to a discussion of the setup of the 'scope with regard to amplitude and timebase scaling, triggering, and how the probe was connected to the input, and your understanding of the counter mode operation and application. We would have to ask those questions in order to figure out why the 'scope trace is what it appears to be.

In light of that, it does not make sense to me that you say, <This answer quite suffices: "There is generally no strict regularity (!) in the pulses, except FRQx is a power of 2". -Thank you DeSilva.> I think deSilva is quite right about that answer, but it doesn't really have much to do with the original question you posed. Also it would be wrong to say that the pulses are either regular or irregular, without a context of what you are trying to accomplish.

Here is an excerpt from your statement in the first message..."
>>" ... when a middle value is sent ($8000_0000, $C000_0000) the output current is quite inconsistent.
>>Is this a characteristic of the Propeller that needs to be filtered out?
>>The code is attached. I have a 10k resistor attached to each output to get the voltage.

How can we give a yes or no answer to that regarding propeller timing issues, when the obvious issue is amplitude? The first red flag that goes up for me (as an engineer) is when I read "the output current is quite inconsistent" and "I have a 10k resistor ... to get the voltage". Maybe it is a question of language or maybe I am misunderstanding, but why, I immediately ask, does Steel need a 10k resistor to get the voltage? The output of the Prop is already a voltage, and the usual application of duty mode is to generate analog DC voltage. Similar reactions occur when I read your middle sentence below, concerning the 12.5nS "changes" and the "current output" being stable to within 5%. huh? We are quite willing to help here, but we can help best when we have a good target for answers.


Steel said...
...
I was really just trying to verify that there counter outputs were consistent. It could have been a fairly easy yes/no answer.
....
I am really trying to understand the current/voltage spikes at a low level, and that is it. I just needed to know "Yes, unfortunately because of the way the counters work, there will be 12.5nS changes" or a "No. We tested the current output of the propeller to be stable within a 5% tolerance"
This answer quite suffices: "There is generally no strict regularity (!) in the pulses, except FRQx is a power of 2". -Thank you DeSilva.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Post Edited (Tracy Allen) : 9/19/2007 11:56:21 PM GMT

Peter Jakacki
09-20-2007, 06:39 AM
There are days when I feel like a real dill, I say all the wrong things, I do all the wrong things, and I might get a ribbing for it from my friends.
Sorry Steel, I think this is one of those days for you so why wouldn't you get a ribbing, we are engineers who know how to look at the lighter side of our own stuff-ups (and others). The fact that we are taking the time to figure out what you are saying and to try to be helpful would indicate that on some scale we are your friends. Examine the facts and what you yourself have said, how else can we answer?

So please don't feel offended by our comments as they are not meant to hurt (too much http://forums.parallax.com/images/smilies/smile.gif).

Have a good day.

*Peter*