Forum > Embedded - AVR

Lazarus control Arduino Nano with Enc28J60

<< < (2/9) > >>

microguy:
Avra,

Thank you for the information and links. I will try find time to work on it next week. Right now I would like to try use Ardunio UNO to make several LEDs to turn on and off from computer.

In future I would like to control four or five Arduino with single one com or something. They are about ten feet apart each other. I will use it for HO train. I would like to control about 25 turnout, several RFID,and lot of LEDs. I thought I could use IC2 but it is my understand it will not work if it is long distance. I rather not to use Wi-Fi. I was thinking to use  ENC28J60 with Nano. Can we use five ENC28J60 with Nano and switch hub to computer with FPC. If we can then how do we do it?

Thaddy:

--- Quote from: dogriz on May 15, 2017, 09:27:30 am ---@Thaddy
I wasn't aware of that. Thanks for the info Thaddy.
But I'm not sure how to control ENC28J60 shield with FPC.

--- End quote ---
Usually there is some sort of C header file available with a description of e.g. the pin layout, enumerations etc. These are easily translated to Pascal with h2pas.

Thaddy:

--- Quote from: avra on May 15, 2017, 09:11:37 am ---You are asking for serial communication,

--- End quote ---
Synaser (part of synapse) works. I guess the other X platforms will also work. I used the ATMega328 blink example with trunk to test both native and interfacing code on a RPi3 and Windows. I made some changes, but if anyone is interested I will post it later (nothing new, just different).

avra:

--- Quote from: microguy on May 21, 2017, 08:03:01 am ---I would like to control four or five Arduino with single one com or something. They are about ten feet apart each other.
--- End quote ---
You can control them from any computer with serial port (yes, including Raspberry Pi) if you use some single master multi slaves protocol. On electrical level it can be RS485 - either 4 wires full duplex or 2 wires half duplex. So you will need 1 RS232-RS485 convertor for your computer, and one for each Arduino. Make sure that your Arduinos have RS232 and not only USB, otherwise you will need different level convertor like TTL-RS485 or USB-RS485). On protocol level it can be MODBUS RTU or ASCII, some other protocol, or even your own if you want to keep it simple. To be able to talk to everyone, all sides need to have unified electrical connection level and talk the same protocol. There are MODBUS libraries available for FPC and as Arduino C libraries. E-Lab AvrCo Pascal compiler has it, and I think that I have seen one for mikroPascal. Your board will have different MODBUS adresses, and when your PC asks for data from board 1 with address 1, only board 1 will answer. Then you ask for data from other boards one by one.


--- Quote ---I thought I could use IC2 but it is my understand it will not work if it is long distance.
--- End quote ---
I2C can have extended range with little electronics, but how would you interface it to PC? You would need something like BusPirate or custom hardware, so I would not recommend it. Keep I2C just for connecting Arduinos to their local sensors.


--- Quote ---I was thinking to use  ENC28J60 with Nano. Can we use five ENC28J60 with Nano and switch hub to computer with FPC. If we can then how do we do it?
--- End quote ---
Unlike W5100 and similar, ENC28J60 is a very simple chip capable to talk just UDP. However some libraries extend it and add TCP/IP layer and other popular protocols. You can talk with ENC28J60 from E-Lab AvrCo pascal, mikroPascal and Arduino C. All boards and your master PC should be connected to a ethernet switch. Your PC would then just need to call boards one by one in  a loop and request data from them. You can use MODBUS TCP protocol for ethernet, but you have very limited resources so you might want to keep it simple and light and instead implement your own request/reply data exchange protocol.

avra:

--- Quote from: microguy on May 21, 2017, 08:03:01 am ---I will use it for HO train. I would like to control about 25 turnout, several RFID,and lot of LEDs.
--- End quote ---
OK, if by HO train you mean model train, then I have made a little research and found that DCC is a standard for model railways. There are even several DCC implementations for AVRs so you might want to take that route if you don't want to be a lone island and be able to take benefit of already existing DCC software and hardware (hint: type dcc railway on ebay).
http://opendcc.sourceforge.net/
http://mrrwa.org/
http://www.dccwiki.com/DCC_Software
http://forum.lazarus.freepascal.org/index.php/topic,24388.15.html

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version