User Tools

Site Tools


nxt_automation_implementation

This is an old revision of the document!


NXT Automation Implementation Introduction
Author: Hashim H., Email: hameeh1@unlv.nevada.edu
Date: Last modified on [11/23/24]
Keywords: NXT, Teleoperation, Automation

Motivation and Audience

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) </fc> <fs x-large>**Software**</fs> \\ * [[https://pypi.org/project/pyserial/

simple_variation.ino
  1. //constnat instantiation for pins & starting speed(s)
  2. const int yright = 5;
  3. const int yleft = 4;
  4.  
  5. const int button = 0;
  6.  
  7. int speedRight = 75;
  8. int speedLeft = 75;
  9.  
  10. //Setting up pins to be output & setting analog joystick value to neutral
  11. void setup() {
  12. pinMode(yright, OUTPUT);
  13. pinMode(yleft, OUTPUT);
  14. pinMode(button, OUTPUT);
  15. analogWrite(yright, speedRight);
  16. analogWrite(yleft, speedLeft);
  17. digitalWrite(button, LOW);
  18. }
  19.  
  20. void loop() {
  21. //iterates through voltage values to vary speed, with an action performed following each iteration
  22. for(int speed = 0; speed < 200; speed++){
  23. analogWrite(yright, speed);
  24. analogWrite(yleft, speed);
  25. delay(100);
  26. Serial.println(speed);
  27. }
  28. digitalWrite(button, HIGH);
  29. delay(100);
  30.  
  31. }

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 pyserial library. Following installation, it is recommended that 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. Theory DAC The RC time constant (τ) for an RC circuit is a value indicative of the rate of growth or decay of a capacitor’s charge in a circuit in seconds obtained from the product of the simplified resistance and capacitance values of a given circuit network (τ = RC = 1/(2πfc) [S]). A large time constant as derived from the provided values results in a somewhat slow, but consistent signal proportional to the output duty cycle as shown below. This means that consistency and accuracy may come at the cost of latency if desired to keep the network simplified as presented. Given the provided configuration, heightening either the resistor or capacitor value will lead to a greater degree of latency and more accurate analog voltage, and lowering these values will see these effects inverted. More complex capacitor networks may be utilized to remedy these issues, though are beyond the scope of this tutorial. It is recommended that external research be done regarding such networks prior to implementation.

nxt_automation_implementation.1732414847.txt.gz · Last modified: by hhameed