I want to replace the Arduino-ness on the Lilypad with Amforth but I don understand how to do it.

forth

Re: I want to replace the Arduino-ness on the Lilypad with Amforth but I don understand how to do it.

Postby Spam » Sat, 23 Oct 2010 08:51:56 GMT




I believe what you are referring to is the original Java based development 
system (wiring?) which is *NOT* C, but rather some strange and wonderful 
subset lacking all the useful bits, and with a bunch of library functions 
to take all the fun out of learning the hardware architecture.


I'm not familiar with Amforth, but in order to compile dictionary words, 
the loader will have to be based in the boot loader code page, and 
specifically compile and store the words in flash ...


I'm not sure that the serial bootloader which is included with the Arduino 
will load such a beast, as it will not overwrite itself, and you may need 
a "high power" burn using an STK-500 or AVR-ISP type device.  You might 
want to check avrfreaks.net for someone who might have done this ahead of 
you ... Oh, and Atmel have published a number of relevant ap-notes on the 
bootloader ... again, refer to avrfreaks.net

Cheers,
Rob.

Similar Threads:

1.I want to replace the Arduino-ness on the Lilypad with Amforth but I don understand how to do it.

On Thu, 21 Oct 2010, IKT wrote:

> Date: Thu, 21 Oct 2010 16:32:41 -0700 (PDT)
> From: IKT < XXXX@XXXXX.COM >
> Newsgroups: comp.lang.forth
> Subject: I want to replace the Arduino-ness on the Lilypad with Amforth but I
>     don?t understand how to do it.
> 
> I want to replace the Arduino-ness on the Lilypad with Amforth but I
> don?t understand how to do it. The Lilypad is a fabulous system in
> theory but the software side is impossible to comprehend with its
> stupid ?C? language that makes no sense at all and lets the whole
> thing down by being too difficult to actually use. A better language
> for it is badly needed.

I believe what you are referring to is the original Java based development 
system (wiring?) which is *NOT* C, but rather some strange and wonderful 
subset lacking all the useful bits, and with a bunch of library functions 
to take all the fun out of learning the hardware architecture.

>
> I?ve downloaded Amforth, looked at amforth.pdf in the TechnicalGuide
> folder, looked at amforth-userguide.pdf and can?t find any
> straightforward instructions written in normal English rather than
> technicalese that tells me how I can get my Lilypads to become Forth-
> based.

I'm not familiar with Amforth, but in order to compile dictionary words, 
the loader will have to be based in the boot loader code page, and 
specifically compile and store the words in flash ...

>
> All I need to achieve at this stage in order to evaluate whether Forth-
> based Lilypads are what I want to proceed with, is a way of getting
> Amforth from my MacBook into my Lilypad. How? I can?t see a way.
>

I'm not sure that the serial bootloader which is included with the Arduino 
will load such a beast, as it will not overwrite itself, and you may need 
a "high power" burn using an STK-500 or AVR-ISP type device.  You might 
want to check avrfreaks.net for someone who might have done this ahead of 
you ... Oh, and Atmel have published a number of relevant ap-notes on the 
bootloader ... again, refer to avrfreaks.net

Cheers,
Rob.

2.I want to replace the Arduino-ness on the Lilypad wi th Amforth but I don抰 understand how to do it.

I want to replace the Arduino-ness on the Lilypad with Amforth but I
don understand how to do it. The Lilypad is a fabulous system in
theory but the software side is impossible to comprehend with its
stupid language that makes no sense at all and lets the whole
thing down by being too difficult to actually use. A better language
for it is badly needed.

Ie downloaded Amforth, looked at amforth.pdf in the TechnicalGuide
folder, looked at amforth-userguide.pdf and can find any
straightforward instructions written in normal English rather than
technicalese that tells me how I can get my Lilypads to become Forth-
based.

All I need to achieve at this stage in order to evaluate whether Forth-
based Lilypads are what I want to proceed with, is a way of getting
Amforth from my MacBook into my Lilypad. How? I can see a way.

3.string-search-and-replace function wanted

  I would know how to write a plain and simple function
  to search and replace a substring within a string. It might
  take several hours including testing. But for something so
  common, I thought it should be easier to find some code
  for this already existing. This turned out to be more
  difficult than I thought.

  Does anyone know of a function or a string library that
  can be used as follows:

#include <lib.h>

  ...

{ char * const p = malloc( 1024 );
  if( p )
  { strncpy( p, "exemple", 1023 ); p[ 1023 ] = 0;
    char * const r = srp( p, "e", "ABC", 1024 );
    if( r )
    { printf( "%s\n", r ); 
      if( r != p )free( r ); }
    free( p ); }}

  This should print "ABCxABCmplABC". The function "srp"
  might replace within the buffer given (it knows the size
  from the fourth argument). If this is not possible, it
  tries to realloc or malloc a larger buffer. The buffer
  with the result is returned (or 0 in case of an error).
  Has anyone already written something like this?
  The interface might differ - it just should search and
  replace.

  If not:

  Does there exist a simple text editor without a UI, but a
  C-API (written in plain ISO C)?

#include <editor.h>

  ...

struct editor * const e = editor_load_from_file( "alpha.txt" );
if( e )
{ editor_search_and_replace( e, "e", "ABC" );
  char * s = editor_string( e ); /* this function is less important */
  if( s ) { printf( "buffer = \"%s\".\n", s ); editor_string_dispose( s ); }
  editor_save_to_file( e, "alpha.txt", EDITOR_OVERWRITE_OK ); 
  editor_quit( e ); }

  TIA

4.Don't understand what my program is doing

Hi,

Below is a program I wrote. In addition to storing the values of the
arrays 'f' and 'tau' in files named 'f_vs_tauxxxxxx.txt', (where
xxxxxx is the number of times the conditional loop labeled 4 has been
iterated), it is also supposed to display the following data on screen
for each iteration. (x's denote numbers)

iteration x
adfmax= x.xxxxxxxxExxx
Data written to f_vs_tauxxxxxx.txt

But the above are displayed on screen for only 6 iterations. Then the
output to the screen stops. But the calculation seems to go on until
'f' converges to the required tolerance (I know because there are a
total of 206 txt files written, not 6). It does what I want it to do.
But I don't what's happening to the screen output. Can anybody help?

And btw, there's also an unwanted file named 'fort.6' that is made by
the program.

Thanks.

PS: I checked the contents of 'fort.6' just now, and the rest of the
output I wanted to be written to screen has been written to that file.

Program follows.

      PROGRAM hmwrk6

      INTEGER i,j,NSTEPS,n
      PARAMETER (NSTEPS=10000)
      DOUBLE PRECISION tau(NSTEPS+1),mu(10),f(NSTEPS+1),b(NSTEPS
+1),a(NS
     $TEPS+1,10),c(NSTEPS+1,10),d(NSTEPS+1,10),beta(2:NSTEPS
+2,10),e(NST
     $EPS+1,10),alpha(2:NSTEPS+2,10),u(NSTEPS+1,10),uprime(NSTEPS
+1,10),
     $delta,w(10),fold(NSTEPS+1),adf(NSTEPS+1),adfmax
      CHARACTER fname*64

      delta=10.0D0/NSTEPS
      do 1 i=1,(NSTEPS+1)
         tau(i)=(dble(i-1)*10.0D0)/dble(NSTEPS)
         f(i)=1.0D0
         b(i)=0.75D0*f(i)*(tau(i)+(2.0D0/3.0D0))
 1    continue

      mu(1)=-0.97390653D0
      mu(2)=-0.86506337D0
      mu(3)=-0.67940957D0
      mu(4)=-0.43339539D0
      mu(5)=-0.14887434D0
      mu(6)=-mu(5)
      mu(7)=-mu(4)
      mu(8)=-mu(3)
      mu(9)=-mu(2)
      mu(10)=-mu(1)

      w(1)=0.06667134D0
      w(2)=0.14945135D0
      w(3)=0.21908636D0
      w(4)=0.26926672D0
      w(5)=0.29552422D0
      w(6)=w(5)
      w(7)=w(4)
      w(8)=w(3)
      w(9)=w(2)
      w(10)=w(1)

      do 2 j=1,10
         a(1,j)=0.0D0
         d(1,j)=1.0D0+(mu(j)/delta)+(delta/(2.0D0*mu(j)))
         c(1,j)=mu(j)/delta
         beta(2,j)=c(1,j)/d(1,j)
         do 3 i=2,NSTEPS
            a(i,j)=((mu(j)**2.0D0)/(delta**2.0D0))
            d(i,j)=1.0D0+(2.0D0*((mu(j)**2.0D0)/(delta**2.0D0)))
            c(i,j)=(mu(j)**2.0D0)/(delta**2.0D0)
            beta(i+1,j)=c(i,j)/(d(i,j)-(beta(i,j)*a(i,j)))
 3       continue
         a(NSTEPS+1,j)=(mu(j)/delta)-0.5D0
         d(NSTEPS+1,j)=0.5D0+(mu(j)/delta)
         c(NSTEPS+1,j)=0.0D0
         beta(NSTEPS+2,j)=c(NSTEPS+1,j)/(d(NSTEPS+1,j)-(beta(NSTEPS
+1,j)
     $*a(NSTEPS+1,j)))
 2    continue

      adfmax=1.0D0
      n=0
 4    if(adfmax.ge.1.0D-6)then
         n=n+1
         write(*,*)'iteration',n
         do 5 j=1,10
            e(1,j)=(b(1)*delta)/(2.0D0*mu(j))
            alpha(2,j)=e(1,j)/d(1,j)
            do 6 i=2,NSTEPS
               e(i,j)=b(i)
               alpha(i+1,j)=(e(i,j)+(alpha(i,j)*a(i,j)))/(d(i,j)-
(beta(i
     $,j)*a(i,j)))
 6          continue
            e(NSTEPS+1,j)=(b(NSTEPS+1)*(0.5D0+(mu(j)/delta)))+
(b(NSTEPS)
     $*(0.5D0-(mu(j)/delta)))
            alpha(NSTEPS+2,j)=(e(NSTEPS+1,j)+(alpha(NSTEPS
+1,j)*a(NSTEPS
     $+1,j)))/(d(NSTEPS+1,j)-(beta(NSTEPS+1,j)*a(NSTEPS+1,j)))

            u(NSTEPS+1,j)=alpha(NSTEPS+2,j)
            do 7 i=NSTEPS,1,-1
               u(i,j)=alpha(i+1,j)+(beta(i+1,j)*u(i+1,j))
 7          continue

            uprime(1,j)=((4.0D0*u(2,j))-(3.0D0*u(1,j))-u(3,j))/
(2.0D0*de
     $lta)
            do 8 i=2,NSTEPS
               uprime(i,j)=(u(i+1,j)-u(i-1,j))/(2.0D0*delta)
 8          continue
            uprime(NSTEPS+1,j)=((3.0D0*u(NSTEPS+1,j))+u(NSTEPS-1,j)-
     $(4.0D0*u(NSTEPS,j)))/(2.0D0*delta)
 5       continue
         do 9 i=1,(NSTEPS+1)
            b(i)=0.0D0
            fold(i)=f(i)
            f(i)=0.0D0
 9       continue
         do 10 j=6,10
            do 11 i=1,(NSTEPS+1)
               b(i)=b(i)+(w(j)*u(i,j))
               f(i)=f(i)+(4.0D0*w(j)*(mu(j)**2.0D0)*uprime(i,j))
 11         continue
 10      continue
         adfmax=0.0D0
         do 12 i=1,(NSTEPS+1)
            adf(i)=dabs(f(i)-fold(i))
            if(adf(i).gt.adfmax)adfmax=adf(i)
 12      continue
         write(*,*)'adfmax=',adfmax
         write(fname,fmt='(A,I6.6,A)')'f_vs_tau',n,'.txt'
         open(unit=n,file=fname)
         do 13 i=1,(NSTEPS+1)
            write(unit=n,fmt='(1X,E16.8E3,TR2,E16.8E3)')tau(i),f(i)
 13      continue
         close(n)
         write(*,*)'Data written to ',fname

         goto 4
      endif

      END

5.amforth assembler

I would appreciate examples of usage for the contents of
assembler.frt, or a pointer to a document which does this. As forthers
know, forth assemblers don't all have the same syntax. Among the
details is the treatment of literal numbers.

6. Forth on Arduino?

7. Serial communication w/ arduino board

8. Controlling endian-ness? (Example: Attribute Overriding)



Return to forth

 

Who is online

Users browsing this forum: No registered users and 83 guest