I2C with 4 digit 7 segment display.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times
Contact:

I2C with 4 digit 7 segment display.

Post by PIC-ER »

Hello,
I have read nearly all on I2c examples and am still stumped.
I am using a PIC16F677 and want to connect it via I2c to a SAA1064 to a 4 digit 7 segment display. On the hardware side I am OK, but just can't wrap my head around how to start a flowcode program for it.
If anyone can help with a basic example of one switch input , and every press increments the display by one.
If i remember, i can only create and simulate the flowcode, but will have to upgrade to compile it as i have a student version. Please correct me if i'm wrong.

Thanks.

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by DavidA »

Hello,

Have you looked at the 7seg examples on the learning centre?

http://www.matrixmultimedia.com/resourc ... php?id=349

(also please no all caps titles!)

PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by PIC-ER »

Hi ,
Thanks for replying, but I am looking for I2C info for 7 segment displays. As my previous post says.
I am clear on the regular connection of displays to a controller.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by Enamul »

Hi

You said you are clear about hardware. so please mention which mode you are using dynamic or static? If possible post an schematic of the 4-digit seven segment connected with the chip SAA1064 and also with PIC.
Enamul
University of Nottingham
enamul4mm@gmail.com

PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by PIC-ER »

Hi Enamul,
Thanks. This is what i want to do, only difference i will have three 7-segment displays instead of one as in the picture. The test chip i am using right now is a PCA9532 (address-11000000) that is wired to a PIC16F677 at pins RB4 and RB6.(SDA, SCK).
Not really sure about the mode.
In flowcode i don't know what the entries are to be in the I2C component macros and their sequence . Eventually i will also have two pushbutton inputs to display numbers (say 1-10). and also count number of pulses.
Any pointers to get me going is appreciated.
I2C-Controlled-7-Segment-LED-Display.JPG
I2C-Controlled-7-Segment-LED-Display.JPG (24.13 KiB) Viewed 7168 times
Thanks,
PIC-ER

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by Enamul »

Hi
Here is a schematic for starting point. Start with 8 LEDs and let's see if we can control these LEDs we will be able to control rest.
PCA9532.png
(14.61 KiB) Downloaded 3082 times
You have to follow the following programming sequence...

Code: Select all

'****************************************************************
'*  Name    : i2c comms test with led driver                    *
'*  Author  : Cody Finden                                       *
'*  Version : 1.0                                               *
'*  Notes   : SOFTWARE FOR A 16F887 TO CONTROL A PCA9532        *
'*          : OVER THE I2C PROTOCOL                             *
'****************************************************************

#config
 __CONFIG _CONFIG1, _HS_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF 
 __CONFIG _CONFIG2, _BOR40V & _WRT_OFF 
#endconfig


'PCA9532 Control Registers
psc0 con 000010   'frequency prescaler 0 (PERIOD = (PSC0 + 1) / 152)
pwm0 con 000011   'PWM register 0        (0-255 PWM)
psc1 con 000100   'frequency prescaler 1 (PERIOD = (PSC1 + 1) / 152)
pwm1 con 000101   'PWM register 1        (0-255 PWM)
ls0  con 000110   'LED0 to LED3 selector
ls1  con 000111   'LED4 to LED7 selector
ls2  con 001000   'LED8 to LED11 selector
ls3  con 001001   'LED12 to LED15 selector


DEFINE OSC 20                   '20MHz crystal
'DEFINE I2C_SLOW 1 
'DEFINE I2C_SCLOUT 1


ANSEL =     000000           'no analog, all digital!
ANSELH =    000000
TRISA =     000000           'all ports output
TRISB =     000000
TRISC =     000000
TRISD =     000000


SDA         VAR PORTD.3         'i2c data line
SCL         VAR PORTD.2         'i2c clock line
led         var portc.5         'led for testing
RST         VAR portc.6         'pca9532 reset pin (active low)
addr        var byte            'pca9532 address storage var
duty0       var byte
duty1       var byte


INIT:
duty0 = 0
duty1 = 255
PAUSE 400   'let hardware settle
RST = 0     'reset pca9532
pause 10
SDA = 1     'i2c pins high on startup
SCL = 1
RST = 1     'pca9532 on

'PCA9532 i2c address(7 bits + 1 bit for R/W) 
'Slave address is 1100(A2)(A1)(A0) + (R/(/W))
'In my setup A2 is pulled low, A1 pulled low, A0 pulled low
addr = 000000  

MAIN:
    
    I2CWRITE SDA,SCL,ADDR,psc0,[$00]  'set both pwm prescalers to max pwm freq
    I2CWRITE SDA,SCL,ADDR,psc1,[$00]
    
    duty0 = duty0 + 1                        'increment duty0 for pwm0
    duty1 = duty1 - 1                        'decrement duty1 for pwm1
    
    I2CWRITE SDA,SCL,ADDR,pwm0,[duty0]       'set duty cycle on pwm0
    I2CWRITE SDA,SCL,ADDR,pwm1,[duty1]       'set duty cycle on pwm1
    
    I2CWRITE SDA,SCL,ADDR,ls0,[101010]    'enable led0-3 with pwm0
    I2CWRITE SDA,SCL,ADDR,ls1,[111111]    'enable led4-7 with pwm1
    
    if duty0=255 then 'restart count on overflow
        duty0=0
    endif
    if duty1=0 then 'restart count on overflow
        duty1=255
    endif
    
    pause 5     'delay for viewing pleasure
    
'    led = 1     'blink led for feedback
'    PAUSE 50
'    led = 0
'    pause 50

goto main
Enamul
University of Nottingham
enamul4mm@gmail.com

PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by PIC-ER »

Thanks Enamul,
I shall fire up my circuit and test the code out. i found a couple of similar code , but eventually will have to learn how to put it in Flowcode as my "C" is not the best. :(
I shall keep you posted.

Regards,
PIC-ER.

PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by PIC-ER »

I found the attached code and hacked it to match my PIC and Slave as in the schematic above, but still is missing something . Any help is appreciated. :(
Thanks.
Attachments
PCA9532_v2_I2C.fcf
(14.36 KiB) Downloaded 298 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by Enamul »

Hi
Can you please post the link where you get this Flowcode from? This has some problem like Cod7Seg[1] = 0x55 is initialized but other locations are not initialized so how you will send that to slave?
Enamul
University of Nottingham
enamul4mm@gmail.com

PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by PIC-ER »

Thanks Enamul,
I think its from the french forum. My mistake, need to correct that init macro.
http://www.matrixmultimedia.com/mmforum ... &hilit=I2C

Regards.

PIC-ER
Posts: 15
Joined: Fri Dec 21, 2012 4:07 pm
Has thanked: 7 times
Contact:

Re: I2C with 4 digit 7 segment display.

Post by PIC-ER »

Hello,
Here is a simple FC, with which i am trying to at least get the displays to light up. But am severely stuck. The circuit is as shown in the previous posts.
Please tell me what i am doing wrong or what i need to add to the FC.
Thanks.
Attachments
PCA9532.pdf
(164.21 KiB) Downloaded 233 times
prog.JPG
prog.JPG (47.57 KiB) Viewed 7075 times
PCA9532_v2_I2C.fcf
(10 KiB) Downloaded 261 times

Post Reply