Pages: 1 [2] 3   Go Down
Author Topic: Is anyone using Forth in their Lilypad?  (Read 5100 times)
0 Members and 1 Guest are viewing this topic.
UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think COBOL puts full-stops at the end of sentences, and uses vaguely English-like syntax, but it has the disadvantage that it looks a bit SHOUTY.
Logged

Per Arduino ad Astra

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What happened to “Tiny Open Firmware”? Seems interesting, but any links one can find lead nowhere. What's the point of dead links? When is someone going to tidy the Internet up. In a few years, it'll be full of rubbish and nonsense at this rate.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There's a board on ebay — the Byvac BV511 — that looks ideal except that it's got sharp corners, costs about three times as much as I want to pay for it, and seems to have nobody else actually using it (which means no help from a community).

Well, I have a BV511 and it's very good (as well as being Forth-based, it's physically smaller than a standard Arduino, yet a faster CPU with more memory) but , yes, in no sense is it a Lilypad replacement.

I keep meaning to see if the Arduino bootloader can be extended with enough to have a 'three instruction Forth' setup (you work on a host, and the Arduino would do one of three things: accept a byte, send a byte, or execute some code. You still get the 'highly interactive developing on the hardware' benefits of Forth, but in a tiny space.
Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've spent a large portion of the day simply reloading amforth again and again. Every time I make a mistake (which seems to be approx 100% of the time), it corrupts and gives me

Code:
?? -13 6


in response to pretty much everything I type. I'm tempted to solder in some turned-pin sockets into the ICSP pads on the lilypad board, it'd make life a lot easier every time I have to re-burn it.
Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, so far I've yet to see “amforth-upload.py” actually work properly at all. The only means I've encountered for putting forth definitions into the lilypad is to cut and paste them carefully, line by line, minus the stack comments. This is obviously too tedious to continue with.
Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What I have achieved so far is to be able to turn the LED on and off under my control.

I typed in most of bitnames.frt and the port-relevant parts of atmega328p.frt, and then was able to type
Code:
PORTB 5 portpin: led
and then
Code:
led pin_output
and
Code:
led high
and
Code:
led low
and it worked.
Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've just taken a photo of my lilypad's resonator:
http://www.flickr.com/photos/iantindale/5214767477/in/photostream/lightbox/
I'd say that was an 8MHz resonator, as the specs say too.
« Last Edit: November 28, 2010, 02:12:46 pm by u0421793 » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6782
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, it looks like 8MHz to me too, and you said that the 328 build I made for you is working correctly; another good sign.  How's that working?  I'm learning how to make more "complete" forth builds that may or may not be useful...  This whole "every implementation is different and will have different core words present" philosophy is confusing me...

Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I didn't get a lot of time this weekend on the hacking front, but I got as far as manually blinking a LED on and off, which is a huge step forward (which I certainly would not have been able to do without your tremendous help!). I ended up having to re-burn the Lilypad I was using about six times, using another Arduino, which is nearby to hand now.

The upside: I very much like the idea of using Forth in the Arduino Lilypad (or any arduino).  It seems very “hands-on” in terms of thinking of something to do, reading through the online version of “starting forth” to remember the syntax, and trying it out, and seeing it work.

The downsides: However, this particular forth implementation seems to have difficulty staying stable. If I make a typing error, or if (as I initially was trying to do) I cut and paste a block of several lines into the terminal, I inevitably end up with an error, frequently one which is not reversible back to a working state (ie, bye no longer works, power cycling no longer works, coming out of screen and back in no longer works) and therefore requires re-burning the hex.

Overall, due to this experience, I've been thinking that using a programmer permanently hooked to the target device is not that bad a way of programming after all. Bang goes the direct interactivity, but the quick upload and reset cycle is not actually that bad.

I've also been reading more and more about Lua and eLua. I know it's not forth, but it seems friendly in about a similar quantity, and it probably isn't as alien to most 'modern syntax knowing' people as forth was.

eLua probably won't fit on an Arduino any time soon, but Lua does have a C API (which probably means it is the wrong way round for what I am hoping can be done), and I'm increasingly of the opinion now that a workflow for arduino beginners programming should run like this:

  • Lua (not eLua) as the language we first see in the Arduino app.
  • Lua hands {something - not sure} over to C to prod GCC into making the usual hex files for the Atmega
  • Arduino app puts them on there in the usual way

Based on my experience with continually reburning forth as a way of developing, I would say that Lua itself as a not particularly interactive but nevertheless rapid turnaround prototyping language would solve a lot of problems, not the least of which the quantity of people buying an Arduino then discovering you need to have a long beard and a computer programming degree to use it. I'm fairly positive that most people don't complain because they think it's their fault for not being smart enough to understand C instantly, rather than because the arduino experience is unergonomic in the software department. It is not the beginner's fault, but they're made to feel irredeemably stupid because of the requirement to suddenly know far too much before any gratification can be offered. So many people at this point will simply shut up and step back, rather than ask questions for fear of being thought an idiot.

As such, and due to the flakiness of amforth and totally baffling instructions (took me forever to realise that most of the basic essential functionality isn't even uploaded to the atmega by default - it's up to me to pick and choose which bits I want to fill the ram with and manually put it there!) I am half suspecting I won't pursue the Forth aspect for long if another alternative appears. Of course, at the moment, it's the one I will pursue that I feel I am even halfway comfortable with. It's quite alarming to discover not only how much forth I have forgot, but how much I actually never knew at all in the first place. I think my approach to learning computer languages was never very thorough, skipping anything that seemed boring or confusing, and sort of randomly guessing how the other stuff worked to get it out of the way quickly.
Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

By the way, any idea what happened to the “1ms” word? It should be defined in assembler, but seems to be missing, and that's behind the errors I've been getting when I try and define:

: ms 0 ?do 1ms loop ;

« Last Edit: December 02, 2010, 03:20:23 am by u0421793 » Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6782
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
took me forever to realise that most of the basic essential functionality isn't even uploaded to the atmega by default - it's up to me to pick and choose which bits I want to fill the ram with and manually put it there!
Yeah; me too.  That's what happened to 1ms as well.  You CAN include (all of) these at compile-time, which makes things a bit better, but I didn't realize that this, or that it was necessary, when I built the version you're using.

I haven't bricked mine yet (running on a m168 at 16MHz), but I haven't been doing anything non-trivial with it either...

My other "oops" realization was that you can't use a lot of the control constructs (looping) EXCEPT inside a word definition.  I was expecting real interpreter-style anything-goes interactivity.  And it's SILENT about such errors as well.  I put a unix forth on my mac and got nice "you can't do that except inside a word definition" errors.

I wonder if there's a LISP for AVR?  That was supposed to be the other major "easy to interpret" language from the good old days...

Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I once heard JavaScript described as “Lisp in C's clothing”.

As a workaround, I retrieved my original DualMiniLove and tried modifying the avrdude command to blow the DualMiniLove amforth eep.hex and .hex into it. I took out any command switch references to fuses (assuming it should be left as is). It seems to have worked (at a different baud rate to yours obviously), and that has the 1ms word, so now I'm going to try a few things on that. Then whatever I get I'll be able to do on a different version of the Lilypad amforth later.

I didn't get a lot done on it yesterday (saturday) as I got sidetracked fixing a digital weighing scales that had a faulty segment on its led display. Took the whole thing apart, tested for dry joints etc, everything fine, so split the LED module apart and destroyed most of the bottom half of all the segments as the red housing scraped all the LEDs off the PCB! Just wiping a finger across the PCB pretty much knackered the rest of them - very fine chip led dots bonded to a single sided pcb trace with very fine wiring from the chip led bonded to the other nearby pcb trace. Obviously not user serviceable, so quickly desoldered it. Ended up using a spare 4 digit LED display that happens to be the same common polarity, that was in my parts box. Same pin quantity (12) but with totally different arrangement (2x6 instead of all in a row). Up in the attic found some 6-way single-strand bell wire (couldn't find anything 12-core - was prepared to sacrifice a SCART lead, but all of those were only 9-way). Extended the connections out from the weighing scales through the hole for the “Kg/other thing” switch (permanently wired to Kg now) and soldered up a bit of veroboard to mate with the display hanging out loose on a pair of plastic tie-wrapped cables (fairly stiff-ish). This solves a significant problem encountered recently. You can't weigh suitcases on it because the suitcase obscures the display. Not any more! The display is on wires about 35cm away from the scales. Sorted, job's a good 'un, and that was the whole evening gone.
« Last Edit: December 05, 2010, 05:01:00 am by u0421793 » Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Gah! It's doing it again, using the DualMiniLove hexes and board. This is absurd. After making a mistake copying and pasting more than one line accidentally, all I get now is this (the second line is when I reset it):


[size=14]amforth 4.2 ATmega328P Forthduino
> amforth 4.2 ATmega328P Forthduino
> words
 ?? -13 6
> .
 ok
> words
 ?? -13 6
> 2 2 + .
 ?? -13 6
> 2
 ok
> 2
 ok
> +
 ?? -13 2
>
 ok
> words
 ?? -13 6
>
[/size]
« Last Edit: December 05, 2010, 06:56:32 am by u0421793 » Logged

London, GB
Offline Offline
Sr. Member
****
Karma: 8
Posts: 332
Nothing works.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I give in. This is no way of doing things. Months and months and nothing to show for each weekend. Utter waste of time.

I've put the bootloader back on the DualMiniLove and it works with a test sketch, I'll do the same with the lilypads for now.

There's pretty much no way forward for using microcontrollers from an artistic perspective at the current time, it would seem, but that doesn't mean it can't happen in the future.

I've just been looking at the RAD project, which essentially doesn't work, but in the meantime, a couple of people have pointed me to two different “fork” versions of it, neither of which work also.

I'll have to abandon the idea of using the Arduino in my plans for the time being, and see what else there is that can avoid exposing people to the hostility of C. There's that ByVac ARM Forth controller, but that's expensive, and therefore won't be utilised other than as a single unit for me alone to experiment with. There's eLua on other ARM platforms, which may be appealing if it can be done cheaply enough. LISP is not easy to understand, so I wouldn't understand anything in there, and therefore I couldn't help anyone if we had problems (ie, same as the current situation with C). In fact, LISP programs seem to me to be totally unrelated to whatever it is one is trying to do with it. There's never a bit in it where you can say “ah, this is where it makes stuff happen”. Or if there is, it's certainly very effectively disguised.

I don't know what to do. Yes I do. Where's my Nikon F4?

Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ian,

Forth, Lisp and other languages which treat code as data don't work too well on a Harvard architecture processor which separate code and data memory, specially if it's one like the Atmega which has very little RAM. In the special case of Forth, the best success you will have if you have a set of rather complex words which are hidden from the user behind a simple language. Lisp I would judge a lost cause on the Arduino.

Now depending on what's exactly the problem you want to solve, there are various options:

If you want to present to the user a simple interface to physical objects, consider putting the user-friendliness into the front end. This works specially well if the Arduino will be connected to a host anyway.

If you have some domain specific functions to support, you can also get away with using a precompiler / parser from a better suited language that compiles into C or a hex-file. You can use Lex and Yacc for that (although it's a bif forbidding) or one of many other ready made tools.

If the main problem is that you don't want to waste your life with C and similar languages, things get more complicated. Probably the best option is to look for processors which support Forth better (eg ARM) and invest a little more in the development platform. The charm of the Arduino is its direct to the metal environment.

So I wonder, what's exactly the problems you want to solve with the Arduino.

Korman
Logged

Pages: 1 [2] 3   Go Up
Jump to: