
- #First robotics labview programming tutorial how to#
- #First robotics labview programming tutorial code#
This was used so that the user had time to remove their hand from the joystick before the robot would begin to drive.Īfter this, the servo write N channel block is used to set the servo motors forward by supplying a 2200uS pulse width to the left motor and 500uS pulse to the right motor. The first part of this state is a 2000ms delay. The true value is also fed into a case structure after the while loop that sends the "Run" state into the main case structure using the shift register.Ī false value is also sent to the main loop so that it continues to run. The "not" block was used to switch this value to true and then the true value is sent to stop the while loop. Thus the setup state is ended when a button on the Pmod is pushed because the resulting byte will be non-zero, resulting in a false value from the comparison block. If one or all of the buttons are pushed, this value is non-zero. If none of the buttons are pushed, this value is 0. The last byte read from the PmodJSTK contains information about the on-board buttons. Using the calibration, this will give a pulse width of 500uS which corresponds to the servo pointing left. Turned all the way to the left, the joystick will output 1024.

2200 was then added to make a correct linear calibration. This was done by doing a linear calibration where the integer from PmodJSTK was multiplied by (500-2200) and divided by the whole range value of 1024. The integer value was transformed into a desired pulse width such that when the PmodJSTK was turned left, the servo would turn left and when the PmodJSTK was turned right, the servo would turn right. The servo points left with a value of 500 uS and points right with a 2200 uS pulses. The servo used ranges from 500 uS to 2200 uS pulses. When the joystick is left, the values range from 512 to 1024 and when the joystick is right, the values range from 0 to 512. If the PmodJSTK is at its origin, a "Nothing" is displayed. These integer values from the PmodJSTK are then sent to two individual case structures that measure whether the PmodJSTK is being controlled left, right, up, or down. A subset array block was used to cut off the extra 6 bits that result when combining the two bytes together for both the x and y axes. These values range from 0 to 1024 (10 bit resolution). For the received bytes, the first two bytes together determine the y - axis values and the second two bytes together determine the x - axis values. The PmodJSTK also sends and receives 5 bytes. There is currently a bug in LINX SPI read that requires active high to be selected for communication to occur but this should be fixed shortly. PmodJSTK had the CS pin connected to channel 10 and is active low.

This results in the setup state pictured above.
#First robotics labview programming tutorial how to#
If the hit-points decrease to zero, the jousting session will end.Ĭheck out this Instructable on the wiring for the robot and check out this Instructable to see how to assemble the 3D printed parts.įor the first loop iteration, the Setup value is sent into the case structure. The robot has three hit-points to start with and each time during the running state if the force goes over a certain value, the hit-points decrease by one. Once the robot was picked up, the state resets back to the setup state unless there have been 3 jousting rounds, in which case, the jousting session would end. In this state the servo motors would run until a force was sensed or if the robot was picked up. Once a button on the PmodJSTK was pushed, the robot would enter a running state. First, there would be a setup state where you could set the angle of the "lance" mounted on a servo using the Pmod Joystick. The overall idea for this project was to create a robot that could be controlled over WiFi and send data back to LabVIEW. To see a parts listing, check out the jousting robot wiring tutorial. In order to communicate with the WF32 over its built-in WiFi, I used LabVIEW MakerHub LINX. I also used the LabVIEW Physical Computing Kit which includes LabVIEW Home Bundle and chipKIT WF32.

If you're not interested in the explanation, the LabVIEW VI is linked on the last step.įor the robot, I used two continuous servos, a joystick, an accelerometer, a mini servo, and a force sensor. This will be an in-depth explanation of the code.

#First robotics labview programming tutorial code#
This instructable will go over the LabVIEW code that I wrote to control a jousting robot.
