Shop OBEX P1 Docs P2 Docs Learn Events
COG Stalling?? — Parallax Forums

COG Stalling??

matb_ukmatb_uk Posts: 16
edited 2007-10-03 02:05 in Propeller 1
Can individual cogs·or io pins stall?

Basically i'm building a small computer based on the Prop which reminds me at points throughout the day to do certain tasks.
It's paired up to a HD44780 16*4 screen with a PS/2 port and a small piezo buzzer for alarm sounds.
I made a small loop to flick a port on and off a number of times per second and the buzzer is connected to that port and therfore makes a sound. Depending on the duration between on off pulses, the tone changes. This works fine for the most part but if i call the loop a few times it seems to lock and play the sound indefinately and sometimes i get garbage displayed on the display.·Now i accept that there could well be a fault in my wiring (Very little electronics experience) but there is nothing else attatched to the buzzer i/o port and i've checked that it's not shorting to an adjacent pin.
The only over thing of note is that i'm using a 5v battery pack for power which creates a 5v rail and off that 5v rail is a (150ma Max) voltage regulator creating a 3v rail which the Prop get's it's power from. I thought that 150ma should be enough to feed two to three cogs running at PLL4 (20 Mhz).

Any ideas?

Comments

  • Mark BramwellMark Bramwell Posts: 56
    edited 2007-10-01 15:19
    Can you cause it to occur on demand? If you were to do that function 5 times in a row, will it always fail at least once? If yes, disconnect the buzzer and try it again. I wonder if the buzzer is causing back-feed voltage bumps into the chip causing it to hic-up. If disconnecting the buzzer makes the problem go away, we then concentrate on a better way of connecting the buzzer.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-01 15:33
    Make sure you have filter capacitors on the input and output of your 3.3V regulator. 150ma should be more than enough for the Propeller.
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 17:51
    I tried a different segment of code to play a different sound and while it doesn't seem to freeze now it does seem to continue playing the sound loops forever. I've included the code for the sound below. If i call the routine supplying a value of 1-3 for the Times parameter it plays fine. Sending a times value of 4 or more and it loops forever for some reason.

    Excuse the variable names. This was a test bit of code.

    PUB PlayTone(Times) | ssx, ssy, pinx
    
        pinx:=7
        dira[noparse][[/noparse]pinx]~~
        ssy:=0
        
        repeat until ssy==times
            ssy++
    
            ssx:=1
            repeat until ssx==50
                outa[noparse][[/noparse]pinx]:=1
                waitcnt(40_700 + cnt)
                outa[noparse][[/noparse]pinx]:=0
                ssx++
    
            ssx:=1
            repeat until ssx==50
                outa[noparse][[/noparse]pinx]:=1
                waitcnt(38_700 + cnt)
                outa[noparse][[/noparse]pinx]:=0
                ssx++
            
            ssx:=1
            repeat until ssx==50
                outa[noparse][[/noparse]pinx]:=1
                waitcnt(36_700 + cnt)
                outa[noparse][[/noparse]pinx]:=0
                ssx++
    
            waitcnt(4_000_000 + cnt)
    
    
    



    I'm going to try the filter capacitors now.

    Post Edited (matb_uk) : 10/1/2007 7:07:24 PM GMT
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 18:00
    Also i've tried it with an LED connected rather than a buzzer and tried two calls calls to PlayTone(2) and it does the same thing.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-01 18:49
    What kind of batteries deliver 5V? Lithium is 3.6V; 4x1.5 Alkaline = 6 V, 4x NiMH = 4.8V+
    Do you use a LowDrop regulator? Most likely, there are hardly any others...

    How large is the resistor you have connected the buzzer and the LED by?
    The duty cycle of your signals is>90% so a lot of current might flow all the time (40mA?)

    What you describe looks like a reset due to a "brown-out" due to voltage breakdown.
    You have connected brown-out enable to GND?

    In any case add a 100nF between Vss and Vdd of the Prop. Alas, Parallax does not stress this recommendation from more than 40 years practice...
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-10-01 18:54
    math_uk,

    Your program will be much easier to read here if you get rid of the <tab>s (which the forum server ignores) and enclose the whole thing in [noparse][[/noparse]code] ... [noparse][[/noparse]/code] tags. You can edit your posting: no need to create a new one.

    -Phil
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 18:59
    At the moment i'm using the battery compartment on one of those 250in1 electronics lab type things. It takes six AA batteries and you can choose 1.5, 3, 4.5 etc upto 9. It's actually delivering 4.3v (from 4.5v port) but i plan to use 4x nimh AA's. According to my multimeter that our outputting 1.3v each so 5.2v for 4.

    I've added a 0.47uf cap from the 3v rail to ground but this didn't help.

    By the way, the voltage regulator i've used is a TS2950CT-3.3
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 19:04
    I removed the <tab>'s now theres no indenting. Arggh.

    EDIT: Helps if you use [noparse][[/noparse]Code] instead of <Code>
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-01 19:31
    (1) If you meassure 4.3 V at the input of the regulator (from 3 batteries) that is no good at all... they are over! Use the four rechargeables instead!

    (2) All linear regulators need an capacitor - best close to their pins. It starts with 10myF smile.gif
    Some will improve by a additional smaller cap at the input, even when you use batteries..

    (3) The recommended 100nF should be located near the pins of the Prop. This is something different..

    I had more questions...
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 20:21
    Sorry i'm just pulling the remainder of my hair out at the moment.

    I have a 10k resistor connected to the buzzer and i've implemented the 100nf as suggested.

    Now the big issue is... Have i damaged my Prop (I shouldn't be allowed to play with electrical equiptment!!)

    I've defined three stacks Stack1[noparse][[/noparse]9]... Stack3[noparse][[/noparse]9] in VAR

    in my PUB Main i have cognew(Display, @Stack1) and this start my LCD loop and displays the value of seconds variable.
    i then have cognew(Clock, @Stack2) to update seconds variable every second.

    This doesn't seem to work yet if i change @Stack2 to @Stack3 it works??
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-01 20:24
    It may be that your stack spaces are too small. Try changing them to 20 or 30 levels. You may need less, but it's better to start with excess.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-01 20:26
    9 seems too small a number, so they overlap! Leaving Stack2 out gives it more room.

    Substitute all 9s by 20s smile.gif
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 20:34
    Great, that worked. Thanks deSilva. I'm wondering if this might have been the cause of some of my problems. To be honest i didn't really know what the value '9' for the stack really meant. I guess i just picked that value from a piece of example code.
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 20:36
    One last question. Since adding a cap between vss and vdd it seems that the prop doesn't reset itself after it is programmed so i have to pull the power to reset it manually. I noticed that both sides of the chip have vss and vdd. Should both sides have the cap?

    EDIT: Really sorry but it seems adding a wait after clearing the LCD it works fine. Also after adjusting the stack values of my originally problematic code seems to have made a big difference.

    Post Edited (matb_uk) : 10/1/2007 8:43:58 PM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-01 20:45
    AFAIK this has never been sufficiently discussed here...

    (a) No it will suffice to connect it at one side, or even between the sides which is quite convenient..

    (b) GND and Vdd are connected internally, buit the question is: for how much current. It might be not so good an idea to connect a regulator able to - say - deliver 3 A at one side and draw 2 A out of the other side of the Prop smile.gif.

    I generally "mesh" the voltage as much as possible on the breadboards
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-01 21:16
    Thanks to Mike as well. I didn't see your post at first.
  • OzStampOzStamp Posts: 377
    edited 2007-10-03 02:03
    Hi

    The cogs may need oiling occasionally.. a little SINGER oil is fine..

    ron
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-03 02:05
    @deSilva: Wow...I never thought of using the Prop as a power bus! But I guess if it's possible, someone will try!

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


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
Sign In or Register to comment.