PWMPAL question ?
serout 0,6,[noparse][[/noparse]"!PWMSS",240] ' initialize outputs
test
serout 0,6,[noparse][[/noparse]"!PWMM1",255,0,255,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,1,0,1]
pause 600
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 600
serout 0,6,[noparse][[/noparse]"!PWMM1",1,1,1,1]
pause 600
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 3600
goto test
' listening off of pin 12 on a BS2 stacked with a PWMPAL
' what causes the 'randomness' in the pattern?
' I can understand latency but a loop shoud produce
' a pattern right ?
' Do the 2 pcbs run on differant clocks ?
' This is some kind of 'beating' ?
' It seems to possibly have something to do with using 16 bit
' vs. 8 bit duration values ?
test
serout 0,6,[noparse][[/noparse]"!PWMM1",255,0,255,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,1,0,1]
pause 600
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 600
serout 0,6,[noparse][[/noparse]"!PWMM1",1,1,1,1]
pause 600
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 3600
goto test
' listening off of pin 12 on a BS2 stacked with a PWMPAL
' what causes the 'randomness' in the pattern?
' I can understand latency but a loop shoud produce
' a pattern right ?
' Do the 2 pcbs run on differant clocks ?
' This is some kind of 'beating' ?
' It seems to possibly have something to do with using 16 bit
' vs. 8 bit duration values ?
Comments
serout 0,6,[noparse][[/noparse]"!PWMSS",240] ' initialize outputs
test
serout 0,6,[noparse][[/noparse]"!PWMM1",255,0,255,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,1,0,1]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",1,1,1,1]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 3600
goto test
' listening off of pin 12 on a BS2 stacked with a PWMPAL
' what causes the 'randomness' in the pattern?
' I can understand latency but a loop shoud produce
' a pattern right ?
' Do the 2 pcbs run on differant clocks ?
' This is some kind of 'beating' ?
' It seems to possibly have something to do with using 16 bit
' vs. 8 bit duration values ?
test
serout 0,6,[noparse][[/noparse]"!PWMM1",255,0,255,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",255,0,255,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",255,0,255,0]
pause 300
serout 0,6,[noparse][[/noparse]"!PWMM1",0,0,0,0]
pause 3600
goto test
' listening off of pin 12 on a BS2 stacked with a PWMPAL
' what causes the 'randomness' in the pattern?
' this time the notes remain whole
BUT !
there is a random 'pop' (transition from low to high(or high to low))
during the 3600 pause ......
AND !
? BECAUSE !
the
' I can understand latency but a loop shoud produce
' a pattern right ?
' Do the 2 pcbs run on differant clocks ?
' This is some kind of 'beating' ?
' It seems to possibly have something to do with using 16 bit
' vs. 8 bit duration values ?
There is a momentary “glitch” in the outputs whenever you send a new serial command. Since you’re looping the same serial data repeatedly you’re going to see that glitch every 3.6 seconds. You should only SEROUT to the PWMPAL when you actually need to change a channel output anyway. Also, please try to be more concise in your posting…It took me awhile to figure out why there were three almost identical posts on this question. You can always edit your original post if you need to update it. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
>almost identical posts on this question
If you would look at the posts more carefully ..
And either listen (or watch on a scope) and/or (bonus for both) to pin 12
You will see what I mean ........
255,0,255,0 (set durations)
'vs
0,1,0,1 (set durations)
'yield ridiculessly completely differant results
WAY more than the differance in frequency suggests .....
Why not follow Mr. Savage's advice and ask clear-cut questions? He supports all of us on a LOT of different forums. His help is truly invaluable. Every opportunity one has to make it easier for him to grasp the problem makes an answer or suggestion that much more forthcoming.
It is my firm belief--I don't know for sure because I don't work for them--that if Parallax discovers a problem with one of their products, or code they have published, they will correct the situation as soon as possible.
Mr. Savage and the other Parallax folks are an extremely valuable resource. And, they like to be used! [noparse]:)[/noparse]
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
>> vs
>> 0,1,0,1 (set durations)
>> yield ridiculessly completely differant results
>> WAY more than the differance in frequency suggests .....
What could be more "clear cut" than that ?
Regarding the following . . .
">> 255,0,255,0 (set durations)
>> vs
>> 0,1,0,1 (set durations)
>> yield ridiculessly completely differant results
>> WAY more than the differance in frequency suggests .....
What could be more "clear cut" than that ?"
Respectfully, almost anything would be clearer than what I have quoted from you above. First, to the good, there are only six lines instead of the original three pages. Second, it is addressed to no one, therefore I think it must be for me, since I am the one that suggested an alternative approach to phrasing the question. The problem is that I am unfamiliar with the technical subject matter·and you apparently have far more experience. Therefore, I cannot address too much of the technicalities of the quoted portion above. (How about putting a colon after each label in the code you posted previously? That would help, I am sure.)
But, at my very first glance, it looks like you are trying to shift some arguments right. When I think about it for a bit and compare it to what you previously posted, I know that must not be your intent and you must have some other intent. But, what is it? Perhaps, I have missed a long-running conversation between you and others and the people you have addressed (implicitly, because there is no opening salutation) know exactly what you mean.
Third, proper spelling always improves anyone's writing. Fourth, your postings are written in incomplete sentence fragments, often with ending punctuation randomly inserted. This makes your meaning very difficult to discern, thus the antithesis of "clear-cut." I could continue, but I am sure you understand what I mean now concerning a more clear-cut writing style.
I have been in the technology business a very, very long time. Clear-cut communications are of paramount importance. The first thing professionals that do not know each other do is determine the meaning of the various terms (as we use them) that clutter our profession. Even professionals that do know each other go through this process. It is certainly a time-saver and, most often, a money-saver.
You know, if you could explain the problem to me, a newcomer to this field, I bet everyone would understand it!
Again, respectfully,
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Could you be more specific as to the timing on the random pop. How may in what time frame.
Speculating here since I do not have a pwmpal but I did just read the data sheet.
Mike Green gave me some information in another post about a BS2 pin in INPUT mode.
Perhaps this is the random pop?
I also have questions on setting the pwmpal to 0,0,0,0 duty cycle. There are special situations that effect hardware timers when set to zero time , I dont know the internal workings of the PWMPAL if the 0,0,0,0 frequency is actually passed along to the timer but after reading the datasheet I would think you might be better off using the Hardware control control status. Use the hardware On/Off pin to turn the PWM on or off after you pass the frequency and duty cycle information. That shuld make it cleaner. Like I said I dont know if the input is interrupt driven or polled, double buffered or not so additional debugging on that point is something I cant do without more information on how the software controls the PWM output from the PWMPAL side.
Hope this helps. I know things that sometimes I think should not happen make me get upset, but stay the course , drill down to the cause and you will find the answer. Sometimes it's a simple misunderstanding of how a device functions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
For now disregarding the 'intermittant' "pop":
What I am doing is using pin 12 on a PWMPAL/BS2 to put out square waves at different frequencies which need to be updated periodically. (~every half second or so)
The duration values below refer to the commands to the PWMPAL.
If I set the duration values to 255,0,255,0 (or any lesser values in the first bytes) this works fine. (some pop at refresh time, but accepttable and understandable)
But:
If I set the duration values to 0,1,0,1 (or any values using the second bytes) I get glitches on the pulse train.
I wouldn't think this is an extreme case of duty cycle (because it's 50/50 in both instances), nor frequency (since it's right in the middle of the given range of frequencies).
This can be readily seen on a scope or heard.
(My application is a crude music synthesizer)
Can anyone shed some light on what may be happening here.
Respectfully,
Michael Miller
Post Edited (hitsware) : 4/20/2007 3:30:32 PM GMT
Perhaps the pwmpal is not using glitch free fast PWM where the counter counts from bottom to top then back to bottom
Perhaps the pwmpal is not using a 16bit timer? and reloading an 8 bit timer?
perhaps the pwm is software/interrupt driven and not a hardware PWM timer?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
http://www.parallax.com/dl/docs/prod/acc/PWMPAL.pdf
>Perhaps the pwmpal is not using glitch free fast PWM where the counter >counts from bottom to top then back to bottom
I know nothing of that.
>Perhaps the pwmpal is not using a 16bit timer? and reloading an 8 bit timer?
I think it's supposed to be 16 bit, but it is strange that you load by bytes instead of words. The first and second bytes define the high time, and the third and forth define the low time. I did have the thought that perhaps the timer(s)? was responding byte at a time. I.E. to the first and third bytes and then the second and forth (rather than making words out of bytes and then resetting the '16 bit timers' all at once.....????
>perhaps the pwm is software/interrupt driven and not a hardware PWM >timer?
I don't know about that either.
Thank you for the input [noparse]:)[/noparse]
Post Edited (hitsware) : 4/19/2007 10:58:11 PM GMT
Thanks for posting that link to Parallax's pdf on the PWMPAL! It helped a lot.
I had always wondered how the PWMPAL controlled much of a motor since the only output was TTL level. The answer is now obvious: It doesn't. Additional circuitry is necessary. (But not too much.)
I have an application in mind for the future that will use a motor rated at 1.2A no-load all the way to 85A stall-torque. I wonder if the PWMPAL and some heavy duty electronics could possibly form the basis of a motor controller similar to, say, the MMBe? I have searched cyber-space far and wide and have found NOTHING that even comes close to the range I quoted. (It is a Banebot gear motor.) Of course, my actual machine would not approach·stall-torque too closely or things would break pretty quickly!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Some logic level mosfets and the right gate resistors (and perhaps attendent passive ?)
and you ought to be good to go ......
Assuming 50MHZ clock, and an SX 20 using the 8 bit clock with the prescaler gets you a 16 bit clock I think
Setting an interrupt for every 25 uS. Increment four 32 bit counters by one for each interrupt.
I would take the sixteen bit values the stamp sends, add then together and make that the TOP value then use the ON time value for the comparison value inside the interrupt. Switch the pin on when the counter hits 0. Switch off when the counter hits the ON value. Reset the counter to 0 when it hits TOP. Do this with all four counters and you have four channels of PWM output.
If this is the case, the new values sent should replace the old values at counter = 0 and not when they are sent. If the SX 20 operates like the SX28 then the timing should not glitch at all because exact timing can be done on this chip and I will bet the parallax folks used something similar that really should not have any glitches.
It will be interesting to see what Chris finds. I enjoy looking for stuff like this, if I had a PWMPAL I would be up all night trying to figure it out. Instead though, I think I may just try making a PWMPAL type co processor to run some servos I have when there was a good price on them, I have a box full of them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!
"The PWMPAL uses the SX20 to generate the PWM output via software. All the functions, including the serial communication are done via software. Take care."
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Post Edited (hitsware) : 4/20/2007 11:56:56 AM GMT
Should I try to email 'customer support' ?
This weekend I will try to do a PBasic demo of the problem.
It would probably be better if I used a scope
(for purposes of my demonstration)
rather than a speaker ...... Right ?
Post Edited (hitsware) : 4/21/2007 3:27:31 AM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Thanks. This seems to pretty well point out my problem:
x var nib'................................addendum to line 3 below
y var word'.............................with some frequencies it's worse
serout 0,6,[noparse][[/noparse]"!PWMSS",255]'........<If I set this value to 17
test'........................................(enabling only channel 1)
for x=0 to 15'............................the problem goes away.
y=255'.....................................But I need to run all the channels
debug dec ? y'.............................at once for my application.
serout 0,6,[noparse][[/noparse]"!PWMM1",255,0,255,0]'.(as would·most applications)
pause 200'.........................(Say a H bridge class D amplifier)
next
for x=0 to 15
y=256
debug dec ? y
serout 0,6,[noparse][[/noparse]"!PWMM1",0,1,0,1]
pause 200
next
goto test
Post Edited (hitsware) : 4/22/2007 2:41:18 PM GMT
This may better demonstrate the problem.
Thanks for any time you can spend on this.
x var word
d1 var byte
d2 var byte
serout 0,6,[noparse][[/noparse]"!PWMSS",255]
test
for x=255 to 256
debug cls
debug dec ? x
d1=x//256
d2=x/256
serout 0,6,[noparse][[/noparse]"!PWMM1",d1,d2,d1,d2]
pause 5000
next
goto test
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
While the debug reads 256 I get a squarewave but with intermittant glitches (almost like it is skipping pulses at times ?)
It seems to happen more often right after the transition from 255 to 256 and again towards the return transition BUT never during the 255 part. And sometimes towards the middle of the 256 part.
While listening the 'glitch' sounds like the refresh glitch.
I.E. like an intermittant refresh glitch (but this only happens during the 256 part)
If your scope doesn't pick it up you may want to try listening to the output. (the ears are more discerning than the eyes (and perhaps attendant instrumentation))
I don't know about my 'firmware'
I assume you mean the 'PWMPAL ID string' ?
I can't quite figure out how to set up the "3 byte array" and then write to it? and debug it?
This is 50/50 duty cycle in both the 255 and 256 parts.
Only the frequency is slightly changed.
From 20000/255=78.4 Hz
To 20000/256=78.1 Hz
It seems to be the extra byte that upsets the apple cart.
serout 0,6,[noparse][[/noparse]"!ID"]
serin 0,6,[noparse][[/noparse]STR version\3]
debug asc ? version
Returns: version = "1"
I was expecting 3 characters, so don't know if this is right?
The reason you’re getting only one character is because you’re using the ASC ? in your code. To see the string array you need to do the following:
DEBUG STR version
This will display the full 3-digit string array.
By the way, you last message somehow got posted three different times in two threads. I removed the extras for you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Thank You so much [noparse]:)[/noparse]
Returns: "1.1"
Post Edited (hitsware) : 4/29/2007 1:09:45 AM GMT
Worst case run all 4 channels (with the same instructions)
In parallel ...
I.E.....Could you safely go below 220 Ohm on the summing resistors ?
So no, you probably can't go below 220 ohm on the summing resistors. Look up Darlington Integrated Circuits.
So if I want to say drive a 45 Ohm speaker , then the 55 Ohm output impedance
(220/4) should cause no problems.
Thank You.....[noparse]:)[/noparse]