Author Topic: Motion plugin for virtual hardware(for tests) - lets share our knowledge  (Read 27186 times)

0 Members and 1 Guest are viewing this topic.

Offline jarekk

  • Active Member
  • Posts: 52
    • View Profile
Hi,

I have my own USB CNC controller ( something close to ncPod - 120Mhz Arm Cortex CPU capable of about 100kHz operation). It works with different software then Mach.
I wanted to to write Mach plugin for it, but there is no good documentation for it. There are few people who know it quite well, but this knowledge is commercially valuable , so nobody was interested to join me.

I have it quite alive. There are few things missing ( like input/output processing, homeing, jog operation), but basic motion works. There is also console windows to dump all interesting internals
I decided to share it before finishing as there are some other people working on similar design (http://www.machsupport.com/forum/index.php/topic,17602.0.html)

So - please have a look at sources, play with it.
It is free to use as long as you share your knowledge to make it really good template for starting own motion plugins.

You need Visual C++ Express 2010 to compile it.
You will need to change in project post processing step - to accomodate path to your Mach directories.
In case your console window is too small - change it . Once changed it will keep setting for consequiteve runs.








Offline madfly

  • Active Member
  • Posts: 7
    • View Profile
Re: Motion plugin for virtual hardware(for tests) - lets share our knowledge
« Reply #1 on: February 27, 2011, 12:49:59 PM »
Hello, thank you for your help and the example that I've provided, I have compiled and now I understand better how Mach3 inside.
 As you rightly said you can not find a working example to see how Mach3 sends commands.
 Almost all USB Mach3 to do nothing but take the data in Modbus format and then regenerate the toolpath, my idea is instead to capture the pulse of step and direction, sending them to the usb it will not do more than repeat the impulses Mach3, which sends the parallel.
 I do not know if I was very clear but my English is at school, thanks again Daniele

Offline Scoppio

  • Active Member
  • Posts: 12
    • View Profile
Well... I'm taking a look in your plugin but I don't get one thing - Where do you send the data trought the USB? I can't find any function that send's the data to the USB port, could someone please point that for me?

Offline jarekk

  • Active Member
  • Posts: 52
    • View Profile
This is virtual plugin  designed to show Mach internals. So no real USB - just software emulation of it.
But - if you are asking about it - it depends on your particular USB device.   For most of my USB devices sending data is like writing to FIFO or file.  If you are interested in real examples see libusb project (http://sourceforge.net/apps/trac/libusb-win32/wiki) or FTDI library (http://www.ftdichip.com/Support/SoftwareExamples/CodeExamples.htm)

Offline Scoppio

  • Active Member
  • Posts: 12
    • View Profile
actually I'll be using a PIC18F4550 to convert the USB into a LPT1 to run 3 stepper motors axis :\

Offline jarekk

  • Active Member
  • Posts: 52
    • View Profile
Use external USB/ serial port or fifo controller. It adds about 19$ to the cost ( for ready made DIP style module from DigiKey ), but it is easier in the beginning.

Offline Scoppio

  • Active Member
  • Posts: 12
    • View Profile
Actuallly, I develop cnc's using pic's, thats the first time I'll try to use the usb port to communicate with the pic instead of using the Parallel, the problem is actually making the mach3 send the data to the pic via USB :\

Offline jarekk

  • Active Member
  • Posts: 52
    • View Profile
Mach will *NEVER* send anything on USB - it has to be your plugin which takes Mach data and sends it itself.
Have a look at some my routines - PC side for FT245R chip ( USB-> Parallel FIFO) converter and LPC1769 code to get data from it.

If this is too complicated - then wait until you try to extract motion data from Mach....

Offline Tweakie.CNC

  • Global Moderator
  • *
  • Posts: 7,669
  • Super Kitty
    • View Profile
    • Tweakie.CNC
Something you may find interesting.

http://www.machsupport.com/forum/index.php/topic,17992.0.html

Tweakie.
Success consists of going from failure to failure without loss of enthusiasm.  Winston Churchill.

Offline Scoppio

  • Active Member
  • Posts: 12
    • View Profile
Mach will *NEVER* send anything on USB - it has to be your plugin which takes Mach data and sends it itself.
Have a look at some my routines - PC side for FT245R chip ( USB-> Parallel FIFO) converter and LPC1769 code to get data from it.

If this is too complicated - then wait until you try to extract motion data from Mach....

Yeah, i know, thats way I asked how to make THIS plugin send data via USB :\
I'll keep searching how to do it, but the hardware is pretty much standar - usb input, control of steppers, etc...

Something you may find interesting.

http://www.machsupport.com/forum/index.php/topic,17992.0.html

Tweakie.

really interesting, actually thats EXACTLY what I'm trying to do, but instead of atmel MCU I'll be using a Microchip PICmcu and instead of an Altera FPGA I'll be using 3 pics mcu specialized on driving step-motors (to decrease the learning/development time).