Shop OBEX P1 Docs P2 Docs Learn Events
Duty - Diff Question — Parallax Forums

Duty - Diff Question

TappermanTapperman Posts: 319
edited 2010-01-17 02:00 in Propeller 1
I'm new to the propeller (got it for XMAS) and I'm going through the PE labs.

I'm a little confussed about the operation of the DUTY mode (page 133 of PE).

According to the docs, the BPIN should be opposite the APIN at all times in the DUTY-DIFF mode.· But when I modified the LedDutySweep.spin and ran it.· The led on P4 went from off to on, gradually.· Then switched off and the P5 LED switch on full bright and gradually went dim.

Shouldln't they both operate at the same time ... but opposite in brightness?· (I attached my spin file I'm using)

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-16 00:58
    I ran your program on my Prop Demo Board (using A16 and A17 instead of A4 and A5) and got the results you expected to get: one gradually dimming while the other gradually brightened. How do you have your LEDs hooked up?

    -Phil
  • TappermanTapperman Posts: 319
    edited 2010-01-16 01:47
    both are connected from the port pin through a 470 ohm resistor to the anode of the LED. Then the cathodes to ground. Maybe I should retry mine on A16 and A17?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-16 02:16
    It shouldn't matter which pins you use. Are these blue or white LEDs by any chance?

    -Phil
  • TappermanTapperman Posts: 319
    edited 2010-01-16 03:15
    Well, it didn't matter which pins I used ... I got the same results ... could I have a bad chip? That seems unlikely, since all the other projects work okay! But, this is the first experiment I encountered that uses the timer furnctions of the COG's ... Here is a video of the result's I got from running the program I uploaded.

    There is no sound .. but I show my laptop, and press F10 to load the program into my PROFESSIONAL PROPELLER BOARD - REV A. and as you can see ... the 1st LED goes from dim to birght .. then off, and second LED goes from full ON to off ... not at the same time ... why?



    Post Edited (Tapperman) : 1/16/2010 3:21:59 AM GMT
  • SamMishalSamMishal Posts: 468
    edited 2010-01-16 03:43
    The problem is not with the propeller....nor with your program.....the problem is with the PPDB....

    The PPDB uses blue LEDs and these have a 2.5V drop.....that means that the LEDs will only light up after
    the DAC is outputting 2.5V and higher.

    So since the DAC on the First pin is going from full high to low the LED will be lit and will start dimming until the voltage drops to below 2.5V
    The other pin is going low to high so the LED won't light up until the DAC is outputting 2.5V and then will start to brighten.

    So the end result is that the LEDs will not be in synch as they should be. Since the high pin will be operating with 0.8V range
    while the low one will have to go to 2.5V before it starts....so they end up not being in synch.

    What you need is to limit the DAC to go from full on to 2.5 and from 2.5 to full on....then you will see them in synch again.
    You cannot do this since you are using Diffrential Duty mode....so the pins cannot be controlled separately.....just do the below.

    Another thing you can do is wire up some normal red LEDs instead of using the blue ones.

    But that is the beauty of the PPDB is that you do not have to do that.....but....just be aware of the limitations.
    I was caught by that at some stage and it drove me mad until some good people on this forum pointed out the errors of my ways....


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com


    Post Edited (SamMishal) : 1/16/2010 6:17:42 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-01-16 06:41
    Tapperman,

    I think Sam is right. That's why I asked about the color. The LEDs I ran your program with were yellow, with a much lower forward voltage. The only fly in the ointment is the fact that the LEDs are being pulsed at full voltage; they're not running from a variable voltage. But I suspect that the LED junction capacitance is high enough to act as a low-pass filter in concert with the current limiting resistor, effectively limiting the peak voltage that the LEDs see at low duty cycles.

    I'm dead certain that there's nothing wrong with either your hardware or program.

    -Phil
  • SamMishalSamMishal Posts: 468
    edited 2010-01-16 17:55
    Phil Pilgrim (PhiPi) said...·But I suspect that the LED junction capacitance is high enough to act as a low-pass filter in concert with the current limiting resistor, effectively limiting the peak voltage that the LEDs see at low duty cycles.
    That is exactly what is happening....it drove me crazy for a while until I posted here and a few people pointed out the 2.5V drop on blue LEDs....and just like you I thought ....but the DAC outputs full 3.3V on/off..... and what clinched was the difference in behavior between the Propeller Professional Development Board and the Propeller Demo Board.
    ·
    In the PDB the LED are wired very close to the Propeller pins and thus very little capacitance. In the PPDB the breadboard and the wires etc cause enough of a capacitance to cause filtering.
    ·
    The effect is also more marked since the DAC operates at full 80MHz pulses....which exasperates the effect.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
  • SamMishalSamMishal Posts: 468
    edited 2010-01-16 18:08
    Just to make sure ..... I just ran your program as is on the PPDB and it did exactly as you describe.

    I then ran it on the PDB (changing pins to the LED pins 16 and 18) and it ran as it is supposed.

    I ran it on the PPDB again with pins 16 and 18 and again it was out of synch....

    So it is CERTAIN that it has to do with the capacitance and the 2.5V drop on the blue LEDs.

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
  • TappermanTapperman Posts: 319
    edited 2010-01-16 21:30
    Thanks guys,

    Thankyou SamMishal for wiring it up on your board, and confirming my result ... Being a newbee, your confidence gets shakin by these tiny little glitches. But this forum is a fantastic asset to all like myself who, on occasion, find themselves groping around in the dark.

    Now forgive me for asking a stupid question, but how would I get it to do the same thing ... but at a lower freq?

    It's PHSA that gets adjusted by FREQA correct?· And my output is comes from the Carry bit, correct?· Why would the resulting signal be so high?

    Post Edited (Tapperman) : 1/16/2010 9:38:37 PM GMT
  • SamMishalSamMishal Posts: 468
    edited 2010-01-17 02:00
    Tapperman said...

    Now forgive me for asking a stupid question, but how would I get it to do the same thing ... but at a lower freq?

    It's PHSA that gets adjusted by FREQA correct?· And my output is comes from the Carry bit, correct?· Why would the resulting signal be so high?
    In the Duty mode what is happening is that you are pulsing high for one clock tick then the pin goes low every time the overflow bit of the PhsA register goes high due to FrqA being added to it.
    ·
    What makes the pin appear to have a certain voltage is the how OFTEN·the Overflow bit of the PHSA register goes high and that depends on the number in the FrqA register so that when it is added it makes the PhsA register overflow less or more often so as to make an average voltage level.
    ·
    So there is no way to control the FREQUENCY of the duty mode. It will always work at the CLOCK speed. However, this is a very advantageous method in that it is Set-And-Forget operation. And to change the DAC output you just change the FrqA register and IMMEDIATELY (almost) the DAC output is changed. It is SIMPLE and EFFECTIVE.
    ·
    If you need another way to produce a DAC you can use the PWM method....read about this in the PEK manual.
    ·
    With the PWM you are setting the Pin high for a certain TIME and then LOW for a certain other time. You can control the frequency by controlling the Total On+Off time (period) and you control the DAC voltage by controlling the RATIO of the On to the Off time (DUTY).
    ·
    However, the disadvantage of this method is that it is NOT a Set-And-Forget action. Also you need to do more work in figuring out the On and Off times. Additionally, when you want to change the DAC level it is not an immediate change since you have to wait for the PERIOD to finish before you can then change the Duty.
    ·
    But with the PWM you can control the frequency of the on/off and thus can lower the speed of the whole thing and operate at lower frequencies. Sometimes this is needed with things like Servos for instance.
    ·
    Which method you use depends on the situation. Duty mode can be very effective. PWM is effective too and might be necessary in certain situations

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com


    Post Edited (SamMishal) : 1/17/2010 2:09:29 AM GMT
Sign In or Register to comment.