03-18-2014 12:42 PM
You can look at the two files and see what the differences are.
You are writing to pins 8, 9, 11, and 12 but you have not set them as ouputs. You need to set the "pin mode" to output for all pins that you intend on using as outputs (one of your Write PWM VIs does not have a pin number wired to it; also, you never use pins 5 or 6 in your code anywhere).
To change the baudrate, don't add a Serial.begin(), you need to change the existing one in LabVIEWInterface.ino (in the syncLV function). Alternatively, you can change DEFAULTBAUDRATE in LabVIEWInterface.h.
Generally, you should use shift registers on the error wire but in this case, you should simply wire the error wire to an OR with your stop button.

03-18-2014 06:25 PM
Thanks again Nathan, i will set these to output similar to the way i have with pin 5 and 6 outside the loop. Yeah i probably left out a few important details. First off my understanding was that the PWM did not need a pin number as 3 is the default pin for this. I think it will make more sense when i tell you i am using a motor shield to drive motors. On the shiled pin 8 and 9 are the designated brake pins, 12 and 13 the direction pins, and 3 and 11 are the PWM pins. Sorry i should have mentioned that!! Would this mean dont need to set these all as outputs outside of the loop?
Im not sure how to type in to set the baudrate in the syncLV funtion . I might try it in the LabVIEWInterface.h file and see how i go. I will let you know how i get on tomorrow. Thanks again for your help, much appreciated.
03-18-2014 06:33 PM
Thanks again Nathan, i will set these to output similar to the way i have with pin 5 and 6 outside the loop. Yeah i probably left out a few important details. First off my understanding was that the PWM did not need a pin number as 3 is the default pin for this. I think it will make more sense when i tell you i am using a motor shield to drive motors. On the shiled pin 8 and 9 are the designated brake pins, 12 and 13 the direction pins, and 3 and 11 are the PWM pins. Sorry i should have mentioned that!! Would this mean dont need to set these all as outputs outside of the loop?
Im not sure how to type in to set the baudrate in the syncLV funtion . I might try it in the LabVIEWInterface.h file and see how i go. I will let you know how i get on tomorrow. Thanks again for your help, much appreciated.
03-18-2014 06:58 PM
All digital pins should have the mode set appropriately before using them. Also, if there is a default pin for any VI, IMO, it is always good practice to wire a pin number to it so that the code can be read accurately (especially if you have multiple uses of the function).
03-19-2014 06:36 PM
Well Nathan, some how by mistake i have uninstalled labview interface for arduino and i cant seem to reinstall. it is saying 'exported vi and machine access' something. Im going to try contact NI tomorrow to see if they can talk me through it so i havent had a chance to implement your advice yet. Will be back in touch as soon as im back up and running.
03-26-2014 06:36 PM
Hi Nathan , sorry about the delay in getting back to you. I had a load of trouble with my arduino board !!! Finally got to try my VI after some of the changes you recommended and it works fine. However i didnt go nea the baudrate anywhere in the code. I did try change it back to 9600 on my VI and it would not work. Chnaged back to 115200 and it worked fine. However im still in the dark as to how to get my car moving through Xbee. Would i need to go down the route of Visa write and read. Or should i be good to go by just using the LIFA base seen as it includes LabVIEWInterface.ino?Do i simply just change the baudrate in the LabVIEWInterface.ino code? Any advice would be great. Thanks a milllion.
03-26-2014 07:23 PM
If you want/need to change the baudrate, you need to make sure that you change it in both the firmware and in your VI (the input to Init.vi).
03-26-2014 07:54 PM
I dont think i need to, unless this might help the Xbee. On changing back to 9600 on the init.vi, and leaving the firmware alone it did not work. But changing the baudrate to 115200 on the init.vi, it works( with i assume the baudrate in the firware at 9600!!). Im confused. Maybe i should jus change the baudrate in the labviewinterface.ino file to 115200 so to have them the same. Do you think if i got this working with both baudrates the same , this would then work over xbee. When i say it works now, i have the arduino directly connected to the laptop with the motor shield sitting on the arduino. My labview vi operates the motor channels using the LIFA base code only. My aim is to use an explorer board with the xbee co-orinator, wirelessly communicate with a remote xbee which is connected to the arduino(with motor shield) which is also connected to the motors being controlled.
Thanks again.
03-26-2014 08:41 PM
The default baudrate in an Arduino Uno is 115200. The default baudrate in an Arduino Mega 2560 is 9600. So, if you are using an Uno, you are experiencing normal behavior. I've read that it's good to slow down the baudrate when using XBee (but don't take my word on that) which would require you changing the baudrate in the firmware and in your VI.
I don't know what an "explorer board" is or what an "XBee Coordinator" is so I can't really help you there.
03-27-2014 04:31 AM
no problem, the explorer board is also known as a breakout board! the co-ordinator is just the master xbee. I know i have these working wirelessly its just when i connect the slave one to the arduino. Do you have any experience with Xbee's at all? Do you now if i need any extra code or initilizing of the xbees? Thanks.