Thursday, July 8, 2010

July 7 Code / HW notes

Next goal is turning the tacho motor to turn by degrees.
Need I2C communication to the Tacho motor.
Following is mostly unrelated to motor:
what is learned + code clean-up finished or documented during the process. 
Needed in part because it was not clear which functions were motor related by their names specifically set and get functions did not specify, if they are for the motor or sensor. (Have already been renamed when unclear.)

Applications:
Need to initialize sensors and turn-off actuators=motors
 
In General:
When sending HW info do following in eCos:
    if (avr_state==e_READY)
      avr_state=e_COMMAND_PENDING;
Then in receive_thread it will be sent to the AVR 
Similiarly to recieve data from AVR add to the function:
      if (avr_state==e_READY)
          avr_state=e_COMMAND_PENDING;
clean-up all:
rename functions (set/get) so HW affected is reflected. But keep names small.
Examples:
  • GetOutputPower(PORT);  has been renamed to: Motor_AVR_GetPwr
  • SetInputPower to Sensor_AVR_SetInPwr  - sensors can are usually just read so was not clear.
General Problems :
Real LMS FORTE problem: no way to leave an application and reset all H: Other handle this by having a file system.  Is a file system appropriate for FORTE LMS? 

Open Questions: 
> Is a file system appropriate for FORTE LMS? in general or as part of a solution to solve the reset problem. 
> Timers used, sampling rates, clock frequency: Using HW or SW timers at the moments - what code indicates this?  think HW via eCos, but haven't found sampling rate in code yet

> LinkInitAVR function is never used, so why is it there?
> GetFirmwareVersion function returns the firmware version of what and via what? The battery is referenced.

Motor:
LMS NXT HW Developer Kit V.1 p.5  6 "The TACHOA0 and TACHOA1 are input ports that have a Schmitt trigger mounted between the ports and the input pins on the ARM7 processor. These two signals allow the possiblity of having a quadrature detector within the system. Within the standard firmware these two signals are used to count the number of tacho pulse from the motors and detect whether the motor is running clockwise or counterclockwise."



from Lego Education FAQ: HW questions:
"Q: What is a servo motor?
A: An electric motor whose speed or position is controlled by a closed loop feedback circuit that can sense its position. The speed of the motor is measured by a tachometer. 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. "



How Lejos reads/ turns by degrees:



I2C interface used by motors is initialized via : at91sam7sxxx_i2c_init( )
io/i2c.h
http://ecos.sourceware.org/docs-latest/ref/i2c-porting.html porting to new HW incl.s bit banging info

Open Problem: Motors not reset to when booting
Solution: create a reset_all function

Applications: need to turn motors off when finished
don't  use timer to generate signal because ecos uses it. ..._TC0 and ..._TC2
   timers  TC0 and TC2  ..   see at91sam7s_misc.c
use any other ones


http://www.philohome.com/nxtmotor/nxtmotor.htm Motor insides

Motor Pins: tachoA0 (Motor) =INTA (motor wiring& connection to ARM7) = PA15/PGM3 (written on the INTA pin connection)  so pin 15 = MA0
Motor Pins: MA0/MA1= 15/1; MB0/MB1= 26/9; MC0/MC1= 0/8;  more exactly:

TachoA0
  = INTA0 = Pin 20 = PA15/PGM3
  = INTB0 = Pin 26 = PA26/PGMD14
  = INTC0 = Pin 48 = PA0/PGMEN0
TachoA1
  = DIRA = DIRA = Pin 47 = PA1/PGMEN1
  = DIRB = DIRB = Pin 30 = PA9/PGMM1
  = DIRC = DIRC = Pin 31 = PA8/PGMM0

Ultrasound:
 see twi.c two wire code for ultrasound

Color Sensor:
Can set power to european setting via FORTE using:
SetInputPower to Sensor_AVR_SetInPwr
  
Buttons:
clean-up needed:  
  • rename fns so button first
  • button pressed values included chorded
  • make clear what code is for debounce
ButtonState is: debounce right after a button changes values
ButtonVal    is: value of the buttons
http://www.rentron.com/Myke6.htm debouncing explained

Battery:
By testing the battery seems to run out too quickly. Then even plugged in it takes 15-30minutes before its charged enough to test. 
  • Short-term solution is to have the recharable battery plugged-in while testing. 
  • Long-term need to test what is eating up so much power so fast and correct the real problem.
Symptoms: 
  • LMS does not turn on  
  • Low Voltage message from openocd cmd
Timing:
The following appears in eCos recieve_thread function:

       cyg_thread_delay( 2 ); // 2 ... every 2 ms ?
It would be nice to know exactly how long between delays, rather than hoping its 2ms so...
In eCos Reference Manual under thread control  the 2 is clarified to be 2 clock cycles:
  • So what clock is used?
  • And how long is 2 cycles?

No comments:

Post a Comment