Thursday, May 6, 2010

May 6 Turn by angle

Lego Mindstorms NXT Servo Motor can be turned by a specific angle.
  • How? Read the value from the encoder.
  • How often and how to ensure often enough? via scheduling
The official Lego HW Specifications describe the pin connections between the motor via AVR to ARM7.

eCos Scheduler we are using is described in:
Embedded Software Developement with eCos by A.Massa
search cyg_thread_create  (in avr_ctl.c)

Interesting   arm-elf-insight forte shows following at first
     359    inline Cyg_Thread *Cyg_Scheduler_Base::get_current_thread()
     360    {
-    361        return current_thread[CYG_KERNEL_CPU_THIS()];
     362    }


Scheduling in other firmware examples:
Lego Open source firmware
http://mindstorms.lego.com/ >> support >> files >> advanced >> under downloads right until find open source firmware
m_sched.c  (motor related: d_output.c d_output.r, c_output.c)


Lejos
in nxt_avr.c nxt_avr_1kHz_update( )
from systick.c systick_low_priority( )


(Motor related: platform\nxt\nxt_motors.c)

Links: How servo motor works
from http://www.robotadvice.com/lego-mindstorms-nxt_specification.html
"Servo (servo motor): is any kind of electric motor whose speed or position is controlled by a closed loop feedback circuit. An example is the drive motor in a floppy disk drive, which must maintain an exact rotational speed. The speed of the motor is measured by a tachometer that is physically coupled to the output shaft of the motor. The tachometer produces a voltage that is proportional to the speed. This voltage is compared to a reference point and the difference, or error, is used to adjust the speed of the motor, either up or down."

http://www.nxt-in-der-schule.de/lego-mindstorms-education-nxt-system/nxt-hardware/motoren
"Der neue NXT Servomotor hat einen integrierten Rotationssensor, der die genaue Geschwindigkeit und Entfernung messen und an den NXT zurückmelden kann . Das Design und die Handhabung ist auf das LEGO Technik Konstruktionssystem abgestimmt und ermöglicht einfaches und stabiles Bauen. Die Motoren können sehr präzise gesteuert werden und gleichen untereinander die Geschwindigkeit ab, während sich der Roboter bewegt. Der Motor kann in 1°-Schritten angesteuert werden."