LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Servo sweep loop on Arduino – new LVIFA Firmware case

Hi,

I am trying to write a new case in the LVIFA Firmware to add the functionality of having the Arduino making a servo sweep loop with minimal communication to LabView.

My Arduino communicates with LabView over two XBees, however the environment (heavily armed concrete) makes the signal distorted and I use a low baud rate for better reception. I therefore have a certain interest in minimizing the data sent between the Arduino and LabView.

My first attempt having LabView running a loop providing the “Servo Write Angle” block with a new value every 1/100th second resulted in choppy servo movements,  the XBee signal strength is too low. I am now trying to “move” the loop calculating the next angle to the Arduino, and just initializing the loop from LabView. I hope this is going to reduce the amount of data sent through the XBees.

I have recently successfully added my first working new case to the LVIFA Firmware (the Utrasonic Sensor), however I am not able to make this one work properly and was hoping for some advice.

I use

Arduino v1.0.1

LabView 2011

LabView Interface for Arduino v2.1.1.69.

Please find attached a picture of my .vi and the added code in the LVIFA_Firmware file.

case 35.png

case 0x35: // Servo sweep

      for(int servopos = 20; servopos < 160; servopos ++)  // goes from 20 degrees to 160 degrees

      {

      servos[command[2]].write(servopos);

      }

      for(int servopos = 160; servopos>=20; servopos--)     // goes from 160 degrees to 20 degrees

      {

      servos[command[2]].write(servopos);

      }

      Serial.write('0');

      break;

I have no need of controlling the max and min turning angles from LabView and have therefore specified them directly in the code.

When I am running this the servo goes to 90 degrees and stays put, no sweeping. XBee communication is fine (tested with other .vi's), LVIFA_Firmware uploads completely to the Arduino without errors. I have also been moving the "Serial.write('0');" command around without success, and there is of course no other case named 0x35 in my firmware file.

Hints, code improvements or other comments on how to get this up and running are most welcome!

Best regards,

Robert

0 Kudos
Message 1 of 2
(11,942 Views)

I think you are doing this anyway but try to offload as much as possible to the Arduino and only send high level commands and arguments over the link to the Arduino.

Also take a look at this post for a step by step example of customising the LVIFA.

Regards,

Dale

0 Kudos
Message 2 of 2
(3,076 Views)