Forum > Embedded - AVR

Lazarus control Arduino Nano with Enc28J60

(1/9) > >>

microguy:
This is my first time to post. Hope this is right place to post about control Arduino. I would like to use Lazarus with Arduino. My computer is window 10. I just download Lazarus and got it working. I have been use Delphi 5 for a long time.  Now I would like to learn how we can control Arduino with several LEDs and servos. I have google it but still not understand how to use. I understand we need to download serial port communication. Which one should we use? I would like to use USB port. Someone mention to use Synaser. I am not sure How do we use it.  Is there a step by step instruction how we add serial componet on Lazarus? Is there a webpage where I can download and run it? I just want to control Arduino with several LEDs at first then I will add some servos. Please don't give me the link to YouTube. I am very hard of hearing and having hard time to understand video. I am 58 years old.

dogriz:
There are a few things you need to be aware of:
Arduino Nano is Atmel Microcontroller (https://en.wikipedia.org/wiki/ATmega328), you can easily program it using C language. On Arduino website there are enough resources for start (look for some examples about Ethernet) (https://www.arduino.cc/en/Reference/HomePage)

ENC28J60 is not compatible with Arduino Ethernet Library (it is for WS5xxx), so you need other library to program Arduino as TCP client or server. Here are some resources:
http://www.geeetech.com/wiki/index.php/Arduino_ENC28J60_Ethernet_Module
https://github.com/jcw/ethercard
http://www.homautomation.org/2014/10/27/how-to-choose-the-right-library-to-add-ethernet-enc28j60-to-your-arduino/
https://github.com/ntruchsess/arduino_uip

And then you can try communicating with it using TCP (or UDP) (eg. Lazarus + LNet or Synapse).

Thaddy:
@dogriz

No need for C. FPC supports AVR, and afaik it can target the ATMega328 directly.
It is also possible to control an ATMega328 from any of the Lazarus supported platforms with software written for that platform.

You just have to build a ppcrossavr compiler using the GNU C toolchain for AVR to compile for the ATmega328 itself.

So:
- you can write controlling software for atmega with Lazarus on e.g., linux.mac, windows
- you can target the ATMega328 directly with an FPC cross compiler.

http://wiki.lazarus.freepascal.org/AVR_Programming
http://wiki.lazarus.freepascal.org/AVR (ignore the warning: the current state works)

avra:
For serial port communication in your Lazarus application take a look at these links:
http://wiki.lazarus.freepascal.org/Hardware_Access#Serial_Communication
http://forum.lazarus.freepascal.org/index.php/topic,36523.msg245030.html#msg245030
You will find small examples to get you started, but first you need to decide which serial lib/component to use. Wiki will help you with the choice. Have in mind that Synaser is not event based. Others are. Any of them will be able to talk to Arduino over USB virtual COM port.

For developing Arduino and other ATMEL AVR microcontrollers in Pascal take a look at these links:
http://forum.lazarus.freepascal.org/index.php/topic,30960.0.html
http://forum.lazarus.freepascal.org/index.php/topic,32816.msg211887.html#msg211887
http://forum.lazarus.freepascal.org/index.php/topic,24665.msg196700.html#msg196700
http://forum.lazarus.freepascal.org/index.php/topic,29128.msg183767.html#msg183767

Using forum search would bring you much more links.

You are asking for serial communication, but your topic mentions ENC28J60 which can be used for Arduino TCP or UDP networking communication. If you decide to go that path instead then you can use Synapse, Dataport, Indy and several other networking communication libraries available for Free Pascal and Lazarus.

dogriz:
@Thaddy
I wasn't aware of that. Thanks for the info Thaddy.
But I'm not sure how to control ENC28J60 shield with FPC.

Navigation

[0] Message Index

[#] Next page

Go to full version