Forum Replies Created

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • in reply to: Need positive logic from the 74HC595 output #42333

    mikek
    Participant

    UPDATE:If you are using this modification to get reverse logic you will not be able to update to firmware 2.1.6(1) OSPI-AC until you get rid of the changes. The git pull command will give you a warning and quit. If you want to update your firmware you will need to abandoned this mod and modify the apply_all_stations_bits as suggested by Ray (a better and easier way to do it anyway).

    To fix things do:
    cd OpenSprinklerGen2
    mv gpio.cpp gpio.old
    git pull
    nano OpenSprinkler.cpp

    Change line 669 in OpenSprinkler.cpp from

    digitalWrite(pin_sr_data, (sbits & ((byte)1<<(7-s))) ? HIGH : LOW );
    To
    digitalWrite(pin_sr_data, (sbits & ((byte)1<<(7-s))) ? LOW : HIGH );

    ctrl-x and y to save

    Then
    sudo ./build.sh ospi
    sudo /etc/init.d/OpenSprinkler.sh restart

    in reply to: Need positive logic from the 74HC595 output #39145

    mikek
    Participant

    @David,

    Yes it works.


    @Ray
    ,

    I put a if else in the code to only effect the single serial data pin going to the shift register (pin 27 on the Pi)

    if (pin == 27) {
    modified code
    }
    else {
    unmodified code
    }

    As for reversing the logic on the input it will have (and does have) the same effect as reversing the output since the LSB of the input is the Q0 output and all the way to the MSB on the input is Q7 on the output.

    My solution works, however, I agree that it would be better and cleaner to change the apply_all_station_bits as you suggested. I was looking where Samer suggested.

    in reply to: Need positive logic from the 74HC595 output #39094

    mikek
    Participant

    I did what I needed by changing the gpio.cpp file like this since I only wanted to effect the serial data to the 74hc595, however if anyone knows what the write function syntax pass it along.

    if (pin == 27) {
    if (1 != write(fd, &s_values_str[HIGH == value ? 0 : 1], 1)) {
    DEBUG_PRINTLN(“failed to write value”);
    DEBUG_PRINTLN(pin);
    return;
    }
    }
    else {
    if (1 != write(fd, &s_values_str[LOW == value ? 0 : 1], 1)) {
    DEBUG_PRINTLN(“failed to write value”);
    DEBUG_PRINTLN(pin);
    return;
    }
    }

    in reply to: Need positive logic from the 74HC595 output #39089

    mikek
    Participant

    @David,

    I thought about using inverters but decided not to because you could have an instance with startup leaving all channels on if open sprinkler fails to run or the pi fails to boot. Unless your inverter uses an output enable, you could tie that to the OE of the 74hc595.

    in reply to: Need positive logic from the 74HC595 output #39087

    mikek
    Participant

    I can’t seem to find a reference to the syntax of the write command.

    In line 120 of gpio.cpp

    if (1 != write(fd, &s_values_str[LOW == value ? 0 : 1], 1)) {

    To me it looks like fd is the io handle and &s_values_str[LOW == value ? 0 : 1] will be the address of either the “0” or the “1” in the s_values_str array, but what is the last peramiter for (the , 1)? Also why return the address of the string element why not just use a HIGH or LOW? Is this needed for the write function?

    I can’t seen to find the write function in the gcc stdio or any of cpp io functions

    in reply to: Need positive logic from the 74HC595 output #39030

    mikek
    Participant

    Thanks for the quick reply

Viewing 6 posts - 1 through 6 (of 6 total)