01-25-2012 04:06 PM
Hey ADrexelDragon,
Can you clarify what you mean by the Arduino not storing data as you thought?
Here is an example of send receive sending two 16 bit numbers to Arduino.
case 0x1F:
number1 = ( (command[2]<<8) + command[3]);
number2 = ( (command[4]<<8) + command[5]);
You can store these numbers in a global variable if you need to access them elsewhere in the code.
Let me know if you have questions on this.
01-25-2012 07:00 PM
Kevin,
I am not sure how this works for you...
I tried to implement the same exact code but have the arduino tell me what it recieved.
LabVIEW code:
Arduino code:
unsigned int Number;
case 0x1F: //Serial Recieve from LabVIEW
Number = (command[2]<<8 + command[3]);
break;
case 0x20: //Serial Send to LabVIEW
Serial.println(Number, DEC);
break;
Result:
Nothing came back.
01-26-2012 12:17 PM
Hey ADrexelDragon,
I think the reason this probably isn't working for you is that at the point where the Get Bytes at Port VI is run there are no bytes at the port so you are sending a 0 to the Send/Receive as the number of bytes to read. The way this should be done is in the first command to send back an acknowledge byte when the command has finished executing (in the code we usually just send back a 0). Then you don't need the wait function in the code since the first Send/Receive will block until the command sends the acknowledge back. For your second send/receive you will need to know how many bytes the command is writing back from the Arduino. This will be easier to figure out if you break the numbers out into individual bytes in the firmware.
01-26-2012 10:10 PM
I was able to send a single number but the idea was to send an array.
Here is how I adapted it:
If I use this LabVIEW code with the following arduino code, would the array work in a separate case?
//Variables
unsigned int NumberArray[];
case 0x1F: //Recieve and build Unsigned Int Array from LabVIEW
NumberArray[command[2]] = (command[3]<<8 + command[4]);
Serial.write(byte(0));
break;
If this does not work, what am I doing wrong?
Thank you,
01-30-2012 08:05 AM
Another option I am looking into is using a SD card or microSD card to save the arrays onto.
From there I could load the arrays. I am not sure if this would help because I am not sure if I could store the array from the text file as a constant on the arduino.
So if I send "100,200,300,400,500,1000"
Would I be able to store it as
unsigned int Array1 = {100,200,300,400,500,1000};
I am also looking for help from the arduino support team on this one.
01-30-2012 09:34 PM
Without running the code I think that general concept for writing an array would work. If the array is a global you will be able to access it in other command cases. I can't say I know much about using Arduino with an SD card so I can't be much help in that area. Whats the big picture goal with your application? Maybe we can think of some other ways to approach the problem.
01-30-2012 09:58 PM
I am trying to store raw IR codes. Here is a website to a link that explains the IRremote library:
http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
I am trying to save the raw IR codes somewhere so I can call them when I need them. Raw IR codes change in length but are usually sent out at 38 Hz.
In this library, the send raw command is irsend.sendRaw(IRsignal, signalLength, 38); IRsignal is an unsigned int array and signalLength is the number of indices in the array.
Here is the thing: I can use IRrecvDump code to get the IR signal array. I want to save this array so that I can build a 2D array (1D array for each unique IR signal) and then call it later. So if I press "Play" on IR remote, it saves in index 0 of the 2D array. If I press "Stop" on the IR remote, it saves in index 1 of the 2D array.
I then want LabVIEW to be able to send whichever index I choose. I plan to make a GUI of Play, Stop, Up, Down and then send 0,1,2,3 to the arduino.
The arduino would send the corresponding IRsignal.
I don't know if the arduino has enough space to store the 2D array. I figured I could save it to the computer and then upload the array everytime I plug the arduino into the computer. That is also why I looked towards the SD card option.
That sums up my project that I am working on... Turning my computer into an IR remote with LabVIEW.
Thanks for your help.
01-31-2012 11:46 AM
How big is the 2D array?
If it never changes and you are going to be eventually loading the whole thing on there anyways I would probably just hard code it as a constant in one of your files- there is quite a bit of empty space on the Arduino Uno/Mega even after the LIFA sketch is uploaded.
01-31-2012 03:01 PM
The 2D array size changes depending on which remote I use.
One remote has a 4 buttons, each button is 67 indices of unsigned integers.
Another remote has 10 buttons, each button is 67 indices of unsigned integers.
01-31-2012 03:40 PM
I would just try and put that on the Arduino. If you are trying to load the whole table at run time from LabVIEW you are going to run into the same size limitations.