Showing posts with label HWinterface. Show all posts
Showing posts with label HWinterface. Show all posts

Thursday, April 29, 2010

Apr.29 Motors FB clean-up

Want to use Tacho to turn by degrees.
Interrupts will probably be needed / desirable.

Tacho Pin information:

Apr.29 Buttons clean-up

Buttons: 2 1 4     each button is a bit.

                     8

Pressing 2 Buttons
  • Our eCos/lms only supports pressing 1 button.
  • and the raw button value is not available to user.
  • Usually button 1 = enter (orange) + another button is supported.
Changes needed:
  • eCos avr_cntl add function to return the raw button value
    • will allow a user to add support for 2 buttons pressed via a FB as an exercise
  • add OR of states and test values for at least Button 1+ another button

Thursday, April 22, 2010

Apr.22 Light Sensor Clean-up

Open 4/29 
clean-up: right place for led initialization + no unnecessary duplicate code
Options: 
  • during eCos/Forte boot *(now led 1 only)
  • avr initialization *(now turn all 4 off)
  • led function block initialization *(now reinitialize)


led
Hiding the following in  inline functions and static const s
  • led initialization, 
  • port 4 initialization 
  • led on/off -  now 0 is off and 1 is on. Inverted logic was used before.
rd
Testing:
read correctly from all light ports
Port 3 Funnines was caused by design funny:
  • for led used 1 for index of first port into an array with HW pins to match standard port #s
  • for rd light sensor used this index for port #, but it was +1
Design change: led to HW array to starts with 0 and use (PORT-1) now for led and rd
Comment: led and rd are in same sensor, but different Fn Blocks in FORTE
    SW-wise first thoughts are 1 Object so 1 function block
    but HW-experts prefer separate, since functions are different.
    Different fn blocks allow differences, but easier to understand if same
    Led was hard-coded to 1 port and then later generalized - (how this really happened)

(debugging port 3 funnies described in  Apr.8- 16+ Checking out LMS HW from FORTE)

1020+ indicated nothing is plugged into a port

initialization - Both Lego & Lejos initialize all leds to off


By default  when lms is turned on leds 1-3 is on and led 4 is off.
Changed so RS485 port is initialized and all 4 leds are turned off during avr state e_INITIALIZED:
* This still may not yet be the best place /cleanest code solution. In default mode leds 1-3 had to be in the applications to turn them off even if they were not used. Extra unnecessary FBs to initialized changed the logical INIT event flow and cluttered how the application looked (was annoying and now fixed).

4/26
Trace notes:
 rd.cpp FORTE_rd::executeEvent (REQ)
             ltVal= GetSensorState(PORT);
avr_ctl.c GetSensorState(cyg_uint32 pa_nInputPort)
watch variable:  io_from_avr->adc_value



Monday, April 12, 2010

Apr.8- 22+ Checking out LMS HW from FORTE

Basic tests finished, HW working from FORTE code


Open Questions left:
Apr.22 Light Sensor Clean-up
ltsensor.rd FB (test appl(s):  blinky3rd)
test: black/white/brown  + led on/off 
Sensor 3 returns 1020 no matter what with light sensors plugged into ports 1-3
All sensors return a value around 1020 if nothing is plugged in.
If no light sensor is plugged into port 2, but a light sensor is plugged into port 3, then the value is read out when port # = 2 (!?)
  • changed sensor
  • changed cable
  • unplugged
  • turned Lego on and off
Touch - Works, but how do you tell if  its just bumped?
Motor.basic - motor does not seem to halt or turn off as expected
Buttons: How can we detce multiple buttons as inputs. Only 1 is returned at at time.

Working:  
Testcases under: LegoHW
Buttons: 2 1 4     each button is a bit.

                     8

Touch 0 = out; 1023=pushed;

Shutdown FB  (test appl(s):  TurnOff)
    No outputs since can't return something after power is off,
    however Forte export filter does not generate one 0 to indicate no outputs.  (fix coming)
   Works with hand change.

Motors A-C work as output ports 0-2 










ltSensor.led ports 1-4  (test appl(s):  blinky1; OffLed2)
  FORTE changes needed for PORT init needed have been checked in (so shouldn't reoccur)









ltsensor.rd FB ports 1-4 (test appl(s):  RdLight, OffLed2)
The lms AVR functions from Alex are in c since added on to eCos
but Forte generates C++ code so following was needed:
#ifdef __cplusplus
extern "C" {
#endif

function headers
#ifdef __cplusplus
}
#endif



Sensor Ports and led = flood light
port 4 needed additional initialization for avr  since its a rs 485 port
how lejos initializes ports

Sunday, March 21, 2010

Mar.19 LegoHW types and apps

Lego HW types (1st try):

Line1 application: overly simple line follower - if black both motors forward, otherwise just 1 motor. Will only work in 1 direction.
 
Calibrate application: calculates the on-line (Black) and off-line (usually White) boundary.