nxt_automation_implementation
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
nxt_automation_implementation [2024/11/23 15:12] – created hhameed | nxt_automation_implementation [2024/11/25 13:55] (current) – hhameed | ||
---|---|---|---|
Line 8: | Line 8: | ||
<fs x-large> | <fs x-large> | ||
+ | |||
+ | 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: | ||
+ | |||
+ | *BricxCC (Bricx Command Center) application setup | ||
+ | *A basic understanding of C+ + (or general object oriented programming) | ||
+ | *Access to basic electrical components | ||
+ | |||
+ | <fs x-large> | ||
+ | \\ | ||
+ | *LEGO NXT | ||
+ | *[[http:// | ||
+ | *[[https:// | ||
+ | *[[https:// | ||
+ | *[[https:// | ||
<fs x-large> | <fs x-large> | ||
\\ | \\ | ||
+ | *[[https:// | ||
+ | * [[https:// | ||
* [[http:// | * [[http:// | ||
* (If needed) [[https:// | * (If needed) [[https:// | ||
* (If needed) [[https:// | * (If needed) [[https:// | ||
+ | |||
<fs x-large> | <fs x-large> | ||
Line 19: | Line 36: | ||
**Step 1 [Teleoperation Verification]** | **Step 1 [Teleoperation Verification]** | ||
- | Follow the instructions within the “LEGO NXT Teleoperation Introduction” tutorial and verify the NXT module can drive motors using either the Playstation 2 Controller or a controller compatible with the Brooke Translation peripheral (operation detailed in following section). Verify the mobile robot platform built prior to the tutorial’s remainder. | + | Follow the instructions within the “[[lego_nxt_teleoperation_introduction|LEGO NXT Teleoperation Introduction]]” tutorial and verify the NXT module can drive motors using either the Playstation 2 Controller or a controller compatible with the Brooke Translation peripheral (operation detailed in following section). Verify the mobile robot platform built prior to the tutorial’s remainder. |
**Step 2 [Brooke Wingman PS2 Setup]** | **Step 2 [Brooke Wingman PS2 Setup]** | ||
Line 25: | Line 42: | ||
The Brooke peripheral requires provision of a 5V voltage source, which the NXT module in many cases is incapable of providing. In order to remedy this, utilize a buck converter/ | The Brooke peripheral requires provision of a 5V voltage source, which the NXT module in many cases is incapable of providing. In order to remedy this, utilize a buck converter/ | ||
- | Verify operation of the Brook peripheral on a functioning NXT module by powering on the module, connecting the 5V power supply if seen necessary, and using a compatible Logitech F710 wireless controller (if not immediately available, the linked page lists all compatible controllers) | + | {{:: |
+ | |||
+ | Verify operation of the Brook peripheral on a functioning NXT module by powering on the module, connecting the 5V power supply if seen necessary, and using a compatible Logitech F710 wireless controller (if not immediately available, the [[https:// | ||
+ | |||
+ | {{: | ||
**Step 3 [Communication]** | **Step 3 [Communication]** | ||
- | Disassemble the Logitech F710 controller. Observe the wireless transmitter soldered onto the mainboard, with connections tied to input(s) as seen below and further documented here (required reading). This transmitter may be used connected to the mainboard (pictured) or desoldered and connected to power via the specified pins for a more permanent connection. | + | Disassemble the Logitech F710 controller. Observe the wireless transmitter soldered onto the mainboard, with connections tied to input(s) as seen below and further documented |
+ | |||
+ | {{:: | ||
It is important to note that each connection handles a voltage of up to roughly 2.1V, with analog inputs accepting any value between 0V-2.1V, so as to not provide excess current. To verify, utilize a multimeter to measure input voltage relative to ground for any given pin. Measurement is additionally recommended in the case of analog input to determine voltage output for desired value(s). Power and voltage may be provided through use of a microcontroller (ESP32 used). | It is important to note that each connection handles a voltage of up to roughly 2.1V, with analog inputs accepting any value between 0V-2.1V, so as to not provide excess current. To verify, utilize a multimeter to measure input voltage relative to ground for any given pin. Measurement is additionally recommended in the case of analog input to determine voltage output for desired value(s). Power and voltage may be provided through use of a microcontroller (ESP32 used). | ||
Line 39: | Line 62: | ||
A very simple DAC can be made from a Resistor-Capacitor (RC) circuit network. The resistor and capacitor capacitor values are 1kΩ and 100μF respectively. As shown in the figure below, source voltage is connected in series with the resistor in turn connected in series with the capacitor, with the positive end of the capacitor being the analog output voltage. | A very simple DAC can be made from a Resistor-Capacitor (RC) circuit network. The resistor and capacitor capacitor values are 1kΩ and 100μF respectively. As shown in the figure below, source voltage is connected in series with the resistor in turn connected in series with the capacitor, with the positive end of the capacitor being the analog output voltage. | ||
+ | {{: | ||
Use the described circuit for any analog input, using a multimeter on the leg of the capacitor relative to ground to verify constant voltage output between 3.3V-0V as output by a given PWM pin on your microcontroller. Read the respective DAC theory section to learn about how you can reconfigure or iterate upon this circuit. | Use the described circuit for any analog input, using a multimeter on the leg of the capacitor relative to ground to verify constant voltage output between 3.3V-0V as output by a given PWM pin on your microcontroller. Read the respective DAC theory section to learn about how you can reconfigure or iterate upon this circuit. | ||
Line 89: | Line 112: | ||
</ | </ | ||
- | Data may be passed from external sensors/ | + | Data may be passed from external sensors/ |
- | 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=" | ||
+ | // | ||
+ | |||
+ | 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, | ||
+ | pinMode(yleft, | ||
+ | pinMode(button, | ||
+ | analogWrite(yright, | ||
+ | analogWrite(yleft, | ||
+ | digitalWrite(button, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | |||
+ | //when communication is not actively occurring, use last defined speed value | ||
+ | while(!Serial.available()){ | ||
+ | analogWrite(yright, | ||
+ | analogWrite(yleft, | ||
+ | } | ||
+ | |||
+ | message = Serial.readString().toInt(); | ||
+ | |||
+ | //case statements with edge cases | ||
+ | //if the " | ||
+ | //if the " | ||
+ | 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, | ||
+ | delay(250); | ||
+ | digitalWrite(button, | ||
+ | delay(250); | ||
+ | digitalWrite(button, | ||
+ | delay(250); | ||
+ | digitalWrite(button, | ||
+ | } | ||
+ | |||
+ | //message will print to terminal of external ide | ||
+ | Serial.println(message); | ||
+ | Serial.println(speedRight); | ||
+ | Serial.println(speedLeft); | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
**<fs x-large> | **<fs x-large> | ||
Line 102: | Line 196: | ||
Given the provided configuration, | Given the provided configuration, | ||
+ | |||
+ | {{: | ||
+ | {{: | ||
+ | |||
+ | <fs x-large> | ||
nxt_automation_implementation.1732403559.txt.gz · Last modified: by hhameed