Shop OBEX P1 Docs P2 Docs Learn Events
'Public' variables - — Parallax Forums

'Public' variables -

TE44TE44 Posts: 42
edited 2007-01-24 19:21 in Propeller 1
Can variables be·shared between and updated from different methods and different cogs ? Similar to a Public variable in VB ?
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-24 05:16
    TE44,
    That depends on whether they're in the same object. Variables (VAR or DAT sections) are known by all methods in the object. It doesn't matter what cog(s) is running (you can have multiple cogs running on the code in one object). Variables cannot be referenced from another object. You can create methods in an object that make a variable or the address of a variable available to other objects like
    VAR long X
    PUB getX
      return X
    PUB setX(value)
      X := value
    PUB getXaddr
      return @X
    
    
  • TE44TE44 Posts: 42
    edited 2007-01-24 16:24
    Mike,
    Yet again ... spot on ...thank you.... your help is much appreciated .. this month was spent entirely playing around with the propellor and I am finally able to do the many things I set out to do ... thanks to your help.

    As a side note : I have also managed to kill 2 40pin dil props in breadboard - seems strange - even though I had regulators & diodes in reverse across the supply & caps etc (all as recommended and more) they worked fine and programmed ok but when I removed the power and reapplied it the props were dead - each time though I had ascreen attached as per schematics (except for led's and associated resistors) - do the LED's in the schematic play some additional role in dissipating unwanted spikes ? - or is this just a coincidence. Removing power this way (same power supply) using the demo board does not cause any difficulty. Is there some additional 'soft start/stop' circuitry I have missed ? I find this strange as all good practice was followed with respect to power supply stage.

    Has anyone else killed a prop for what is an unknown reason (at least unknown for the moment)?

    Best to post this as a new thread

    Post Edited (TE44) : 1/24/2007 4:54:49 PM GMT
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-01-24 19:21
    As stated in the other thread, you'll have to post a schematic of your setup. The Propeller is fairly indestructable compared to other microcontrollers, for instance I have shorted all pins together while driving them to the opposite value, we have zapped the IO pins with 7.5kV and we have and sourced 3 watts of power through it without destroying the chip. There is only one chip that I have broken, somehow P0 no longer works (really wish I knew what did it, like your experience it worked until I picked it up one day, but even then the chip works just as expected except for P0 sourcing alot of current, but I had to exclude it from my sample set for current measurements).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
Sign In or Register to comment.