Help needed with 74HC595


#1

Hi,

For my projects I use a script/script2 object with this code edit inside:

// FOUR 74HC595 SHIFT REGISTERS
// by paul

uint8_t *txbuf;

void setup(void){
    
    static uint8_t _txbuf[32] __attribute__ ((section (".sram2")));
    txbuf = _txbuf;

}

void loop(void){
    spiSelect(&SPID1);

    txbuf[0] = (in1>>24);     // SHIFTREGISTER 1
    txbuf[1] = (in1>>16);    // SHIFTREGISTER 2
    txbuf[2] = (in1>>8);    // SHIFTREGISTER 3
    txbuf[3] = (in1);    // SHIFTREGISTER 4

      spiSend(&SPID1,4,txbuf);
      spiUnselect(&SPID1);
    chThdSleepMilliseconds(1);
}

Can someone do a single object with that? It needs only one inlet.

My objects will work for everybody without the need to copy this code in a script.


Hugo Contributions
#2

Is this what you want?
shiftRegister.axo (1.6 KB)


#3

Yeah!!

It's working perfectly!

Now the ideal would be to add it to the community library!

Can you do that? Are you a contributor?


#4

sure, i will do soon, then you can comment on the background it if you want.


#5

The script is not mine so I asked the author ( @paul )if he is ok.


#6

hi @Hugo and @Djeremaille
you can use my code, no problem :spy:. the posted sample codes are only base sketches and should help at getting started. It would be cool if you paste the 74xx595 thread url into the description field as help reference, so other user can see what has changed in the past and please post a link at the 595 thread to your contribution object.

To run the 595 script it needs to create a thread session else the axoloti won't work properly.
You can check the description at the chibios reference:
* Thread overview
* Tutorial "create a thread"
* Tutorial "timing and threads"

and you can decrease the number of stored value into the sram2. the script only needs 4 bytes (txbuf). it should look like this:
static uint8_t _txbuf[4] attribute ((section (".sram2")));


#7

yeah, threading is contained in this object, as it is in the script object by default.


#8

Hi, I'd like to make an object for two 4 digit 7 segment displays using two 595. Right now I have it wired so that the first 595 turns on different segments and the second one multiplexes common anodes.
I checked the scrips posted here, but none of them utilizes multiplexing. Can somebody post a script that would multiplex the digits and where possibly different segments could be turned on/off simply rewriting binary 8 digit number? That would help a lot and I believe we all could learn from it.


#9

Whats the easiest way to use only one of these chips to use 7leds? Do I need to modify the script?