Recent

Author Topic: Creating new component for Arduino  (Read 5750 times)

Arminius

  • New Member
  • *
  • Posts: 39
Creating new component for Arduino
« on: July 21, 2015, 07:13:29 pm »
Hello Lazarus community,

I haven't been here for a while and I'm happy to see Lazarus is still up and kicking!

Through quadcopters and swarm robotics, there has been a renewed interest in programmable robotics and I have been trying to find any Lazarus related components for different sensors (accelerometers, compass, gyroscope,...) and actuators (mainly the motors/their control board). Despite some messages here and there I have found no structured, easy to use components or tutorials.

I'm interested into getting something structured out there (in case I have missed nothing). Anyone with hardware experience interested in joining in?


Additionnal question: why are all the examples I saw using serial ports instead of USB. What advantages/disadvantages?

eny

  • Hero Member
  • *****
  • Posts: 1587
Re: Creating new component for Arduino
« Reply #1 on: July 22, 2015, 09:59:31 am »
Additionnal question: why are all the examples I saw using serial ports instead of USB. What advantages/disadvantages?
Working with serial ports is much easier than with USB at both the uController and PC side.
And many/must uControllers support serial communication.
All posts based on: Win10 (Win64); Lazarus 1.8.0 'stable' (#56594 win64) unless specified otherwise...

Arminius

  • New Member
  • *
  • Posts: 39
Re: Creating new component for Arduino
« Reply #2 on: July 24, 2015, 05:25:03 pm »
Thank you for this information!

avra

  • Hero Member
  • *****
  • Posts: 1717
    • Additional info
Re: Creating new component for Arduino
« Reply #3 on: July 27, 2015, 01:02:51 pm »
Through quadcopters and swarm robotics, there has been a renewed interest in programmable robotics and I have been trying to find any Lazarus related components for different sensors (accelerometers, compass, gyroscope,...) and actuators (mainly the motors/their control board).
Original Arduino IDE uses GCC to produce code for 8-bit Atmel AVR and some ARM processors. Lazarus IDE uses FreePascal to produce code for various targets.  I guess that you are probably most interested in ARM embedded and ARM Linux targets. ARM embedded is possible but not very user friendly. ARM Linux is well supported and there are ready to use libraries for Raspberry Pi platform. More info can be found here: http://wiki.freepascal.org/Lazarus_on_Raspberry_Pi.

Arduino platform was microcontroller hardware oriented from the start - that's why there are so many ready to use libraries to talk to various hardware chips (through GPIO, I2C, SPI, 1wire, serial...). For each library someone had to read sometimes hundreds of pages from datasheet of some chip and code a wrapper which is not easy and usually needs and engineer or an advanced user. Lazarus was pc oriented from the start and does not have such strong hardware background, and there are not many Lazarus people who know how to interprete datasheet data to make a usable library. Therefore you will not find many libraries for some specific chips, but nothings stops you from converting other's people code (including Arduino) if you know what you are doing, or read datasheets yourself and use GPIO, I2C, SPI and other ways to talk to your device (step motor, servo motor, gyro, compass, temperature or any other type of sensor...).

If you want to use Pascal with a lot of included ready to use hardware drivers like you can find for Arduino, then take a look at E-Lab AvrCo Multitasking Pascal for Atmel AVR Tiny/Mega/XMega microcontrollers, or Mikroelektronika Pascal (also for Atmel, but supports PIC, ARM, 8051 and FT90x):
http://www.e-lab.de/AVRco/index_en.html
http://www.mikroe.com/mikropascal
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: Creating new component for Arduino
« Reply #4 on: July 27, 2015, 02:23:05 pm »
Arminius, there are related links on this wiki page: http://wiki.freepascal.org/Portal:Hardware_and_Robotics

I'm hoping to make ARM Embedded much easier for the Teensy, and this wiki page is where things are right now: http://wiki.freepascal.org/Small_Virtual_Machines
Regards,
Paul Breneman
www.ControlPascal.com

Edson

  • Hero Member
  • *****
  • Posts: 1055
Re: Creating new component for Arduino
« Reply #5 on: July 27, 2015, 05:53:22 pm »
Arduino is very closed to C language, from his architecture. FAIK there is not a direct way to compile with FPC directly to 8-bit AVR micros.

Currently I'm working on developing a Pascal compiler for PIC microcontrollers. My target is to have a compiler for Pinguino. For Arduino there is already, a lot of tools developed.
Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

Laksen

  • Hero Member
  • *****
  • Posts: 621
    • J-Software
Re: Creating new component for Arduino
« Reply #6 on: July 27, 2015, 06:57:55 pm »
It is possible to compile to AVR with FPC. It may not be entirely stable yet, but it's definitely getting close to working nicely :)

Here's a teaser image I made with an STK500, an ATTINY2313, and a cheap LCD. All with FPC of course ;)

If people are interested in the code/directions to do that then let me know. AVR is like any other embedded target, just much simpler