Arduino Delphi Serial Communication Rs232

Arduino and Delphi Controlling Outputs with the PC Controlling Arduino Outputs with the PC Elsewhere on my website, I show details of a which can be controlled using the computer's parallel port. Unfortunately, fewer PCs are fitted with parallel pors these days and, for a laptop, it's not really an option. A recent failure of the PC I used to operate the Video Switcher meant I needed to find an alternative to the parallel port. Although the software I ran on the PC to control the Video Switcher is beyond the scope of this article, I needed to update it to use USB instead of the parallel port.

  1. Arduino Output To Rs232
  2. Arduino To Arduino Serial Communication
  3. Arduino Rs232 Serial Communication Example

Arduino Output To Rs232

I had in mind something similar to the but without any inputs or LEDs or buffering or Analogue IO. The original Video Switcher design only needed three data output lines from the PC's parallel port to selelct the cameras, so this seemed like a good opportunity to bring together a few bits and pieces and 'concepts' that I'd been thinking about for the Arduino; specifically:. To build a 'minimal' stand-alone Arduino on its own PCB (. To interface the 'DIY' Arduino with either a or a - or even try both!. To write a simple Windows application (in Delphi) to control the 'Arduino' digital output pins, similar to the application supplied with the Velleman USB Interface. As this will be using the existing Arduino IDE's Virtual COM port, it should be much easier to write than grappling with the Velleman K8055 DLL methods and procedures!.

Ultimately (outside the scope of this article) to incorporate what I learn into the to act as a 'bridge' between USB and the original parallel port input. The Delphi application I wrote to test the PC-to-Arduino communication is very simple. Six checkboxes are used to turn an Arduino digital pin HIGH or LOW. The actual digital pins are determined by the Arduino sketch but the Delphi application assumes digital pins 8 to 13. These are all but the top two bits of the ATmega's PORT B - the top two bits being unavailable because the chips's hardware design uses those two bits (which would be Arduino digital pins 14 and 15) for the 16 MHz crystal. The Delphi software simply calculates the decimal number based on which checkboxes are checked and sends the number as a text string to the USB port - which the Arduino & IDE has already configured as a Virtual COM Port (VCP).

Delphi doesn't have any native COM port functions or procedures and Delphi programmers will have their preferred software or 3rd Party component so I won't give the code here. I use the TComPort Library available. It should be easy enough to write to individual Arduino digital pins rather than addressing an entire port but, in order to do this, the PC application would need a 'pin map' of the Arduino and would need to take care to read the port to which the digital pin belongs and logical OR it with the idividual digital pin's bit in order not to change the state of any of the other bits before writing to the port.

USB To RS232 Serial Port Adapter. 2 LCD_DUMMY Serial port. Sets the data rate in bits per second (baud) for serial data transmission. These days, I'm learning serial port communication and want to write a simple to reboot after opening a serial connection. The Arduino SoftwareSerial library is.

For simplicity, that's not the approach I used with this current application. The Arduino Sketch The Arduino sketch begins by setting all but the top two bits of PORTB as outputs and turning all outputs to OFF. The main loop simply loops and builds up a String variable ( inputString) when the Delphi application sends any data. The text string is converted to a numerical value and is then applied to the PORT B register.

Drum fills

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 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. (ignore the warning: the current state works).

Arduino

For serial port communication in your Lazarus application take a look at these links: 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. 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: 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. 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.

Arduino To Arduino Serial Communication

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? 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.

Arduino serial communication code

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. 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.

Arduino Rs232 Serial Communication Example

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. OK, then to get some confidence do the most simple thing first. Connect led to your Arduino using proper resistor. Light a led on and off using Arduino IDE for writing a very simple C program.

Flash it to your Arduino and verify that the led blinks. After that use Arduino IDE to write another C program that listens to serial port to change led state with serial 'on' and 'off' commands. To test it use some terminal software, connect to proper serial port (check that port speed and other settings match Arduino port settings), and type on and off commands. Verify that Arduino led obeys your commands. For all this you can find a nice tutorial here: All you need to do now is to make a Lazarus application that will send serial commands to Arduino like you did previously by hand with your terminal.

Avra, Sorry for taking so long to respond. I was travel a lot for my company. I fiinlly be home few days. Anyway I got Arduino IDE working with Arduino Mega to turn on and off LED.

Now I trying to get small Lazarus program that I create a button for one and another button for off. I think I am not sure how to use serial code and where do we put in Lazarus. Is there somewhere I can get more tutor on serial port on Lazarus or where I can download and already have source code and exe file that I can run?

Posted on