User Tools

Site Tools


nxt_automation_implementation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
nxt_automation_implementation [2024/11/23 18:22] hhameednxt_automation_implementation [2024/11/25 13:55] (current) hhameed
Line 11: Line 11:
 The following tutorial has the motivation of documenting a means of wireless communication to a LEGO NXT module for the purpose of automation with a concentration on mobile robots. This tutorial assumes: The following tutorial has the motivation of documenting a means of wireless communication to a LEGO NXT module for the purpose of automation with a concentration on mobile robots. This tutorial assumes:
  
-<fc blue> 
   *BricxCC (Bricx Command Center) application setup   *BricxCC (Bricx Command Center) application setup
-\\ +  *A basic understanding of C+ + (or general object oriented programming)  
-  *A basic understanding of C++ (or general object oriented programming) +  *Access to basic electrical components
-</fc>+
  
 <fs x-large>**Parts List and Sources**</fs> <fs x-large>**Parts List and Sources**</fs>
 +\\ 
 +  *LEGO NXT 
 +  *[[http://www.mindsensors.com/ev3-and-nxt/29-sony-playstation-2-controller-interface-for-nxt-or-ev3|Sony Playstation 2 Controller Interface for NXT or EV3]] 
 +  *[[https://www.brookaccessory.com/products/wingmanps2/index.html|Brook Wingman PS2]] 
 +  *[[https://www.amazon.com/Logitech-Wireless-Nano-Receiver-Controller-Vibration/dp/B0041RR0TW?crid=3CA24GQASRV0V&dib=eyJ2IjoiMSJ9.Dpo5bvFXpJM3oQEDxlrPqmP4TRDfE4f8jZYDWWs0-zfZulhTOqzvztLb4u8wiH0X2r79i_fAdbJJ-opjjFkpMtZRn3qE7NZqZnjjiRi0fwl2wtIU_GJQY-lK4HgTHY4mfNYxzU-dBCF_oezbP9Mxws493giWpE0urfRldViaHgJXUCIHs3cmi9vqJ5Nh5iNuHJY29zX02arsvn9J8lZ_IkWjwVKOXrOLA_Y3buJ804s.3u1z3FfpARLiWgLPpZ2KYgU6wYiFBY9DuZRkZyNyv9o&dib_tag=se&keywords=logitech%2Bf710&qid=1732413989&sprefix=logitech%2Bf%2Caps%2C144&sr=8-1&th=1|Logitech F710]] 
 +  *[[https://www.amazon.com/AITRIP-ESP-WROOM-32-Development-Microcontroller-Integrated/dp/B0DF2YJSHN?dib=eyJ2IjoiMSJ9.J8fl2PuZsBFTQRqqz9O9mEmyW62U4_MpGp5foNJRgelWypISvNbbm65DtPAI9DzhViCB-x3lbNUDgupbZhCbxSDVwBBMwtxW_bgXqq9RyaIYGRk49OAKmhrFw_OKJdupc5G0u4I1gW7rkdlTuLLVACDXdiQFeOYfhHiV8AOgwIMv8TQfESYUxBC8714aMXMEUBk-H-kpkaVbEzudR8qffCO6tua6TvQSKq7ggfZuV88.U3LiQYOUYERI_is6ZEJiMS6iwDWPcd1npboG-NrB1Io&dib_tag=se&keywords=esp32%2Busbc&qid=1732415679&sr=8-3&th=1|ESP32 USB-C]]
  
 <fs x-large>**Software**</fs> <fs x-large>**Software**</fs>
 \\ \\
-  * [[https://pypi.org/project/pyserial/|pyserial]] +  *[[https://www.arduino.cc/en/software|Arduino IDE]] 
-  * +  * [[https://pypi.org/project/pyserial/|Pyserial]]
   * [[http://sourceforge.net/projects/bricxcc/files/bricxcc|BricxCC]]   * [[http://sourceforge.net/projects/bricxcc/files/bricxcc|BricxCC]]
   * (If needed) [[https://www.daslhub.org/unlv/courses/me425-625/lesson-B-simpleMachines1-leversShaftsAndCranks/lab/NXT_USB_Driver_120.zip|NXT USB Driver]]   * (If needed) [[https://www.daslhub.org/unlv/courses/me425-625/lesson-B-simpleMachines1-leversShaftsAndCranks/lab/NXT_USB_Driver_120.zip|NXT USB Driver]]
Line 111: Line 114:
 Data may be passed from external sensors/devices such as cameras or even motion capture to inform the NXT module’s movement. In order to communicate with the microcontroller, the given device(s) are ideally able to run through a script containing some form of serial communication. Used in this case is the Python [[https://pypi.org/project/pyserial/|pyserial]] library. Following installation, it is recommended that [[https://projecthub.arduino.cc/ansh2919/serial-communication-between-python-and-arduino-663756|this tutorial]] be followed to verify communication between a python script and the script running on the microcontroller. Using this as a base, we may create a more robust stimulus-based movement.  Data may be passed from external sensors/devices such as cameras or even motion capture to inform the NXT module’s movement. In order to communicate with the microcontroller, the given device(s) are ideally able to run through a script containing some form of serial communication. Used in this case is the Python [[https://pypi.org/project/pyserial/|pyserial]] library. Following installation, it is recommended that [[https://projecthub.arduino.cc/ansh2919/serial-communication-between-python-and-arduino-663756|this tutorial]] be followed to verify communication between a python script and the script running on the microcontroller. Using this as a base, we may create a more robust stimulus-based movement. 
  
-The following code shows an arduino ino file with serial communication used to inform motor speed for a mobile robot NXT. +The following code shows an arduino ino file with serial communication used to inform motor speed for a mobile robot NXT
 + 
 +<code c [enable_line_numbers="true"] mobile_starter.ino> 
 +//instantiates pins & speed(s) 
 + 
 +const int yright = 16; 
 +const int yleft = 17; 
 + 
 +const int button = 18; 
 + 
 +int message; 
 +int stop = 75; 
 +int speedRight = stop;  
 +int speedLeft = stop; 
 + 
 +//Setting up pins to be output & setting analog joystick value to neutral 
 +//Starting serial for script communication 
 +void setup() { 
 +  Serial.begin(115200); 
 +  Serial.setTimeout(1); 
 +  pinMode(yright, OUTPUT); 
 +  pinMode(yleft, OUTPUT); 
 +  pinMode(button, OUTPUT); 
 +  analogWrite(yright, 90); 
 +  analogWrite(yleft, 90); 
 +  digitalWrite(button, LOW); 
 +
 + 
 +void loop() { 
 + 
 +//when communication is not actively occurring, use last defined speed value 
 +  while(!Serial.available()){ 
 +    analogWrite(yright, speedRight); 
 +    analogWrite(yleft, speedLeft); 
 +  } 
 + 
 +  message = Serial.readString().toInt(); 
 + 
 +//case statements with edge cases 
 +//if the "message" value is within the defined voltage range, it will be mapped accordingly 
 +//if the "message" value outputs 300, stops robot and performs action 
 +if(message != 0){ 
 +   
 +  if(message > 0 && message < 200){ 
 +    speedRight = stop + message; 
 +    speedLeft = stop - message; 
 +  }else if(message < 0){ 
 +    speedRight = stop + message; 
 +    speedLeft = stop - message; 
 +  }else if (message = 200){ 
 +    speedRight = 125; 
 +    speedLeft = speedRight; 
 +  }else if (message = 300){ 
 +    speedRight = stop; 
 +    speedLeft = stop; 
 +    digitalWrite(button, HIGH); 
 +    delay(250); 
 +    digitalWrite(button, LOW); 
 +    delay(250); 
 +    digitalWrite(button, HIGH); 
 +    delay(250); 
 +    digitalWrite(button, LOW); 
 +  } 
 +   
 +//message will print to terminal of external ide 
 +  Serial.println(message); 
 +  Serial.println(speedRight); 
 +  Serial.println(speedLeft); 
 +
 + 
 +
 +</code>
  
 **<fs x-large>Theory</fs>** **<fs x-large>Theory</fs>**
Line 125: Line 199:
 {{:time_constant_demo.png?400|}}{{::time_constant_demo2.png?400|}} {{:time_constant_demo.png?400|}}{{::time_constant_demo2.png?400|}}
 {{:time_constant_demo3.png?400|}}{{:time_constant_demo4.png?400|}} {{:time_constant_demo3.png?400|}}{{:time_constant_demo4.png?400|}}
 +
 +<fs x-large>**Final Words**</fs>
  
  
nxt_automation_implementation.1732414933.txt.gz · Last modified: by hhameed