Shop OBEX P1 Docs P2 Docs Learn Events
need help with problem — Parallax Forums

need help with problem

stilgarstilgar Posts: 47
edited 2012-12-08 15:41 in Propeller 1
After 12-20 attempts to get this working that all ended in chaos or shutdown, I need help.

This program worked with the intended hardware. But now I need to get it to work with a older piece of hardware.
A little background...

The program was written for hardware that has 16 leds, individuality controlled. (led pins P27-P12)
The old hardware uses a led matrix of 8 leds in 2 matrix . (led pins P27-P20, control pins P18-P19), (the control pins connect each matrix to ground through a npn transistor and 120 ohm resistor.)



What I need to do is change the output to control the matrix.
matrix normal operation..

High on P18, cycle High through P27-P20.
High on P19, cycle High through P27-P20

reverse the cycle..
High on P19, reverse cycle High through P27-P20.
High on P18, reverse cycle High through P27-P20.

I have added notes as to what parts need to do and a copy of the V2 version program, If you would add notes, so I can see what your changes do.

Thankyou,
stilgar

V2 upgrade - Archive [Date 2012.12.04 Time 14.50].zip

Comments

  • JonnyMacJonnyMac Posts: 9,108
    edited 2012-12-04 15:23
    Do you need brightness control of each LED or just on/off?
  • stilgarstilgar Posts: 47
    edited 2012-12-04 16:24
    yes please, I need the pwm brightness control for each led and the trailing effect (persistence, rtime2). the sweep speed is set by rtime1.

    thanks
    stilgar
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-04 18:17
    I think the only part of the code that needs to change is the "led_pwm_1" object. I assume you realize the LEDs will only be half as bright by splitting them into two sections?

    I'll give this a shot and try to post something tomorrow.

    Which of the cathode control pins (18&19) control the LEDs that had been controlled by pins 12 - 19?
  • stilgarstilgar Posts: 47
    edited 2012-12-04 18:48
    After these posts, I returned to the hardware and found I had built the trailing effect in the hardware, not software.

    So all I need is the multiplexed pwm driver, JonnyMac. If you are still up to it.

    Duane Degn, I have attached a schematic of the LED matrix.

    Thanks
    stilgar

    V2 led schematic.jpg
    896 x 833 - 142K
  • stilgarstilgar Posts: 47
    edited 2012-12-04 19:36
    I did a better exam of the hardware and what the program needs to do for this project.

    Sweep speed controlled by pot on P4.

    After chip start up...
    1. Center LED (P23) fads from off to full brightness.
    2. LEDs sweep to left edge (P20).
    3. LEDs sweep full across to right (P20-P27) (Keep in mind the LED matrix).
    4. LEDs sweep full across to left (P27-P20) (Keep in mind the LED matrix).
    5. Repeat 3. and 4. forever.



    thanks
    stilgar
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-04 19:37
    Okay, here's my attempt.

    I didn't really try to understand what the code was doing, I just looked for the section that set pins high and only set half the pins high at a time.

    The code isn't user friendly. The pin masks are hardcoded.

    I modified three sections of the LED object. Here's the first modification.
    'mov             dira, pins         ' commented out by dwd
    '--------- start of added code section by Duane Degn -------------            
                  or              dira, anodeMask
                  or              dira, lowLedsCathodeMask
                  or              dira, highLedsCathodeMask
    '--------- end of added code section by Duane Degn --------------- 
    

    The above just sets the masks as outputs. I commented out the original direction setting code.

    The meat of the change is in this next section. Again, I commented out the original code (two lines this time).
                  'waitcnt         time, delay        ' commented out by dwd 
                  'mov             outa, accum        ' commented out by dwd
    
    '--------- start of added code section by Duane Degn -------------           
                  waitcnt         time, halfDelay     
                  mov             temp, accum
                  and             temp, anodeMask
                  or              outa, temp
                  andn            outa, lowLedsCathodeMask
                  or              outa, highLedsCathodeMask
                  
                  waitcnt         time, halfDelay
                  mov             temp, accum
                  shl             temp, #8
                  and             temp, anodeMask
                  or              outa, temp
                  andn            outa, highLedsCathodeMask
                  or              outa, lowLedsCathodeMask
    '--------- end of added code section by Duane Degn ---------------
                  djnz            wavepart, #:waveloop
    

    The above code breaks up the "accum" mask into two sections and turns on eight bits at a times.

    The final section includes the hardcoded variables.
    delay   long  1200   ' Actual PWM carrier, period will be delay * wavemax   orig..600 1200 fer 16,.. 1200 was start
    wavemax long  64     ' number of pwm sub-segments
    '--------- start of added code section by Duane Degn -------------
    halfDelay               long 600
    anodeMask               long %1111_1111 << 20
    lowLedsCathodeMask      long %1 << 18
    highLedsCathodeMask     long %1 << 19
    temp                    res 1
    '--------- end of added code section by Duane Degn ---------------
    ' Make sure res elements always come last
    pins       res   1
    
    

    If the wrong set of eight LEDs light up switch the values for lowLedsCathodeMask and highLedsCathodeMask.

    It's always risky posting untested code. I hope it works.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-04 19:42
    I attached the code to the above post but when I previewed the post the forum software kind of went crazy. I was able to restore the post but apparently the attachment was lost. I don't want to risk editing the above post, so here's the attachement.

    Are you sure the trailing effect is done in hardware? The PASM driver looks like it takes care of that.

    Let me know if this works.
  • stilgarstilgar Posts: 47
    edited 2012-12-05 05:28
    Duane Degn,

    here is a schematic of the hardware

    V2 led schematicA.jpg


    After careful consideration, I have come to the realization that it would be a waste of time to mod the V3 programing, so I am working on a new program for this hardware.
    Thanks to all that have helped in this.

    thanks,
    stilgar
    1024 x 1024 - 51K
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-05 06:04
    stilgar wrote: »
    I have come to the realization that it would be a waste of time to mod the V3 programing

    I assume VDD is really Vss in the schematic?

    V2 has the line:
    persistence_ := rtime2 / 7000         ' starting point 7000
    

    if you change it to:
    persistence_ := 0
    

    The software wont add persistence.

    Though without adding software persistence, the program is trivial.

    Did you try my modification?
  • stilgarstilgar Posts: 47
    edited 2012-12-05 11:47
    oops, yes VDD is Vss.

    I tried your mod, it appeared ALL LEDs came on at the same time, but went out after about 2 sec. The battery was dead. I will try again when I get neww battery.
  • stilgarstilgar Posts: 47
    edited 2012-12-07 16:12
    I decided to code a different route. so the mods are not needed. My problem tonight is in the PUB called death.
    All the other code works correctly. I have it sweeping a led back and forth.

    What I am trying to do is, when a button is pushed it causes the leds to slow down and stop. the led that it stops on then fades.
    I keep getting the same thing, when the button is pushed and held it ALWAYS stops on led 1(P20) and don't fade.

    what did I do wrong, or miss ?

    thanks
    stilgar

    wakeup - Archive [Date 2012.12.07 Time 19.01].zip
  • kuronekokuroneko Posts: 3,623
    edited 2012-12-07 23:16
    stilgar wrote: »
    What I am trying to do is, when a button is pushed it causes the leds to slow down and stop. the led that it stops on then fades.
    I keep getting the same thing, when the button is pushed and held it ALWAYS stops on led 1(P20) and don't fade.
    For starters rtime is a local variable in your death method, i.e. it's not the one controlled by the RCTime3 object. If this is supposed to be the same variable either make it global so all methods can access it or pass it by reference as a method parameter.
  • stilgarstilgar Posts: 47
    edited 2012-12-08 09:46
    a global variable, still a bit fuzzy on use, but if I understand correctly I need to change the variable name to " _rtime " to make it a global?
    and should be placed in the " VAR " section


    thanks,
    stilgar
  • kuronekokuroneko Posts: 3,623
    edited 2012-12-08 15:41
    stilgar wrote: »
    ... if I understand correctly I need to change the variable name to " _rtime " to make it a global?
    Name it whatever you want. Its appearance in the VAR section is the important bit. Obviously you should then remove the local instances. Besides you're already using global variables without underscore.
Sign In or Register to comment.