Recent

Author Topic: Robotic arm in Lazarus  (Read 5540 times)

krolikbest

  • Full Member
  • ***
  • Posts: 246
Robotic arm in Lazarus
« on: January 19, 2018, 10:22:40 pm »
Hi,

i would like to show you my last project (well, a little part of huge project at least) https://www.youtube.com/watch?v=Ac7vMdVqnJE. If someone would be interested in using my rough library for creating movement like above, could attach a library for inverse and forward kinematics for planar 3dof RRR-arm and give source of this program how to use it. As you see there is also plain SDL (without gfx) and eyecandy-control by Blaazen since i find it very useful, so to use it one need this two things installed.

I hope you enjoy it.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Robotic arm in Lazarus
« Reply #1 on: January 20, 2018, 10:33:25 am »
Very nice and applicable to real robotic arm. Hope to see a repo with sources one day...  ;)
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

Rookout

  • Newbie
  • Posts: 1
Re: Robotic arm in Lazarus
« Reply #2 on: January 21, 2018, 05:29:45 pm »
Very nice and applicable to real robotic arm. Hope to see a repo with sources one day...  ;)

That's impressive, Krolik. It makes me wonder what's the bigger project about. Can you talk more about it?
« Last Edit: November 05, 2021, 04:52:17 pm by Rookout »

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Robotic arm in Lazarus
« Reply #3 on: January 21, 2018, 08:23:05 pm »
The main aim is to build robotic arm basing on RPi. On RPi I code in Lazarus mostly, some parts write in Bascom for uC like AVRs. A little work ahead of me to build my own controller for hybrid-stepper (stepper with encoder) but some progress is already done :) Previously i've done it (reading encoders) directly on RPi with Lazarus but somehow it didn't work as expected (due second-hand encoders), but anyway uC for that is better and doesn't  load so much the RPi. Presently step by step i try to solve some basic brics and in 2 months I hope to start to conect all parts together :)

Paul Breneman

  • Sr. Member
  • ****
  • Posts: 290
    • Control Pascal
Re: Robotic arm in Lazarus
« Reply #4 on: January 21, 2018, 10:42:15 pm »
The main aim is to build robotic arm basing on RPi. On RPi I code in Lazarus mostly, some parts write in Bascom for uC like AVRs.

I did a bit of motion control work with Free Pascal about two years ago.  You can view my (Basic) program and notes here if you like: https://kdn.kollmorgen.com/node/87138#node-87146  (see Basic38.txt).  I hope to do more work on that project soon.

I'd like to add a simple motion control project to this page: http://controlpascal.com/

I use RPis a lot so I'm very interested in what you are doing!
Regards,
Paul Breneman
www.ControlPascal.com

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Robotic arm in Lazarus
« Reply #5 on: January 22, 2018, 03:44:36 pm »
Thank you for your interest.
A little old project but my first contact with RPi https://www.youtube.com/watch?v=4jahHNvuSLc. Programmed in Lazarus of course. Since then I haven't published yet what i'm currently working on. You can follow my youtube channel or contact me directly.


Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: Robotic arm in Lazarus
« Reply #6 on: January 22, 2018, 06:04:21 pm »
but anyway uC for that is better and doesn't  load so much the RPi.

Impressive demo, but your quote above I do not understand (working with RPi's a lot). Are you sure you separated the GUI part of the code from the actual robotics code?
Because FPC is very capable (and small) with such code and only the GUI part should give you any CPU load.

I would like to help you in solving any performance issues. And/Or help you write FPC embedded code for a specific AVR chip as long as it is supported. 
« Last Edit: January 22, 2018, 06:10:43 pm by Thaddy »
Specialize a type, not a var.

BlueIcaro

  • Hero Member
  • *****
  • Posts: 791
    • Blog personal
Re: Robotic arm in Lazarus
« Reply #7 on: January 22, 2018, 06:53:03 pm »
Nice work!
/BlueIcaro

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Robotic arm in Lazarus
« Reply #8 on: January 22, 2018, 07:36:57 pm »
Hi Thaddy,
thank you for your help, I really appreciate it. But  it is not matter of gui. Imagine, there are 5 steppers with encoders. Every one in real time should be read, analysed and then some kind of action has to be done with steppers (stop, go on, back, hold position etc.). There is also voltage circuit in case that an encoder is destroyed? And to the RPi are connected other sensors, next, how to manage with acceler/ deceler. of stepper and so on...  That why i decided to separate them from RPi. Simple ATMega8 is very capable of:
1. to generate steps wit accel/decel ramp,
2. to check/count encoder signals,
3. Avr is in some way also autonomous and decides about other processess but always send action's info to RPi,
thus simply RPi sends to avr through I2C few informations as dir, expected encoder's position and other infos. When stepper is in position, avr sends back info. RPi has to collect all datas from all servos/display them/to process datas/ and many other tasks.
----
It sounds interesting about programming avr with FPC. I used to do it with Bascom, you know, there is plenty useful commands that no one has to spend much time to learn how to write code for lcd/i2c/generator and not to mention simulator.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Robotic arm in Lazarus
« Reply #9 on: January 23, 2018, 09:28:24 am »
Imagine, there are 5 steppers with encoders. Every one in real time should be read, analysed and then some kind of action has to be done with steppers (stop, go on, back, hold position etc.). There is also voltage circuit in case that an encoder is destroyed? And to the RPi are connected other sensors, next, how to manage with acceler/ deceler. of stepper and so on...  That why i decided to separate them from RPi. Simple ATMega8 is very capable
You are right that sync will be lost with plain linux (even RT could loose steps in this case), and I understand using an AVR for offloading realtime work (I did stepper acc/dec ramps with AVRs too). Once you have to make a driver electronics it is tempting to add a microcontroller, especially if you are already familiar with programming them. But maybe Thaddy was talking about using DMA to offload GPIO work from RPi CPU. Take a look at this project. You will see that with RPi DMA even slow Python is capable to drive stepper ramps without loosing sync. Here is a quote from the site:
Quote
Typically there is no way to control stepper motors from Linux runtime environment due to the lack of real time GPIO control. Even kernel based modules can not guarantee precise control of pulses for steppers. However, we can use a separate hardware module, DMA (Direct Memory Access) which provides high precision for GPIO outputs. This module can copy bytes which represent GPIO states from RAM buffer directly to GPIO with some clock based on main chip internal oscillator without using CPU's cores. Using such approach this project generates impulses for moving stepper motors and that is very precise way regardless CPU load and OS time jitter.
This approach also allows to use Python language for this project. Typically, Python is not good choice for real time application, but since project just needs to set up DMA buffers and hardware will do the rest, Python become the perfect choice for easy development of this project.
It might be even good enough for encoder readings without interrupts.

Anyway, I also like the idea of using the AVR for offload work...
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Robotic arm in Lazarus
« Reply #10 on: January 27, 2018, 10:41:55 pm »
compiled with Laz1.8/FPC 3.0.4/WIN7. No problem to compile library on ubuntu 14/Laz1.8/FPC 3.0.4 if someone wants.
Link https://ufile.io/7lsbn

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: Robotic arm in Lazarus
« Reply #11 on: January 30, 2018, 12:42:44 pm »
It sounds interesting about programming avr with FPC. I used to do it with Bascom, you know, there is plenty useful commands that no one has to spend much time to learn how to write code for lcd/i2c/generator and not to mention simulator.
I am sure FPC will eventually have decent support for AVR.  Currently development happens slowly because only a small fraction of the core team's time is spent on this target.  Once FPC for AVR is stable enough the libraries will follow.  Regarding a simulator - I've used simavr with Lazarus to simulate and debug AVR code.

Thaddy

  • Hero Member
  • *****
  • Posts: 14158
  • Probably until I exterminate Putin.
Re: Robotic arm in Lazarus
« Reply #12 on: January 30, 2018, 01:49:26 pm »
compiled with Laz1.8/FPC 3.0.4/WIN7. No problem to compile library on ubuntu 14/Laz1.8/FPC 3.0.4 if someone wants.
Link https://ufile.io/7lsbn
Don't use 3.0.4 for AVR, use trunk.
Specialize a type, not a var.

krolikbest

  • Full Member
  • ***
  • Posts: 246
Re: Robotic arm in Lazarus
« Reply #13 on: January 30, 2018, 04:22:48 pm »
Hi Thaddy,

why?

ccrause

  • Hero Member
  • *****
  • Posts: 843
Re: Robotic arm in Lazarus
« Reply #14 on: January 31, 2018, 05:38:51 pm »

Don't use 3.0.4 for AVR, use trunk.
why?
Thaddy is recommending FPC trunk specifically for the AVR processor family because the support for AVR in the release versions is very basic.

 

TinyPortal © 2005-2018