Sunday, October 31, 2010

Oct.31 LMS 61499 Segway is possible now!

This application can be created now with the existing LMS FBs


 Hardware:
  • Light Sensor
    • red light turned on 
  • 2 Motors
    • adjusts based on PID
      • direction  forward/backwards base
      • duration based
  • Ultrasonic Sensor - not connected - used to look like a head.
Two topics:
1. NXT Segway description vs. actual results
2. What is needed for a lms event driven (IEC 61499- fordiac) Segway?


1. NXT Segway description vs. actual results
The NXTprograms NXT Segway with Rider   "This robot simulates a Segway PT "
The project construction was straight forward. With the exception of the axle between the wheels, parts were easy to find and could be used as is. The axle had to be modified. The 2 wheels are connected so they move together to avoid drifting to the side.

The Usage Information in the Building Instructions were extremely helpful.
The NXT-G program worked as described and is well commented. And was it was nice surprise it worked on both a solid tan and solid gray surfaces with normal lab lighting.


There are links to PID descriptions and alternative LMS self-balancing robots such as the
alternative NXTway with both light sensor and gyro sensor versions.
Fail safe: The program shuts off, if the PID value is not reasonable indicating it has probably fallen down.

The blue tooth version is unique to this construction.


2. What is needed for a lms event driven (IEC 61499- fordiac) Segway? 
The basic NXT-G code / algorithm  is:
  1. Initialize using the robot's initial value as the goal value
  2. Adjust motors forward or backwards based on the PID correction 
  3. If the correction value unreasonable - Stop

In theory this can work now in fordiac. The only known potential for error is, if the signal to motor is not sent timely. 1st Draft Application/Tests can use existing robot and lms FBs from summer.

FBs needed:
  • Provided: 
    • E_CTU,; 
    • F_NOT; 
    • E_DELAY (3 pre-calibration/balance warnings); 
    • E_CYCLE;
  • lms pallete: 
    • LED; 
    • LT (read light reflection); 
    • MOTOR (sent power setting)
  • utility/ cntlr pallete:
    • PID; 
    • BTW (is # BeTWeen 2 numbers)

Friday, October 29, 2010

Oct.29 clean lms Forte; laptop dev; NXT-G Segway

For break at the end: downloaded NXT-G NXT Segway with Rider  
It works on solid gray desktop and solid tan table. Trick is balancing it well by the third beep.


Note: Video edited and clipped with MPEG Stream Clip.

clean lms Forte - continued creating a clean version of lms forte with minimum files


Development on laptop

The main open issue is how to install drivers so it works and Vista funnies.

JTAG-edu : recognized by both Alex's PC and my laptop

On Alex's PC:
Samba ok following blog instructions for flashing
OpenOcd let me flash

On Laptop:
LMS:   recognized as a libusb-win32 device --> eCos USB Serial Device
It only shows up after the boot squence blinking if finished. When Forte adds the LMS_DEVice.
Sometimes thought eCos device was Lego... then could flash it through LMS Firmware update back to Lego. Still don't have a pattern how Windows choses a  device driver!

BUT Sam-Ba doesn't see it.  (main open issue!)
Sam-Ba 2.9 sees JLink, but not the .-.l--ö-------------------------------ööööööööööööööööööööö----ö-öö_
!
Miscellaneous Links: 
Flashing LMS with SamBa
Sam-Ba for Vista: (installed on laptop)
specifically:


Driver info: USB CDC/ACM Class Driver for Windows 2000, XP, Vista, 7

C++ style links: http://www.possibility.com/Cpp/const.html

Interesting "Examples":

MakerLegoBot: Lego Mindstorms NXT 3D Lego Printer

NXT Segway with Rider (also with tilt control via BT) 

Sideline: Dave Miller from KISS BoeBot is here and will hold a workshop Tue at TU and Th. at TGM.   Will possibly try to install (PLT) Scheme on CBC.

 

Oct. 28

Finished building the basic 4DIAC/FORTE on stick.
And used the 4DIAC on the stick to create and export 4 lms FBs (OFF, LED, TOUCH, LT).

4DIAC-IDE (minor) problems
same old problem:
It requires you exit and enter to see new Systems; Type groups; and export filter.
This can definitely confuse new users and is annoying, but must be included in Tutorials.

Blanked out  author field in properties of new SIFB, so no author tag was filled in. Exported the SIFB fine, but next time re-entered IDE it gave a java null pointer error. Added the tag in manually. It appeared to work at first, but may messed up some internal db. Now the type group never shows up in the drop-down when creating a new FB in Type Manager. However the group name can be typed in and appears to work fine.

LMS arch/ecos C++ style - #defines vs. constants
Used #define s in summer since that is what Atmel include uses. After short discussion.. if its a number then will change to a constant, if it reads or writes - then will use #define. However #define will be used in a method, except in lmsmain. For lmsmain, fast is more important, but using #defines lets the same code be used to initialize leds.

Wednesday, October 27, 2010

Oct.27 new LMS Forte cont.

4diac-ide clone from hg works. Forte from clone hg needs minor changes.
At moment many  more FBs are compiled by forte than LMS's limited memory can hold.
Changing configure.in and makefile.am so conditionally compiles only what LMS needs.

Initially a 64bit #define flag was not set in a forte file - which caused an error. (corrected)

Then added an use_lms conditional to configure.in and used in set-up shell script and makefile.am, so only function blocks needed by lms are compiled.

In process a hg clone repository has been set-up on Q a common hard drive, so changes to be pulled into the official web-hg version. Local clones are being tested on laptop, aa, and usb stick.

The goal is a set-up where different hardware device interfaces can be tested at the same time a version with finished hardware interface and function blocks is being created, tested and used in labs etc.

Monday, October 25, 2010

Oct. 25+ LMS Passive sensors and IEC61499 adaptors

Should IEC61499 adaptors be used /taught? 
Using:
  • LMS passive sensors 
    • raw value read = 0-1023, but FB interface output variables might return:
      • raw value
      • extracted value like True or False
  • All LMS Sensors
Commonality:
  • All Sensors:
    • INIT event:
      • reserves PORT# to the first sensor FB type
  • Passive Sensor Read Value
    • Sensor value read internally is always 0-1023
    • 0 if no sensor is plugged in
    • If FB says its touch sensor, but light sensor plugged no way to flag as an error


Oct.25 LMS 4DIAC-IDE and FORTE on a stick

Creating a version of 4DIAC-IDE and FORTE already set-up with LMS Palette.
It should be  a zip that can be used as soon as its extracted even on an USB stick.

4DIAC-IDE 
  • clone from hg (synchronize, test, export)
  • copy into 4DIAC-IDE directory:
  • template directory from hg 
  • typelibrary with default configuration FBs
    • working on lms palette to be included with:
      • OFF- turns the LMS off (=shutdown)
        • OFF is a shorter name than shutdown
      • LED- light sensor led
      • TOUCH
      • LT (reads light sensor value)
  • set preferences 
    • looking into using system variable for current path in 4diac-ide code: 
      • org.fordiac.ide.fbrtLauncher\src\org\fordiac\ide\fbrtlauncher\preferences\PreferenceInitializer.java
    • FORTE
    • FBDK 
  • export all lms /lms FB types

FORTE
Stage 1: (compile hg version)
  • clone from hg
  • copy in ecos include and lib directories under bin/lms directory
  • run setup_lms.sh
  • run bin/lms/make all 2-3 times until only get a compile error
  • change src/makefile.am to include the whole lms pallete and only FBs needed 
    • see if easy to add lms conditional variable to configure.in
  • E_SWITCH
  • E_CYCLE
  • E_RS
  • E_SR
  • E_CTU?
  • E_DELAY?
  • run bin/lms/make all 
    • Note: This executable will do nothing yet because  lmsmain.cpp still has the empty default code.
Currently HERE
    Stage 2: (compile to run on lms) 
    • copy in the src/arch/ecos/lms the minimum files needed:
      • lmsmain.cpp
      • arv_ctl.c / .h
      • i2c_at91sam7sxxx.c / .h
      • Buttons.c/ .h
      • Port reservation files (sensor INIT service)
    • run run bin/lms/distclean
    • run bin/lms/make all until no errors
    • Flash LMS NXT with forte.bin
    Stage 3: Ready for lms HW FBs and user exported FBs and FB downloads via deployment 
    •  start USB ethernet bat
      • would be nice if bat file could be connected into deployment directly
    • deploy application to LMS NXT

    Friday, October 22, 2010

    Oct.22 Back to project progress blogging

    Daily progress will go in blog
    ... now summary information is being collected in the portable wiki not in blog entries.

    Environment changes:
    Virtual Boxs (Win7, Ubuntu) and portable Wiki  on different USB devices
    Want 4diac/forte also on a fast USB.
    (so can document when waiting on VB to start) 
    Built hg versions
    4diac hg:
    1. hg clone
    2. import into Galileo (modelling tools) Eclipse 
    3. syncronise, test, export to build 4diac-ide
    4. copy into the built 4diac directory:
      • hg template directory
      • typelibrary directory which will be used for default 
      • know where an fbdk is for 4diac-ide preferences
    Forte hg on:
    1. laptop C: and H: drives
    2. Alex's PC C: and Q: drives
    • lms set_up shell
    • make all 
      • need to edit make file so only FBs needed are included
      • Lab Nov. 8 Di. Blinky (Flip-Flop) 45 Minutes''' - need tutorial
    • Problems: 
      • cygwin errors when on USB
      • Spaces in directory or filename cause cygwin problems
      • cd to pwd will be removed from lms shell script
    Flashed LMS with SAM-BA by downloading Lego Firmware and sending it to Lego
    • VT1 (win98) saw it was an ecos device although no drivers installed
    • Plugged lms into laptop with ecos - had no idea any device was attached.
    • Plugged into laptop (WinVista) nothing!
    • Plugged into Alex's PC (Win98) and nothing at first. Powered on with reset button pushed. Then Sam-ba recognized it.
    Noted links in wiki to:
    cmake (easier to have makefile configuration per application) - coming to 4diac in Nov. (I hope)
    and hg to set up a repository and branches for lms fb palette.


    in Virtual Box: Win7
    Can LMS be used with standard LMS SW and downloaded from a Virtual Box (VB)?
    1.  Lego Mindstorm NXT 2.0 Software is installed in VB (not on host= laptop)
         Goal to program LMS and download program
    Did Program the LMS provided RoboCenter >Machines>Color Sorter example

    Connected the LMS to the laptop:
    • Host (Vista) reaction:
      • Installed unknown device
      • Couldn't find in device list, but when turned off device list refreshed
    • VB reaction:
      • crashed  
        • when tried to switch back to it in full screen mode. 
        • first a message about needing more memory
      • would not restart - gave error
      • restart of vista system ok
      • after restart: Win7 VB started in safe mode
      • after Win7 restart - able to program again.
    • Finish program - save after every step
      • Just like it did 2 years ago when I first used LMS - the UI is very, very slow and you can see everything. In this case the motor blocks at the end. 
      • Finished - but not tested
    • Will want to compare to what event driven program would look like.
    Snapshot of VB
    • Connected LMS to VB (check under USB devices)
    • It kept going on and off
    • Finally managed to start download while it was detectect
    • And ColorSorter.rbt downloaded from VB on to the LMS!!!
    • (details: lms ACIN = USB Devices> unknown device 0694:002)

    Wednesday, October 13, 2010

    Oct.13 Lego, ecos, Samba and usb Drivers

    • Lego NXT Mindstorms 
    • ecos
      • Put the following files in their own directory. 
        •  usbser.sys 
          •  C:\WINDOWS\system32\drivers\usbser.sys
          • hint in an ecos forum about ecos slave devices:  "For windows, copy the INF file and the 'usbser.sys' driver from your version of Windows into a directory, plug in the device, and when prompted, navigate to the INF file."
        •  eCosUsbSerial.inf
          • C:\sourceware_ecos\ecos-3.0\packages\io\usb\serial\slave\v3_0\host\windows\ eCosUsbSerial.inf
      • When Windows asks for the local of the driver. Enter this directory name.
    • Samba
    • libusb-win32
      • to create your own usb .inf and .sys for any generic USB device
      • NOT needed for LMS
      • libusb can be used with any good .inf and .sys files for usb devices

    Wednesday, October 6, 2010

    Oct. 5 Sampling - ECycle

    Started using EDelays just to get the applications to work when trying out the algorighms using GUI on PC for simulation. But on real device need to sample at regular intervals. Since EDelays do not guarentee time between samples because of delay time to execute other Function Blocks. 

    Better Solution: ECycle - sends out request at regularly timed intervals. 
    Of course the sample rate chosen must be greater than the execution time of all FBs used in the cycle.