Darrel's SPWM and LCDOUT


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code?
    And maybe, maybe not. If your LCDs are slow and don't respond quick enough, then you might not be able to fit 10ms of display data inside of a 100Hz PWM loop without the code jumping out of the LCD portion, into the SSPWM portion, and back.

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Based on interrupt so jumps in out much more

    Quote Originally Posted by skimask View Post
    Code?
    And maybe, maybe not. If your LCDs are slow and don't respond quick enough, then you might not be able to fit 10ms of display data inside of a 100Hz PWM loop without the code jumping out of the LCD portion, into the SSPWM portion, and back.

    Although 10ms is the cycle duration still for software PWM of 64 steps it does enters the ISR at least 64 times in that 10ms. Correct me if I am wrong.

    However that should not be much problem since it is interrupt based. What happens when all the PWM channels have the same duty cycle.
    Regards

    Sougata

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I would suspect an R-M-W problem.

    What pins are the LCD on?
    And, which pins are the SPWM on?
    <br>
    DT

  4. #4
    Join Date
    Feb 2007
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    I would suspect an R-M-W problem.

    What pins are the LCD on?
    And, which pins are the SPWM on?
    <br>
    Hi Taylor, what means R-M-W ?
    Follow the LCD pins setting:

    Define LCD_DREG PORTD 'set LCD data bus port
    Define LCD_DBIT 4 'set data bus start
    Define LCD_RSREG PORTD 'set LCD Register Select port
    Define LCD_RSBIT 2 'set RS bit
    Define LCD_EREG PORTD 'set LCD Enalble port
    Define LCD_EBIT 3 'set Enable bit
    Define LCD_BITS 4 'set LCD bus size
    Define LCD_LINES 4 'set number of lines of LCD
    DEFINE LCD_COMMANDUS 2000 ' Set command delay time in us
    DEFINE LCD_DATAUS 70 ' Set data delay time in us

    and for the SPWM

    ASM
    SPWM_LIST macro ; Define PIN's to use for SPWM
    SPWM_PIN PORTB, 5, _DutyVar1 ; RED
    SPWM_PIN PORTB, 4, _DutyVar2 ; GREEN
    SPWM_PIN PORTB, 3, _DutyVar3 ; BLU
    SPWM_PIN PORTB, 2, _DutyVar4 ; WHITE
    SPWM_PIN PORTB, 1, _DutyVar5 ; SYNK
    endm
    SPWM_INIT SPWM_LIST ; Initialize the Pins
    ERRORLEVEL -306 ; Avoid Crossing page boundary "Message[306]"
    ENDASM

    and this is the main loop that work correctly for tree or four seconds, then seems that the display go out of sink and I see scrambled data as for the attached images.

    Forever:
    Lcdout $fe, $80, "MMMMMMMMMMMMMMMMMMM" ' move cursor to beginning of firt line
    Lcdout $fe, $c0, "VVVVVVVVVVVVVVVVVVV" ' move cursor to beginning of second line
    Lcdout $fe, $94, "HHHHHHHHHHHHHHHHHHH" ' move cursor to beginning third line
    Lcdout $fe, $d4, "YYYYYYYYYYYYYYYYYYY" ' move cursor to beginning of fourth line
    hSerout ["|"]
    pause 400

    Lcdout $fe, $80, "1111111111111111111" ' move cursor to beginning of firt line
    Lcdout $fe, $c0, "2222222222222222222" ' move cursor to beginning of second line
    Lcdout $fe, $94, "3333333333333333333" ' move cursor to beginning third line
    Lcdout $fe, $d4, "4444444444444444444" ' move cursor to beginning of fourth line
    pause 400
    GOTO Forever


    Also I have connected to ground the unused 4 input bit of the Optrex DMC20481 display and added a capacitor between VSS and VDD of the LCD, without visibile effect.

    Also consider that I have changed the display with other different brand and the symptom remain the same.

    Ciao

    Leo
    Attached Images Attached Images   

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    R-M-W is "Read-Modify-Write". It's the way PIC chips set an individual pin by reading the entire port, changing the 1 bit for the desired pin, then writing the whole port again. It can cause problems from time to time, but that is not the problem here. If the LCD and SPWM pins were on the same port it could have been. But I hadn't seen any code at the time, so I was guessing.

    And to keep from guessing again, could you post the whole program?

    I've run LCD's with SPWM before, so I don't think there's a common cause that I could point to. Hoping there's something else going on.
    <br>
    DT

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Maybe just a LCD clear... or PSU noise.. who know?

    LVP_NOT set to OFF.. huh... how bad things could go with it...
    Last edited by mister_e; - 2nd April 2008 at 01:30.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    What surprises me is that the entire line changes to a different character.

    If it was a timing problem from the interrupts, I'd think it would be more Random.
    <br>
    DT

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts