02-06-2014 06:37 PM
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!
02-06-2014 10:01 PM
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.
02-07-2014 05:27 AM
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?
02-07-2014 01:20 PM
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.
02-08-2014 02:31 PM
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
Not as easy as I thought to add a function on my own. 😄
02-08-2014 03:08 PM
If you have an Arduino example that works with your shift registers, could you post it here?
02-10-2014 05:30 AM
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... ^^
02-10-2014 01:30 PM
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.