Shop OBEX P1 Docs P2 Docs Learn Events
variable exceeded ram errors ? — Parallax Forums

variable exceeded ram errors ?

turboturbo Posts: 24
edited 2008-03-14 23:49 in General Discussion
Im having a problem with this PWM code im trying to get working it needs alot of work i know im sure this could be done more efficiently but im stumped on how to do it it works with two stages of PWM but as soon as i put all six stages in i get the "variable exceeded ram " errors any help on this would be wonderful.

Comments

  • BeanBean Posts: 8,129
    edited 2008-03-14 11:05
    Turbo,
    Make your variables into arrays. Arrays are stored in a different area then regular variables.

    So instead of:
    Duty             VAR    BYTE  'Variable to hold current duty cycle starts at 0
    Duty1            VAR    BYTE
    Duty2            VAR    BYTE
    Duty3            VAR    BYTE
    Duty4            VAR    BYTE
    Duty5            VAR    BYTE
    Counter          VAR    BYTE
    Counter1         VAR    BYTE
    Counter2         VAR    BYTE
    Counter3         VAR    BYTE
    Counter4         VAR    BYTE
    Counter5         VAR    BYTE
    RampCycles       VAR    BYTE
    RampCycles1      VAR    BYTE
    RampCycles2      VAR    BYTE
    RampCycles3      VAR    BYTE
    RampCycles4      VAR    BYTE
    RampCycles5      VAR    BYTE
    StepCount        VAR    BYTE
    StepCount1       VAR    BYTE
    StepCount2       VAR    BYTE
    StepCount3       VAR    BYTE
    StepCount4       VAR    BYTE
    StepCount5       VAR    BYTE
    
    


    Use

    Duty             VAR BYTE (6)
    Counter          VAR BYTE (6)
    RampCycles       VAR BYTE (6)
    StepCount        VAR BYTE (6)
    

    Then you just need to add parens in the code. "Duty(0)" instead of "Duty", and "Duty(5)" instead of "Duty5".

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com



    Post Edited (Bean (Hitt Consulting)) : 3/14/2008 11:10:40 AM GMT
  • turboturbo Posts: 24
    edited 2008-03-14 18:09
    Thanks Bean i will try that later. One more question i have DIP switches set up for the rampcycles input what i was wondering is can i have the dip switches setup so two switches will have four ramp cylce rates instead of having each switch take up an input ?
  • BeanBean Posts: 8,129
    edited 2008-03-14 18:21
    Sure just do something like:

    cycles = 0
    cycles.0 = switch1
    cycles.1 = switch2

    Now the variable "cycles" will have a value for 0 to 3 depending on how you have the two switches set.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.iElectronicDesigns.com

    ·
  • turboturbo Posts: 24
    edited 2008-03-14 20:08
    One more question on my input it is a pot so how can i index a window for each potval so it can be between a certain value ?

    Like in my code where it is


    If poval = 120 THEN
    GOSUB G1

    Something like this

    If potval 120 to 140 then
    GOSUB G1

    This way it will fit inside this window and trigger everytime.

    How would i do this?
  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-03-14 21:35
    SX/B only allows one expression per line, so you could code it like this:

    IF potVal >= 120 THEN
      IF potVal <= 140 THEN
        GOSUB G1
      ENDIF
    ENDIF
    
  • turboturbo Posts: 24
    edited 2008-03-14 23:49
    Wonderful you guy are great . It would have took me years to figure this out thanks. LOL
Sign In or Register to comment.