scripting in avr

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
I would like to have some scripting capabilities in the avr interface. Nothing as complicated as python script but as least flexible. Does anyone have experience with that?
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which AVR interface? Studio, Avrdude, stk500?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When I read "interface" I thought he might be talking about a run-time interface such as RS232, RS485, SPI or something. I guess we'll not know until sufficient detail is provided.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bitlash might be worth a look. It is an interpreter that runs on the AVR, and allows you to store small programs in EEPROM. http://bitlash.net for information and downloads.

The distribution version is for Arduino, but it is easily adapted to other AVRs.

-br
http://bitlash.net
http://entropymouse.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is complicated with a Python Script ? The language is simple, well strucutred and easily readbale.
If acompanied with pyserial, python is a swiss army knife.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Running a python interpreter in 8 bit avrs are not possible.

I am thinking connecting bluetooth to one of the uarts and maybe I can have a simple script interpreter there. Its for a motor drive so I can send commends like "go forward", "left turn" etc. Just just as a single commands, but like a script, each command will be executed upon completion of the last.

I am also consider xml-- as an alternative. Does any1 know running an xml interpreter inside a 8-bit avr? I am talking about xmega a3.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why the complexity at the AVR end? Surely you can bodge something together with strstr() ? In the limit output to the UART

1: go forward
2: turn left
3: turn right

then simply wait to receive 1, 2 or 3.

Sounds like you are trying to over-engineer things.

(I don't know if anyone else is old enough to remember this but I guess you might want to find an implementation of the Logo programming language and look at its command interpreter - the "turtle" had very simple command like forward, right, left and so on)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, that is sort of what FORTH is. I recall seeing at least one FORTH implementation for AVR.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Thu. Nov 11, 2010 - 08:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Its more than that. Suppose I would like to download predefined routine so that it can automatic execute the routine when powered up.

Also for loops and if statement would be nice.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bitlash has the concept of a "startup" macro, as well as "while", "if", and "switch" statements for flow control.

More here: http://bitlash.net/wiki/macros:o...
and here: http://bitlash.net/wiki/conditio...

-br
http://bitlash.net
http://entropymouse.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So you want to put BASIC on an AVR?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Its more than that. Suppose I would like to download predefined routine so that it can automatic execute the routine when powered up.

Also for loops and if statement would be nice.


No question then - I'd follow Jim's suggestion of Forth. Though Bill's Bitlash does sound interesting.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How about xml? any1 tried to implement xml on 8 bit avrs?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How does parsing XML make for an easy to use "English like" scripting language> Are you really expecting the user to type something like


  
    Left
  

or something? Again it seems like you are trying to over-engineer this. Did you look at Bitlash or Forth?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You CAN implement a monitor like tool, that does things like

DIR L
DIR R

You have to design the parser and the structure of the script, but it certainly can be done. Doing this sort of command mechanism from a terminal is pretty straight forward. So, why not do it from a data block? No UART, no command prompts, just do it!

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry for my above nonsense comment, to run a python interpreter on an 8 bit MCU is not possible indeed. I did not get the intended meaning of the question, so I guess I have to take a english class.

As for the question I would also vote for Force.

On the other hand if I google for lex/yacc + AVR I get pointed to UART strings:
http://svn.berlios.de/viewcvs/op...

But for three or four commands it might be easier to handcraft a little parser.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want a real lex+yacc parser, I once ported flex and byacc to
the AVR (in particular by moving all the constant tables into flash
ROM). I could get you the patches for this. Don't expect it to be
lightweight, but it's damn fast.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What does the lex+yacc do? Does that mean I can define some scripting language and have that do the parsing? Yes, I am interesting to know more about it. If it can fit into a 16k memory, I will consider it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can fit what you want to do in 1K..2K, there's no need to over-engineer this with some large command parsing library to handle a few commands. Let's say your command set consists of:

Go forward
turn left
turn right

Then you can ignore the extra words and just search for the keywords "forward" "left" and "right". In fact "for", "lef" and "rig" may be unique so:

if (strstr(input, "for")) {
   // forward action
}
else if (strstr(input,"lef")) {
   // left action
}
else if (strstr(input,"rig")) {
  // right action
}

Sure, if you were trying to parse 500 command words then a cascading if/else would be "cumbersome" but for a handful of commands why do you need more than this.

With the above

"at your earliest convenience please turn to the left"

would be a valid command. As would:

rig
for
for
lef

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
How does parsing XML make for an easy to use "English like" scripting language> Are you really expecting the user to type something like


  
    Left
  

or something? Again it seems like you are trying to over-engineer this. Did you look at Bitlash or Forth?

Its more like


  
    Left
  
  
    90
  

xml is not for manual typing. The reason for xml is that there are a lot of tools developed for parsing/validating xml out there in C/JAVA/Python, etc. xml can be describe in xml schema so the functions can be exposed automatically to machines, not just humans reading manuals of instruction and follow it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Tell us more about what's going to be issuing the Fwd/Left/Right commands then? If it's a computer why bother with anything ASCII (designed for humans) anyway? Have the controlling system send 0x01 for Fwd, 0x02 for Left, 0x03 for Right. No need for ANY parsing in this. If the controlling system itself wants to interact with a human and accept high level "Go forward", "turn left" style commands then fine - but let the PC parse this - the AVR doesn't need to know anything about command parsing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If all the commands were like #define LEFT 1 you could compile it into a hex file and dl it into eeprom.

Imagecraft compiler user