Prox / RFID
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Resume / Consulting
Contact Me

LDmicro Forum - Ldmicro running on Atmel ATmega168 / 328

(you are viewing a thread; or go back to list of threads)

Ldmicro running on Atmel ATmega168 / 328 (by JosÚ GILLES)

I enjoyed trying ldmicro on Atmel ATMega8 / 16.

As I own some ATmega168 / 328 (used by arduino) I have
adapted the source code to support these more recent Atmel AVRs.
I built the project under MSC++ 10 Express, modifying only 4files:
ldmicro.h, mcutables.h, lang.cpp, avr.cpp (mainly)

Ports, ADC, PWM and UART seem to work fine on all my targets (8, 16, 168, 328).

I also noticed a little bug in langage tables Fr, De and Te:
a double % is missing after 5% on 2nd line, which generates wrong error messages. So lang-tables.h as also been modified.

Here are modified files, and new executable, for everyone who may be interested !

Maybe it could justify a new release ?

JG (France)
Sun Nov 25 2018, 12:29:12, download attachment LdMicro-Avr++.zip
More recent releases on Github (by JosÚ GILLES)

I've just seen that more recent releases are on Github (4.4.3 vs 2.3 on ldmicro)
It should be updated !
Sun Nov 25 2018, 13:10:49
(no subject) (by Alex)
have you modified 2.3v? i can┤t open. would like to try your version
Sun Nov 25 2018, 15:14:52, download attachment error LdMicro++.jpg
(no subject) (by Ziggy)
LDmicro already supports those two microprocessors.
Sun Nov 25 2018, 21:55:08
Error MSVCR100(D).dll (by Jos´┐Ż GILLES)

This error MSVCR100(D).dll is due to 2 factors:

I posted the Debug executable of my 2.3+ modified version.
Release (normal) executable is in the new attached zip file.

Il the problem persists with new executable, it meens that Visual C++ runtime is missing on your computer.
You can download it on microsoft website:
Install it and run ldmicro again.

Mon Nov 26 2018, 13:11:59, download attachment LdMicro++.zip
(no subject) (by Alex)
Thanks a lot , now it works :), i have tried your 2.3+ version with a modified ladder from:


if i compile ladder with 2.3+ lcd prints another values, if i use ldmicro (latest is until now, it has a terminate bug, so i use it prints values ok, see video please:


there are some bugs in ldmicro 2.3v official ldmicro release, like :


Ihor already fixed that and it works ok, i think ldmicro 2.3v should be upgraded for begginers then they could use latest ldmicro from Ihor.
Mon Nov 26 2018, 15:44:02, download attachment swatch3_328p_2.3+.ld
Bug LCD / Alex (by JosÚ GILLES)

I've been playing with ldmidro for 2 weeks only ; so I'm not aware of too many things !

I have discovered a few days ago that new releses were held by a new developper. I'm looking at it and recompiling sources. It seems to be more poweful but also more confusing than before !
I also think that former releases are fine to start.

About your display pb, I watched the video.
Your board is an Arduino Uno with AtMega 328 and you use a PIC to drive the display via UART ? I have a Myavr board with the same ÁC (but 3.6864 MHz), and some HD44780 compatible 16 pin LCD displays, but I do no longer use PICs.

What is the speed of the UART ? I've just tried 9600 bds in echo.
I'll have a better look at UART with ATMega328 using your swatch3 example...

My goal is not really to use Ldmicro with atmel AVRs, but with some 32 bits ARMs, if I can adapt it...

Mon Nov 26 2018, 17:39:16
(no subject) (by Alex)
speed uart in that ladder is 9600, would be excellent, yeah ihor┤s development is powerful
Mon Nov 26 2018, 21:09:36
UART / ATmega328 (by JosÚ GILLES)
Hi Alex

In fact ATMega328 UART has one more register (UCSRC) to configure compared to other similar Atmels.

I have set the right - I believe - value in UART setup from avr.c and I hope it should be better.

I can't exactly try your ladder because I dont have the same material, and no simulator either. With a terminal it works
at different speeds.

Let me know if its OK or not ?
New files are in attached zip.

Tue Nov 27 2018, 16:10:18, download attachment LDMicro2.3+.zip
(no subject) (by Alex)
thank for your reply, sorry for the late i was a little busy, i had to redo ladder with your ldmicro version for non conflict , i tested uart without buttons


it keeps sending weird characters
Wed Nov 28 2018, 16:46:18
UART / ATmega328 (by JosÚ GILLES)

I can't explain the pb for the time beeing but I will have a look at it again by the end of the week !

Now I'm working on ARM STM32 support in ldmicro 4.3 and it begins to be fine...

Thu Nov 29 2018, 06:21:56
(no subject) (by Oleksiy)
Hi JosÚ.

Did you have an open repository on GitHub?
Thu Nov 29 2018, 11:14:45
(no subject) (by Alex)
thanks for your reply JosÚ,would be great to have arm stm32, when you say ldmicro 4.3 you mean latest ldmicro version?
Thu Nov 29 2018, 16:24:24

To Oleksy:

No I haven't got a repository on Github
What are you interested in ?

To Alex:

Yes, I also think it would be great to use 32-bit ARMs in ldmicro. That's what I use now with my students after using a few PICs and several AtMegas for years.
I used the last version on Github for my trials (

For the time being only I/O pins are working on 8 bits. I can generate with ldmicro a full c program using ST libraries, which is compiled via ArmGcc and loaded into the target via flashMCU (modified) script. All this without exiting ldmicro.

It works with a trial program just using 1 button and 1 led !
To be continued...
I'll post a video as soon as possible.

Fri Nov 30 2018, 00:58:51
(no subject) (by Oleksiy)
To JosÚ:
>>What are you interested in?
Nosing special, just curious.
Also, I slowly try an upgrade codebase of LDmicro.
My aims are:
* made code more C++/c++11 and above
* divide compiler itself and GUI

my repo: https://github.com/slyshykO/LDmicro
Fri Nov 30 2018, 03:37:55
(no subject) (by Alex)
hello Oleksiy, are your realeses implemented in Ihor┤s ldmicro version?
Fri Nov 30 2018, 07:39:31
(no subject) (by Oleksiy)
To Alex:
Yes, I push changes to Ihor's repo.
Fri Nov 30 2018, 14:22:09
ldmicro 2.3 Uart bug (formatted strings) fixed ? (by JosÚ GILLES)

To Oleksiy:

You're right when you say that ldmicro sources derived from 2.3 version are a bit old fashioned nowadays. To be more efficient, it ought to be (re)written in C++, because contacts are naturally objets ! Menus and dialogs should be implemented as resources, as you're doing... But all this is a lot of work.

To Alex:

I have worked today on our UART problem with my ATMega328 under ldmicro 2.3+. In fact, as you probably know, the problem is general: it's not a bug in my UART, since the same phenomenon occurs with ATMega16, ATMega8 and - I suppose - all other targets. It'a bug in formatted strings implementation in ldmicro 2.3

I believe I have fixed this bug in my "2.4" release by modifying pieces of code in intcode.cpp. As far as I have tested it, strings via uart work in simulation and truly on my ATMega16 and ATMega328.

Your ladder called "swatch3" now works fine too !
Can you try it with your simulator ?

Attached zip file includes my new "2.4" fr executable and several ld files, among which the "famous" bug of not connected strings but sending chars ! It does no longer send anything.

If you confirm that it works for you too, I'll post the source files and an english version for those who may be interested.

Sat Dec 1 2018, 17:31:20, download attachment testsuart.zip
(no subject) (by Alex)
Thanks a lot JosÚ GILLES now it works fine, at 0:35 second of the video it had some problem , it freezes , tested again for 5 minutes it worked very well without any problems, at 0:35 second it is more probably just simulation, i had same problem with Ihor┤s but when implemented in real life it worked very well, now i am going for a trip for some days, after that i┤ll test it in real life, thanks again :)


btw: i was listening some music during video recording sorry for that
Sat Dec 1 2018, 19:58:14
(no subject) (by Alex)
would it be possible to have it in spanish and english? also memory usage of 328p
Wed Dec 5 2018, 23:36:42
(no subject) (by JosÚ GILLES)

I have created a repository on Github:


You'll find a zip file with all sources and different langage

What do you mean by "memory usage of 328p " ?

Thu Dec 6 2018, 07:20:56
(no subject) (by Alex)
thanks a lot JosÚ, i donwloaded it :) , by memory usage i mean memory used for schematic ladder compiled, see iamge please,

a little whim :) ldmicro 2.3v has these feature : "When minimizing LDmicro, it always hides the IoList window"


video for description:


Ihor alreaydy fixed that feature on his releases, but 2.3 keeps this"annoying"feature, would it be possible to change those features if you have time, please
Thu Dec 6 2018, 07:59:01, download attachment memory used 328p.jpg
(no subject) (by JosÚ GILLES)


Once again I can't open your image !
Don't know why ?

Fri Dec 7 2018, 01:24:14
Post a reply to this comment:
Your Name:
Your Email:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):