2

I've developed a PI Python application to replace an old control card which sent bit banging out to daisy chained LED drivers.

It all works fine except when I need some fast updating of the LED's.

Currently I'm using bit banging on SPI. Having problems getting the data to actually go out the GPIO.

I've set up PiScope and have a screenshot attached of the capture on pins 4,16,19. The screenshot also shows the terminal session running the test program.

Respectively they are data, clk, cs.

Here is the Python code of the test program I am running:

Why am I not seeing the data on pin 4?

import time
import pigpio as GPIO
import serial


Ziku = [
    0x07,0x0F,0x0f,0xff,        #0
    0x00,0x00,0x01,0xf8,        #1
    0x00,0x0F,0xfe,0x3f,        #2
    0x00,0x00,0xff,0xff,        #3
    0x07,0x00,0xf1,0xf8,        #4
    0x07,0x00,0xff,0xc7,        #5
    0x07,0x0F,0xff,0xc7,        #6
    0x00,0x00,0x01,0xff,        #7
    0x07,0x0F,0xff,0xff,        #8
    0x07,0x00,0xff,0xff,        #9
    0x00,0x00,0x00,0x00,        #10
    0x00,0x00,0x70,0x00,        #- 11 
    0xf0,0x0F,0xfe,0x00,    #12
    0x00,0x0F,0xf0,0x07,        # F
    0x07,0x0F,0xf1,0xf8,        # H  

]   



#create local PI GPIO

p1 = GPIO.pi()

# Pin definitions
sda_pin = 4
mosi_pin = 7
clk_pin = 16
oe_pin = 5
cs_pin = 19

#p1.bb_spi_close(cs_pin)

#clock frequency
freq = 1000

#Now going to just use straight bit banging rather than the i2c stuff


p1.set_mode(oe_pin, GPIO.OUTPUT)
p1.set_mode(cs_pin, GPIO.OUTPUT)

p1.set_mode(clk_pin, GPIO.OUTPUT)
p1.set_mode(sda_pin, GPIO.OUTPUT)



p1.write(oe_pin, 1) # Disable output





def send_digit(char):
    ziku_num = int(char) * 4
    send_data = [Ziku[ziku_num], Ziku[ziku_num+1], Ziku[ziku_num+2], Ziku[ziku_num+3]]
    p1.bb_spi_xfer(cs_pin, send_data)
    print(send_data)



# Main Loop
num_select = ""
while num_select.upper() != "E":
    num_select = raw_input("Choose which digit (10 will clear, E will exit) ")

    if num_select.upper() != "E":
        p1.bb_spi_open(cs_pin, sda_pin, mosi_pin,  clk_pin, freq, 0)
        p1.write(oe_pin, 1) #disable output

        ziku_num = int(num_select) * 4
        send_data = [Ziku[ziku_num], Ziku[ziku_num+1], Ziku[ziku_num+2], Ziku[ziku_num+3]]
        p1.bb_spi_xfer(cs_pin, send_data)
        print(send_data)

        p1.write(oe_pin, 0) #enable output

        p1.bb_spi_close(cs_pin)


p1.bb_spi_close(cs_pin)

PiScope Screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.