Any Experience with LunaAVR programming Language?

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

Hallo,
esterday I have seen a new Language LunaAVR, it seems a real nice Language, wich combine many good things from C, Pascal.
HEre you can see the Syntax, its easy to understand like Pascal, but have features like C!!

Does anybody else have experience with LunaAVR?
Does anybody written an larger Projekt with this?
Because at this moment, I think about, to buy e-Lab AVRco Pascal Pro for over 1000€ or to use LunaAVR for free!
The Page is only german, but google side Translator should correct that ;-)

Lcd.luna
'***************************************************************************
' Title       : lcd example (internal interface)
' Last updated: 24.08.2012
' Target      : LCD HD44780 ?x2 (16x2, 20x2, ..)
' Compiler    : LunaAVR 2012.r7.beta build 3390 or newer
'***************************************************************************
 
 
const F_CPU = 16000000
avr.device = attiny2313
avr.clock  = F_CPU
avr.stack = 16
 
dim i as byte
 
' Die Signale können an *beliebigen* Port-Pins des Controllers
' angeschlossen werden. Sie müssen *nicht* einer Portgruppe
' angehören (PortA, PortB, ..).
lcd.PinDB4  = portb.0
lcd.PinDB5	= portb.1
lcd.PinDB6	= portb.2
lcd.PinDB7	= portb.3
lcd.PinEN	= portb.4
lcd.PinRS	= portb.5
 
'Initialisierung durchführen
lcd.init
'Cursor einschalten und blinken lassen
lcd.cursor.enable
lcd.cursor.blink.enable
delay()
delay()
delay()
 
'blinken abschalten (deaktiviert auch den Cursor, Herstellerabhängig)
lcd.cursor.blink.disable
lcd.cursor.enable
 
'Einzelnes Zeichen ausgeben "A"
lcd.char 65
delay()
 
'Cursor sichtbar versetzen
for i=0 to 3
  delay()
  lcd.cursor.right
next
'Formatierte Zahlen ausgeben "00" bis "99" (zur Vermeidung von str() bei kleineren Controllern)
lcd.number 23
delay()
lcd.char asc(":")
delay()
lcd.cursor.set 1,9
lcd.number 1
delay()
 
lcd.DefChar smily,0					' Eigenes Sonderzeichen definieren (0-7 möglich)
lcd.DefChar heart,1					' Eigenes Sonderzeichen definieren (0-7 möglich)
 
lcd.cursor.set 2,1					' Cursor positionieren
lcd.textd "Hallo Lcd "+chr(0)+chr(1)	' Text und eigenes Sonderzeichen ausgeben
delay()
delay()
 
'Gesamten Anzeigebereich verschieben
for i=0 to 3
  lcd.screen.left
  delay()
next
delay()
for i=0 to 3
  lcd.screen.right
  delay()
next
 
'Ende des Beispiels
do
loop
 
' Erstellt mit Lcd Zeicheneditor in der LunaIDE
data smily
  .db 0b00000
  .db 0b01010
  .db 0b00000
  .db 0b00100
  .db 0b10001
  .db 0b01110
  .db 0b00000
  .db 0b00000
enddata
 
data heart
  .db 0b00000
  .db 0b00000
  .db 0b01010
  .db 0b11111
  .db 0b11111
  .db 0b01110
  .db 0b00100
  .db 0b00000
enddata
 
 
 
procedure delay()
  waitms 250
endproc
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I cant see any real advantages over C/C++, so why opt for an obscure language that has limited audience?

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

?
It's easer to read, easier to handle.
Like PAscal, many people work with PAscal, but very less have problems!
Mostly newbies ask some question about, but then they don'T need much support (I know it from myself :-)
With C I have so many problems to make an Projekt, I have to ask more often, the Libraries are from users, those are not so Userfreindly to use, like professionell ones.
This is the Reason for AVRco Pascal too!
Many Professionals work with this! But nobody knows ;-)
Because its so quick and easy to make an Professionel Projekt and make quick money.

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

Quote:

It's easer to read, easier to handle.

I must be missing something - how is the above any "easier to read" than C? Is it simply for people with an aversion to using punctuation symbols such as { and }? You can always:

#define begin {
#define end }

in C if you want. It makes the code (in my opinion) LESS readable and certainly less portable but the option is there for those who don't like messy { and } ;-)

I can certainly see arguments for "other languages" like Pascal and Basic in addition to C and C++ but I don't see the point in having to learn a whole new syntax of a brand new language unless it delivers some radically important improvement over the established languages that most people have been trained in.

So what is the killer "must have" feature here? Or is this just another "me too" language?

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

I used this type of define the first time I learned C: one of the biggest disadvantages is that vi -it was vi, without m- is programmer oriented and could find (it always can) the matching curly braces defined BEGIN cannot (it is one of my favorite errors).

Has gnat been ported for avr's -I know gfortran has not-

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

Quote:

Has gnat been ported for avr's

http://sourceforge.net/p/avr-ada...

For example:

with Avr;            use AVR;
with Avr.Mcu;        use Avr.Mcu;
with AVR.Real_Time.Delays;

with Lcd;

procedure Lcd_Test is

begin

   Lcd.Init;

   loop
      Lcd.Clear_Screen;
      Lcd.Put ("Hello, AVR-Ada!");

      delay 2.0;
   end loop;
end Lcd_Test;

which looks very like "LunaAVR" in fact! (except with semi-colons ;-))

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

Well, I caved in and started using C 'cause "everything" is documented and "all" library code is in seemingly indecipherable C.

Perhaps I'm just trying to unscrew the inscrutable?

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

LunaAVR is still in development and is even greater. Apart of the fact that is very easy to learn, it comes with object oriented programming features which can be useful for Arduino people. But you can program also in the procedural way. It is also offering bit manipulation support, no need of complicated C macros to mask the complexity (from a PIC programmer perspective).

But the best of all, in most cases, the compiled code is equal and even smaller than the one obtained in avr-gcc with much less effort.

 

And is not only this. It is a great development suite with a crossplatform IDE (Windows and Linux), assembler/disassembler/linker/debugger (does not use gcc in any way), and it knows everything about the generated code and it can show you (graphically) where every object is stored in the flash and ram.  It is amazing that this is free. It offers more useful features than a commercial package is offering  (e.g., CodeVision, Atmel Studio).

 

Really, it doesn't need an effort to learn it as the entire process is a real pleasure. It was a pleasant surprise for me knowing how horrible code generates mikroe compilers (all languages), BASCOM and even the Arduino cocktail.

 

So, is a good thing to recommend it to beginners but I bet that also the professionals can find it at least interesting. Congratulations and many thanks to the author!

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

Quote:

A Luna program requires a minimum of three definitions:

  1. What microcontroller should be used (“device”)

  2. What clock rate is given by fusebit and hardware (e.g. quartz) (“clock”)

  3. Stack size (“stack”) - What does stack mean?

 

Really, a toolchain that needs me to work out my stack size? How quaint.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

Actually, that is the only thing that is unclear to me - it is on my agenda to ask the author, but always forget to do it...  I won't mind if he explains why I have to do this myself and how to calculate the required size.

 

Anyway, in the manual we can read:

Quote:
STACK-SIZE

The required stack size depends on the number of parameters and local variables and cascading level of method calls. Cascaded calls add their number of required byte. A method requires at least 2 byte (Return address). Parameters and declared variables come on top.

 

It is awkward that it must be guessed by the user, but at least, there is a warning when the stack overflows - in this case we just increase the reserved size. Well, for me it is the only annoying thing - not big of a deal.  In the end, I'm willing to do it as I am pleased with the language features and the final result.

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

funlw65 wrote:
It is also offering bit manipulation support

Where?

 

The only "bit" operators at http://avr.myluna.de/doku.php?id... seem to shift & rotate?

 

frown

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Where?

I think he means examples such as this:

 

http://avr.myluna.de/doku.php?id...

 

And within that examples such as this:

 

#define LED1 as PortD.5

Not sure how that's actually "better" than Codevision C if that kind of thing really floats your boat?

 

Oh and the stack (perhaps as expected) works from the end of RAM into the dynamic memory pool so it looks like you could just always specify a stupidly large value (assuming no dynamic memory use) and not worry too much about how big to set the value.

Last Edited: Mon. Feb 16, 2015 - 01:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The only "bit" operators at http://avr.myluna.de/doku.php?id=en:logische_operatoren_und_bitoperatoren seem to shift & rotate?

 

bitwise and, or, not and xor are described in the same link (then, logical false is zero, true is anythig != 0) Drawback is that bitwise operators  are not distinct from boolean ones ... making reading difficult.

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

Imagine the time it would take to find a bug induced by using one too many angle brackets as in a normal shift operation that only uses two:



Implemented in version
2013.r2 

This operator is used to rotate the Value x bits left. The argument right from the operator is the number of bits. The number of bits can be a expression or variable. Warning with signed values! This operation rotates all bits. The sign-state of signed and negative values are destroyed.
Result = Value <<< numBits
Note: Operator not available in the preprocessor. 

Example

  ' in Expressions
  a = &b10000001
  var = a <<< 1   ' rotates the value &b10000001  1 bit left to &b00000011

>>>




Implemented in version
2013.r2 

This operator is used to perform a Wert um x Bits nach rechts zu rotieren (Rotate-Right). The argument right from the operator is the number of bits. The number of bits can be a expression or variable. Warning with signed values! This operation rotates all bits. The sign-state of signed and negative values are destroyed.
Result = Value >>> numBits
Note: Operator not available in the preprocessor. 

Example

  ' im Expression
  a = &b00000011
  var = a >>> 1   ' rotates the value &b00000011  1 bit right to &b10000001

 

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius

Last Edited: Mon. Feb 16, 2015 - 10:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I meant to say pin manipulation as is done for PICs.

About stack, yes it is at the end of ram, you can see the graphic report at the end of compilation if you enabled it in Options.

 

"reserved" means "occupied" by the program. The example program is to demonstrate the use of "lcdbar" on a 16x2 LCD display.

 

Also you have access to the entire Flash map of your resulted compilation if desired. LunaAVR has a couple of nice tools for both the beginner and the pro. It has much to offer to beginners comparing it with Arduino/Wiring and is not stuck only on a couple of micros and a fixed frequency. You just set the required crystal frequency, and use existing libraries as you need, no special setup. Imagine how easy is for the beginner who can concentrate now on his project. And again, the compilation result competes with what you get with avr-gcc and other C compilers. Is a shame that is not promoted at least for the newbies.

Last Edited: Mon. Feb 16, 2015 - 10:28 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For me, a HLL that only supports a single target architecture defeats one of the main purposes of a HLL.

Not that I wouldn't rather use ABASIC or JAL or Luna than assembler for a large program, if those were the only things available.

 

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

Is a shame that is not promoted at least for the newbies.

Two things:

 

1) I don't see anything knocking Arduino off that pedestal now

 

2) presumably a lot of people hack about AVRs to learn programming with a view to future employment? If so "C" and "C++" (aka Arduino) will look good on a CV, "Luna" maybe not so much :-)

 

Talking of Arduino. If the developer really wanted this to catch on maybe what he needs is to put in the infrastructure for his IDE to simply "talk through" to an Arduino bootloader then he could promote this as "easier than Arduino for the Arduino"? (maybe the IDE already does that - I don't know).

Last Edited: Tue. Feb 17, 2015 - 10:10 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Luna has his own bootloader, written in Luna language if I'm not mistaken, but the IDE can upload also to Optiboot bootloaders, and anything avrdude can handle (just mention the protocol in IDE), as is used in background. LunaAVR IDE has also a graphical interface to avrdude, for the micros without bootloaders, and in this case, it allows you to specify the programmer you use. Programming an Arduino directly is no problem and the nice thing is, if you can upgrade your crystal to 20MHz, than you can program your Arduino at maximum speed. Scaling up your program, or shrinking it for a ATtiny, or burning it to an ATXmega is not a problem for LunaAVR. That is why is better, and it is also a chance for Arduino guys who can't still stand C. to move forward in using any AVR (ATtiny, ATmega, ATXmega). It does not need to knock down Arduino (or gcc), is here, and with a lot of potential for Arduino people, for BASIC people, for PASCAL people, even for C people who wants to do rapid prototyping, remembering that they already knows BASIC or PASCAL. A good compiler and an easy language for AVR. Why not?

 

Uploader looks like this:

 

And the avrdude GUI look like this:

Last Edited: Wed. Feb 18, 2015 - 03:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not?

Already crazy, don't want to be a LUNAtic too.....

John Samperi

Ampertronics Pty. Ltd.

https://www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Ha ha! Good one!
Hi @js,

Do you know that the library is written in assembler? We can write any library in Luna language, but the official library is written in assembler and I think that is why the compilation result is so competitive. The source can be seen via the IDE - it has nice UI browser tools. You can mix in your program assembler code if you wish.

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

but the official library is written in assembler and I think that is why the compilation result is so competitive.

But that's also true of the majority of AVR C compilers too. Most of their library code is written in Asm too.

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

westfw wrote:
For me, a HLL that only supports a single target architecture defeats one of the main purposes of a HLL.

Absolutely!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oops! (a big one). LunaAVR no longer free for commercial use :( . Lucky me, I still have the old package but this don't change anything for new comers. It is still free for non-commercial use and for Educational environment. Fair enough, I would say, as the language is easy to learn, no limitations and results are at the professional level. Still worth getting it, in the eventuality that there may appear some limitations in the future.

Last Edited: Sat. Mar 7, 2015 - 12:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"For me, a HLL that only supports a single target architecture defeats one of the main purposes of a HLL."

 

It may be a problem for people who stick with one language (modern people?).

Last Edited: Sat. Mar 7, 2015 - 11:20 AM