LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with LIFO Shiftregister

Hi,

I am trying to implement a fast and easy way to handle shiftregisters, like the one from the starter kit...

so I tried to write a "case" and add it to the LIFO. But there seems to be a slight problem.. it isn't working....

case 0x46: // ShiftOut

      {

      byte data = 0;

     

      pinMode(command[2],OUTPUT); //DataPin

      pinMode(command[3],OUTPUT); //ClockPin

      pinMode(command[4],OUTPUT); //LatchPin

      // command[5] = Shiftsize (8,16...etc.)

      // command[6] = Shiftsize divided by 8, because of 8bit data packets?!

      // command[6+n] = Shiftarray in 8bit packets.

      for(int i=7;i < command[6];i++) 

      {

        for(int h=0;h <= 7;h++)

        {

          if(h=0)

          {

            bitWrite(data,h+((i-7)*8),(command & 0x01)); // (i-7)*8 for 16bit etc. shiftregisters

            shiftOut(command[2],command[3],MSBFIRST,data);

          }

          else

          {

            bitWrite(data,h+((i-7)*8),((command >> h) & 0x01));

            shiftOut(command[2],command[3],MSBFIRST,data);

          }

        }

      }

     

      digitalWrite(command[4], HIGH);

      digitalWrite(command[4], LOW);

      }

I wrote the code according to an example for shiftregisters (USK Circuit#12) and the case "writedigitalport"... the problem has to be my use of "command & >>...." since I have no idea how it works 😄

Or maybe its my VI... take a look. ^^

Thanks in advance!

0 Kudos
Message 1 of 8
(5,084 Views)

The first thing that I notice is that in your VI, you are specifying 0d46 (46 as a decimal value) but in the firmware, command are specified in hex: 0x46.  So, to call the function in the firmware, you need to make sure that you are providing 0x46 and not 0d46 as the first element of the array.

0 Kudos
Message 2 of 8
(4,079 Views)

Thanks!

Now the call works. But after some blinks of the data,clock,latch pin the data pin remains triggered.. and none of the leds connected to the shiftregister are glowing.

Do I convert and access the Boolean Array correctly?

0 Kudos
Message 3 of 8
(4,080 Views)

Starting with your VI and the official documentation for ShiftOut(), I built a LIFA ShiftOut function.  Test it out and let me know if it works.

0 Kudos
Message 4 of 8
(4,080 Views)

Thanks for the efforts... but same problem 😞

after some blinks of the latch/data/clock pins the data pin stays lightened but none of the shift-led's.

Your way should have worked... its easier to use a command for each shift_led, instead of accessing an array within the command.... but still no reaction of the led's.. mysterious.. (all is connected correctly... the starterkit_shiftexample and my way using the LIFO_digitalwrite commands works as well (but is very slow.. 130ms))

Not as easy as I thought to add a function on my own. 😄 

0 Kudos
Message 5 of 8
(4,080 Views)

If you have an Arduino example that works with your shift registers, could you post it here?

0 Kudos
Message 6 of 8
(4,080 Views)

Those VI's are fully functional for adressing a shiftregister with unknown size,... but with 110ms .. a little slow. Therefore a "LIFA Function" would be nice... ^^

0 Kudos
Message 7 of 8
(4,080 Views)

It will always be slow if you try to do low level stuff through this abstraction layer.  I was asking for working Arduino code (not LIFA or LINX).  Also, maybe it would help if we knew what device you are actually using.

0 Kudos
Message 8 of 8
(4,080 Views)