Allegro A6280 with PICBASIC


Closed Thread
Results 1 to 26 of 26

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    10

    Red face Allegro A6280 with PICBASIC

    HI there, I'm very new in picbasic and need to have some expert's advise in here. I wish to drive an Allegro A6280 with PIC16F628 by using shiftout. It seems that the data can be sent but the problem is I need to continuously pulse the clock with the code below to keep the A6280's PWM in order to run.

    clksend:
    high clk
    low clk
    goto clksend

    It seems that when I execute this command, my pic is busy with the code and I can't send the next data to the A6280. Anyone can give me a good suggestion in here as I'm lost in no where right now. Thanks in advise.

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

    Default

    Hi makson,

    Not the easiest way to drive 3 LED's is it?

    Well, I'm going to make it sound even harder.

    The 6280 has 10-bit PWM counters. So, to get around 100hz PWM to the LED's, you'll need about 100 Khz going to the clock input continuously.

    This can be easily acheived with the CCP module of the 16F628, but you can't use the HPWM command because the frequency is too high, so the registers will have to be set manually.

    Now for the hard part.

    Using SHIFTOUT to send the data may cause blinking when you update the PWM values. You would need to turn off the CCP module to allow SHIFTOUT to control the clock pin, shift the data out, then turn on the CCP module again to keep the clock going.

    It's possible that you may not even be able to see it because it will be more of an elongation of 1 PWM cycle, so you should try that way first.

    If it is noticable, you'll need to manually shiftout the data "In Sync" with the CCP clock cycles, which can be done with the TMR2IF flag. But try it with SHIFTOUT first to see if there's a problem or not. If there is, I can show you how to "sync" the data.

    HTH,
    DT

  3. #3
    Join Date
    Aug 2007
    Posts
    10

    Red face

    Dear Darrel,

    Thousand thanks to your reply. I really appreciate your help and I'm now going to try the method you mention. Before that, I've encountered that when the circuit is power on, there's 5V in the OEI pin of a6280. I don't really understand how to operate with OE. Do I need to sink it to ground with a resistor in order for the LED to light up? Please kindly advise. Thanks & hope u enjoy your weekend.

    Warmest Regards,
    Kevin Loh

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

    Default

    You can just tie the (OEI) Output Enable Input to ground. (No resistor required)

    If you want more control later, you can connect OEI to a PIC pin. Then HIGH is LED"s OFF, and LOW is LED's ON.

    But, you can still turn them ON/OFF by putting 0 or 1023 in the PWM register, so using OEI doesn't help all that much. Which is why I say, Just ground it.

    DT

  5. #5
    Join Date
    Aug 2007
    Posts
    10

    Default shiftout doesn't run as expected

    Dear Darrel, sorry for the trouble again, below is the code that I'm trying to work with but it doesn't light up the led as expected. Please kindly advise. Thanks in advance.

    @ DEVICE HS_OSC
    DEFINE OSC 4
    include "bs1defs.bas"

    CMCON = 7 ' PortA = digital I/O
    VRCON = 0 ' A/D Voltage reference disabled
    TRISB = %00000000 ' B.3=PWM,B.0,B.1,B.2 blink LEDs
    PR2 = 25 ' Set PWM for approximately 38KHz
    CCPR1L = 13 ' Set PWM Duty-Cycle to 50%
    CCP1CON = %00001100 ' Mode select = PWM
    T2CON = %00000100 ' Timer2 ON + 1:1 prescale

    d2pin var portb.0
    c2pin var portb.3
    latch var portb.4
    'oe var portb.1


    funct var byte
    rvar var word
    gvar var word
    bvar var word

    funct = 0
    gvar = %0011111111
    rvar = %0000000000
    bvar = %0000000000

    begin:
    high porta.0
    pause 1000
    low porta.0

    CCPR1L = 0
    shiftout d2pin, c2pin, 1, [funct\1,gvar\10,rvar\10,bvar\10]
    gosub latching

    pause 1000
    gosub bringpwm


    goto begin




    bringpwm:
    PR2 = 25 ' Set PWM for approximately 38KHz
    CCPR1L = 13 ' Set PWM Duty-Cycle to 50%
    CCP1CON = %00001100 ' Mode select = PWM
    T2CON = %00000100 ' Timer2 ON + 1:1 prescale
    return

    latching:
    high latch
    pause 500

    low latch
    return

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

    Default

    Putting 0 in CCPR1L just stops the output with a 0% duty cycle. The pin is still controlled by the CCP module.

    CCP1CON = 0   Will allow SHIFTOUT to use the PIN.

    And for 100Khz, use PR2 = 9 and CCPR1L = 5.

    DT

  7. #7
    makson2's Avatar
    makson2 Guest

    Unhappy how to use TMRIF2 to synch with serial data send

    Using SHIFTOUT to send the data may cause blinking when you update the PWM values. You would need to turn off the CCP module to allow SHIFTOUT to control the clock pin, shift the data out, then turn on the CCP module again to keep the clock going.

    It's possible that you may not even be able to see it because it will be more of an elongation of 1 PWM cycle, so you should try that way first.

    If it is noticable, you'll need to manually shiftout the data "In Sync" with the CCP clock cycles, which can be done with the TMR2IF flag. But try it with SHIFTOUT first to see if there's a problem or not. If there is, I can show you how to "sync" the data.

    HTH,[/QUOTE]


    Dear All, especially to DT,
    My brother had tried out the shiftout part of the codes, it worked perfectly. But to my calculation, that will be way to slow for our requirement, pausing to wait for the shiftout to complete will take impractically long in our project.
    You mentioned of using TMR2IF flag. Both me and my bro are new. I tried playing with the TMR2 to synch the data send: ie using the PWM as clock drive. But seems like my understanding of the TMR2 is wrong. Please correct:

    1. TMR2 counts from 00 to value in PR2 then resets.
    2. If TMR2 count reaches value in CCPR1L, then duty cycle is completed, hence going to the low cycle of the PWM and therefore our "clock"

    So my aim is to send the data on the duty cycle time via the data pin and prepare for the next data bit in the low time. I set the PR2 = 9 and CCPR1L =5 as in your earlier code with the above assumption. Thinking the Low time will be after TMR2 = 5, so I wrote:

    For Counter = 1 to 31
    while TMR2 <= 5 then
    high DataPin
    wend
    low DataPin
    next Counter

    Will this work?
    Didn't use TMRIF2 as I am still struggling to understand the interrupts.
    Can you show how to synch CCP with the TMRIF2 as you have mentioned?
    Thanks a lot.
    Heng.

  8. #8
    Join Date
    May 2008
    Location
    France
    Posts
    2

    Default multiple pixels

    Hello,

    I don't understand the principle of the shift register of the A6280. I need to control 20 RGB pixels separately. Is this principle work ? :

    1) Load RGB data of pixel 1
    2) Load RGB data of pixel 2
    ..) ...
    20) Load RGB data of pixel 20
    21) Latch
    22) Load RGB data of pixel 1
    ....

    Thank tou for your help

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

    Default

    If pixel 1 is the LAST one in the string, then yes.
    Send the data for all pixels then latch it. All pixels update at the same time.

    DT

  10. #10
    Join Date
    May 2008
    Location
    France
    Posts
    2

    Thumbs up

    ok, thank you for this fast reply,
    A6280 is perfect for my application : (low resolution screen).

    I'm going to test it soon

Similar Threads

  1. Picbasic VS C Compiler
    By koossa in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 11th October 2005, 21:44
  2. Replies: 22
    Last Post: - 12th July 2005, 17:39
  3. 1st 16F877A program in PICBasic
    By Borisw37 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th January 2005, 04:46
  4. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 10:04
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 21:19

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