Friday, April 30, 2010

*Apr.30 Duplicating Install / Dev.Env

Following will be what needs to be installed and how to be able to develop IEC61499
applications on more the one current development PC. Currently just list of tasks / notes.

Usual 4DIAC/ FORTE required SW
  • Java SE6
  • cygwin
  • 4DIAC (for LegoMS)
  • eclipse C++ (gnu-arm-elf g++);

see Quick set-up guide in Wiki

In addition to standard 4DIAC SW
Debug Environment
openocd for arm-elf-insight

    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

    Wednesday, April 28, 2010

    Apr.28 CalibrateBnd Basic FB Tests on Brick

     Online Test used on LMS brick (in test) 
    Note: Starting with led off means the first sample is darker than the rest and should not be used.  cnt1 is now initialized to 0 and the 1st data sample is not added in.













    Basic Test used on LMS brick. 
    Note: leds 2 & 3 turned off since default state currently is on.  Delays help see results. GDB Debugger was not used/ necessary.

    *Apr. 28+ Port Manager FB

    A mechanism is needed to avoid:
    • multiple sensors types used on the same port
    • to encourage application developers to only use 1 FB for 1 physical sensor / motor.
    Related notes will collected here and formatted as the ideas become better formulated.

    Open Questions:
    • Can Port assignment / use be required / enforced using FBs?
    Simple Mgr can check if the port is taken and reserve the port#,  but no check if its used.
    • Should input ports (sensors) &output ports (motors) be managed together or separate?
    In other words should there be an Lego Brick FB or 2 port managers? Leaning toward 2 port managers at the moment.
    • Port / sensor Initialization at start-up or when first used?
    If the leds are initialized when the AVR is, then no need when the led FB is used.
    Extra work to initialize all 4 leds even if they are not used.

    Or should initialization be moved into FBs or allowed as an option?

    Sunday, April 25, 2010

    * Apr. 26 Firmware Flashing - general

    Lego Mindstorms 
    •  Update to latest Lego Mindstorms firmware
      • start Lego Mindstorms SW
      • open NXT window 
      • update firmware
    • to restore Lego Mindstorms firmware
      • connect the NXT to the PC 
      • start Lego Mindstorms SW
      • open NXT window 
        • The NXT brick should be available
      • push the reset button with a paper clip 
      • in Mindstorms SW do a firmware update
      • NOTE: If reset and then go into Mindstorms SW brick will not be available.
    Lejos
    • connect NXT to PC
    • upload the firmware via eclipse lejos button (top) or via cmd line
    eCos + Forte   
    Normal mode coming this week....
    currently only debug options
    see Apr.19 Samba mode Firmware flashing

    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 19, 2010

    Apr.19 Samba mode Firmware flashing

    Currently the firmware is flashed with eCos and Forte FBs via JTAG. (so unplug JTAG USB cable)
    Samba mode via sam-ba v2.9 flashes the firmware via USB like Lego Mindstorms and Lejos upload does.

    1. Press the reset button with the end of a paper clip. Since the display is not yet working with Forte,  we 
    • take out the battery, 
    • press the reset button, 
    • put the battery back in, 
    • press orange power button.
    2. When hear the device is connected to the PC, click on the device symbol.
    The message shown in the picture below should appear. 
    (or at least hear a device was connected to PC)






    3. Open Sam-ba and connect
    (Important: that it says \usb\ARM0 and at91sam7s256-ek indicating its the Lego MS that it wants to connect)









    Sam-ba flash page appears
    4. In Send File select the most recent forte.bin and press the Send File button


    • unlock yes
    • lock no
    • (close window)
    5.  Power off / on so forte boots (see with blinking led in PORT 1)

    Ready to test / work again

    Sunday, April 18, 2010

    Apr.18 CalibrateBnd Basic FB Tested (simulation)

    Calibrating average color and boundary between colors was tried previously as a composite FB ( Mar.23 Calibrate as Composite FB + FindLine)  This version was hard to test via simulation using FBDK due to extra delays needed for output.

    The following is a Basic FB version of calibration and has been tested using FBDK.

    The FB reads N samples on-the-line, then N samples off-the-line. The steps are: 

    • led on (light sensor positioned over line)
    • on-the-line read N samples
    • led off (move so light sensor positioned off the line)
    • [delay will go here]
    • led on (light sensor positioned off the line)
    • on-the-line read N samples
    • calculate average boundary between on and off the line

    Interface 

     

     

     

     

    Execution Control Chart (ECC)


    Friday, April 16, 2010

    Apr.16 Firmware Flashing

    Use an open paperclip or similiar to push the reset button under NXT
    when clicks NXT is in reset mode

    From Lego Mindstorms Software
    in NXT window update firmware from Lego Mindstorms package
      also loads Lego firmware if following firmware is on the NXT: lejos

    Samba mode

    Tuesday, April 13, 2010

    Apr.13 gdb via arm-elf-insight forte

    1.  Change gcc optimize level to -O0 from -O3
    make dist clean followed by make all

    Note:  FORTE grows from around 160k to 230k so lower levels of optimization only help for very small applications since 256k is max available.

    1b. run openocd_flash.bat 
    2a. run  openocd.bat

    2b. In cygwin start:  arm-insight-elf 

    current path: (if gdb does not remember for you)
    aa@automatix /cygdrive/d/AA_local/eclipseWork/forte_lms_neu/bin/lms/src
    $ arm-elf-insight forte

    3. In gdb 
    • run connect to target
    • wait
    • in Console window:
      •  monitor reset
      •  monitor halt - so can set breakpts
      3b. Set breakpoints
      No more than 2 breakpts, since chip only allow 2 breakpoints
        and only 1 breakpoint, if you want to step because 1 breakpt is used for stepping
      •   select source file 
      •   -    next to a line indicates where breakpoints are possible
      •  click  on - to set breakpoint for a line
      •  verify via view/breakpoints 
      • delete extra breakpoints
      Note: if drop-down for select source has disappeared, close all windows except source (main) window and  console window;  exit gdb; restart in cygwin
      4. after settting the breakpoint  then...
      • continue (far right of run symbol)
      • wait for  boot to finish indicated by: blinking / sound of a device connecting to PC
      5.  run download program in java eclipse
      6.  download application from 4diac
      Stops running at breakpoint
      7. examine state at breakpoint
      can now view/ local variables or watch
      QI is really a #define
       so use the form this->mpapp0DI[0] for watch expression

      NOTE: C++ will not compile if gdb is open!

      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

      Wednesday, April 7, 2010

      Apr.7 Can work!

      Bad JTAG to Lego cable replaced so can test on Lego HW !!
      Working on using PORT as input:
      Test works, but gets error message.
      Reason: INT was commented out in code to save space 
      256Mb Flash is small so need to keep FORTE small so room for applications
      see eclipseWork\forte_lms_neu\src\Makefile.am 
      ex:
      forte_SOURCES += core/datatypes/forte_uint.cpp
      #forte_SOURCES += core/datatypes/forte_usint.cpp

                   


      Debugging (stepwise) simple line1b algorithm via simulation
      • learned new tricks about testing with FBDK FBs for UI.
        • composite  FB includes 
          • Java imports entered via click on compiler (import fb.rt.hmi.*;)
          • when save the package name is added to this information
        • 4DIAC xmls and FBDK java/class files
          • open 4DIAC xmls in the workspace/system/typelibrary group
          • saved under FBDK src/package_name directory
        • FBDK FBs for UI.
          • FBs can be tested under FBDK without an application!
          • if INIT event path comes back to the REQ of an FBDK FB and the event is sent to the REQ, but no CNF sent, then add an E_DELAY with small time between the send and the REQ input. (=FBDK error workaround)

      *FBDK FBs in 4DIAC-IDE/FORTE

      HInts how to use FBDK in combination with 4DIAC.
      (under construction)


      From Mar.3 post
      1. 4DIAC: Develop Application and FB Types
      2. FBDK editor parse: Check for basic and composite FB errors    
        (no Structured Text error checks currently in 4DIAC?)
      3. FBDK editor save as: 
        • Converts the updated XML to Java class (fb.rt.fbTypeGroupName)
        • Compiles to Java classes in FBDK
      4. 4DIAC: Add fbTypeGroupName to FBRT preferences
      5. 4DIAC: Add new FBs where needed in application
      6. 4DIAC: Test via Deployment of FBRT in 4DIAC
      Can test FBs in FBDK without an application!

      Symptom: Event is sent, but the FB doesn't react to the event:
      Reason:   (in FBDK) Certain feedback requests (INIT connections come back to the REQ)need Solution:  an E_DELAY before the REQ.

      Friday, April 2, 2010

      Apr. 2 LMS openocd-flash screenshots/problems

      If JTAG quits, then
      • turn off LMS (switch or take battery out)
      • unplug usb to JTAG and plug back in
      • wait for JTAG to boot (blinking light)
      • turn LMS back on

      Looking for a pattern on when
      • VLOW and 
        • looks like problem was broken wires in the connector from the JTAG
        • also if the lms is plugged in then FORTE is running, which may use more power than what is coming from charger 
          • (so need to look into power management later)
      • broken pipe problems 
        • unknown eclipse problem - but did occur with arm-elf-insight was running
      occur:
      • to avoid these problems
      • to find the simplest or at least some consist way to get LMS openocd-flash to work again
      Don't yet have a full set of fully working screen shots, nor screenshots as soon as problems start.
       
       LMS openocd-flash screenshots
       with no problems: (from 2 Apr.)











      openocd.bat with no errors











      java eclipse - run also worked correctly (no screenshot)
      Mistake: in 4diac-ide / deployment clicked on launch forte instead of download

      unfortantely didn't take screenshot first time Vlow problem occurred
      with Vlow problem (from 2 Apr. - plugged in, 2nd time)
      Webpage partly shown: http://powerelectronics.com/news/converter-controller-ics-0428/

      LMS continually clicks, showing it is firmware reset mode  
      • openocd-flash.bat downloads to firmware, it must hang / have problems after going into firmware reset mode. 
      • The clicking eventually stopped, but not clear why.
        • Tried reseting the firmware for an LMS with LEGO default Mindstorms firmware. It continued to click until its firmware was updated (via LEGO Mindstorms SW).
      • LMS when turning PC on and off
        • Turn computer off and LMS stays on
        • Turn computer on
          • LMS turns off at some point when the user id is being signed on to (not during boot up)
        • PC on / Press orange button
          • led turns on
          • lms starts to click and PC sounds like a device was connected
          • after some time: 
            • PC sounds: device disconnect
            • LMS clicking stops, 
            • led turns off 
      • Tried updating firmware from LEGO Mindstorms
        • The NXT brick was not found
          • either device not recognized by PC
          • or what is currently on the NXT brick makes unrecognizable
      Vlow value:
      • 1.47-1.55 with USB plugged in to the LMS
        • same value with or without the battery pack in the LMS!
      • 0 when USB is not plugged in to LMS
      • JTAG error if its USB is not plugged in
      • 3.2 but then get -902 error, next time back to Vlow error














      -902 error (battery plugged in and fully charged)
      Also the PC:
      • pops up a unrecognized device connected message; 
      • device connection sound; 
      • shortly afterwards device disconnect sound
      Beforehand arm-elf-insight  followed by open of forte.exe worked.




      Thursday, April 1, 2010

      Apr.1 Line Follower with 1 Light Sensor


      Line Follower with 1 Light Sensor
      No findLine yet, so only follows curves in 1 direction.
      Tests: basic design set-up, LightSensor, 2 Motors, and simple turn.
      Start: SetRdState.R
      • calibrate on line
      • calibrate off line
      • if black both motors fwd                        else 1 motor fwd