Aeropassion's homepage
Aeropassion's parteners :
Posted by Martin 
Jedicut and Arduino over USB
September 07, 2012 12:40PM
Hi again,

now starting with the basics. The purpose of the new jedicut plugin USBSerial is to use jedicut on PC's and Laptops without a parallel Interface, which is nowadays more and more the case. But all PC's have a USB-interface which can be used.
A second target was to do the timing for the stepper motors and a possible PWM Modulation for the wire heating not on the PC because of the timing lags which will occur on e.g. windows and slower PC's.
To achieve this targets a low cost well known microcontroller system, the arduino, will do the job. It (e.g. the arduino uno) will have an integrated USB-interface and enough ports to handle most parallel port stepper motor boards and do additional tasks like PWM for wire heating. The development environment for arduino is free and well documented.

To start with USBSerial the following hardware parts are necessary:

1x Arduino uno board with USB cable (normally around 30€, but I think hobby king in china, sells them now for 15$ with cable)
1x Connector to your Stepper board (e.g. a 25 pin Sub-D connector, ~2€)
1x Connector to arduino board (header with ~20pin, ~2€)

Now short wires need to be soldered between the arduino and the stepper board connectors.
For the letmathe mdlcnc board I did it as follows:
Arduino uno                         LPT Sub-D connector
12                                         1        All motors On/Off
 8                                         2        X step
 9                                         3        X direction
10                                         4        Y step
11                                         5        Y direction
 4                                         6        Z step (X2)
 5                                         7        Z direction (X2)
 6                                         8        A step (Y2)
 7                                         9        A direction (Y2)
GND                                    18-25    Ground

If this is done, all hardware parts are ready and the software part can be started.
Other boards my need a different wiring and an adapted arduino software too.
I will explain the software part in the next postsmiling smiley



Edited 1 time(s). Last edit at 09/09/2012 09:18AM by Jerome.
Re: Jedicut and Arduino over USB
September 10, 2012 09:39AM
If the hardware is ready it may look like my prototype:

Now I want to explain the interface definition, the commands which will be exchanged between the jedicut plugin and the arduino.
The serial Parameters are 115200 baud 8 bits no parity 1 stop bit.
I am using 2 bytes per command. The first byte is the command name and the second byte the parameter.
With two bytes per command and a rate of 115200 baud a maximum rate of of around 5000 commands per second is possible.

For Example:
0x48 0x24 is the ascii value for 'H' followed by the value 0x24=36 for the value -- This means Wire heating with value 36

The commands currently sent from the plugin are:

'A' with parameter '1' or other value      -- all Motors on/off ('1' on, all other values means all Motors off)
'H' with parameter 0 to 255  -- Wire heating (0 means off, 255 full)
'F' with parameter 0 to 255  -- Frequency, it is the value entered in the jedicut options for 'Cut speed' respectively 'Fast speed' 
'M' with parameter 0 to 255 -- Motor step command, corresponds to the 8 Motor bits (4 direction + 4 Step) defined in the jedicut options for 'Parallel Port' configuration

There are a number of responses defined, which sent from the microcontroller to the plugin. Responses consists only of one byte.
The responses are:
'S' -- Stop transmission, the buffer is full, wait for a 'C'
'C' -- Transmission can be continued
'L' -- Limit switch hit (only defined in plugin, but not used)
'A' -- Stop complete cut (only defined in plugin, but not used)
In the next posting I will explain how the current implementation of the plugin and the arduino software are working together.
Re: Jedicut and Arduino over USB
September 11, 2012 10:12AM
Back again. First I want to explain the sequences within the plugin side.
A jedicut plugin exports a number of procedures/functions. Important are the procedure MoteurOnOff and the function EmettreBit.
There are a number of internal functions too. The plugin USBSerial has internal functions to open, write, read and close the serial port. Which serial port to use is defined in an ini-file called comport.ini and is located in the same directory as the jedicut.exe is located.
Its content is e.g.
[COMPORT]
PORTNUMBER = 4   ;means COM4, usually taken for the virtual port of arduino
When the dll is loaded the serial port will be opened and when it will be unloaded the port will be closed.
Now if jedicut decides to start the movements it calls MoteurOnOff. USBSerial will send out the two byte values 0x41 and 0x31 ('A' and '1'). When the movement is over jedicut calls again MoteurOnOff (with false as parameter) and the USBSerial plugin sends out the values 0x41 and 0x30 ('A' and '0') and the additional command to turn of the wire heating, 0x48 and 0x00 ('H' and 0x00).

The most important function is EmettreBit. This function will be called by jedicut for each step a motor shall be do. This function will receive the values for the cut speed, the wire heating, the motor and the direction to rotate. To save bandwidth on the serial line the commands for wire heating ('H') and cut speed ('F') will only be sent out if the values have changed. The parameter values for 'F' are taken from the settings of cut and fast speed (range 0-255) and for 'H the values are % values (range 0-100%).
Each motor movement is defined by two bits (motor/Step and direction) of a byte. This two bits are given to EmettreBit. If the function is called in succession with different motors (that means different bits of the byte), the bits can put in the same byte. With the first request to the same motor the byte is sent out as parameter to the motor command 'M', so up to four motors will move at the same time. With this optimisation theoretical no sharp corner can be cut, but for now I think its within the tolerances.
In the next part I will talk about the microcontroller side.smileys with beer
Re: Jedicut and Arduino over USB
September 17, 2012 09:20AM
The arduino software in general has two procedures which are called by the arduino system automatically. The procedure setup() is called one time when the arduino boots up, here initialisation tasks like setting the baud rate or defining which pins are in or output shall be located. The procedure loop() is called from the system in a loop, that means if it is left it is immediately called again.

The software for handling the commands from the jedicut plugin consists of two important parts too:
  • The main loop, which polls the serial interface for incoming data. It is identical with the procedure loop(). It writes every two received bytes into a command buffer. If the buffer is filled up to a specific level, an 'S' is sent out to temporarily stop the transmission.
  • The timer interrupt service routine, which is called periodically and handles the commands the main loop has written into the command buffer. If enough commands are handled and enough memory is free in the buffer, a 'C' is sent out to indicate that the transmission can continue.

Using a buffer and a timer have two advantages. The motor commands are given to the stepper board with a very accurate timing and a short lag of the transmission from the plugin to the microcontroller will be survived without disorder of the stepper timing. As long as the PC is fast enough to generate and send out enough commands to fill up the buffer as fast as the cutting speed is set, a very smooth cutting will result. The software uses the onboard LED to indicate a possible underrun of the buffer, in this case the cutting speed need to be lowered a little bit.
Additional the complete pulse necessary to move one step is generated by the microcontroller. Only the direction bit must set correctly (0 or 1) and the corresponding motor/step bit must be set to 1. This reduces dramatically the amount of data sent from the plugin.

The software of the arduino needs to be adapted to the specific board used. In the procedure setup() the pins used for motor step and direction must be declared as output. Other pins e.g. used for wire heating or heating relay or limit switches must declared too.
The handling of the different commands needs to be rewritten to reflect the hardware used, but this is not difficult. I will support everyone who needs help with this task.

My current implementation of the arduino software is specialized to the letmathe mdlcnc board. It supports 4 motors and the relay for heating. PWM and limit switches are not implemented yet, but this would need only little work to implement. I have no switches installed and I make the heating manuel so there was no need to put this functionality into the software. If anybody needs this functionality I will give support to put it in. The cut speed is allowed to set from 0 to 127, which will result in 1000 to 500 steps per second.The relay will be turned on if the heating value is greater zero and turned off when the value is zero or all motors are turned off.

Finally some words about the procedure to 'burn' the software to the arduino board. If you have already the hardware (board and USB cable) you need to install the arduino development environment (its a zip, it must not to be installed only extracted). The homepage of the arduino is arduino software. There the development software can be found.
It includes the driver needed to install when the board is connected to the PC the first time. Then a virtual serial interface is created which you need to enter in the comport.ini file (see above). The arduino software file for foamcutting is called foamcutif.ino. It can simply loaded to the development environment and uploaded/'burned' to the connected board.

Ok, that's it for now. Questions as well as improvements are welcomed. If someone needs help, then I would be happy to assist in solving the problems smiling smiley
Re: Jedicut and Arduino over USB
September 17, 2012 02:15PM
Hello Martin,

sorry, my english is not good.

Who can i find the Plugin for Jedicut?

I plan in the winter a board such arduino with a PIC from Microship.
I work many years with PIC's.

It is possible you can make a little flow-diagramm from the Plugin?

Greetings, Manfred
Re: Jedicut and Arduino over USB
September 18, 2012 08:20AM
Hi Manfred,

Jerome maintains a google code repository where all the jedicut plugins are hosted. You can find it at Jedicut extension. If you select source and then browse you can see a number of directories. Select branches and then Jedicut_2.3. Under USBSerial you can find all the sources, the C++ as well as the arduino code and ready useable USBSerial.dll in a debug-able as well as a release version.

Concerning the flow diagram I want to forward you to Jerome, who can explain in detail when is which function of the plugin called and with which parameters. What I can do is to post the short descriptions of the plugin functions I got from Jerome:

  • GetDllFamily: return if it's a file plugin or a communication plugin. Look at the svn for all values.
  • EmettreBit: Jedicut call it to send order to the cnc board.
  • MoteurOnOff: some cnc board use a bit to switch on/off steppers, like mm2001.
  • InitialiserChauffeEtCommunication : Jedicut call it to initiate heating settings and communication settings in the plugin (wich bit on wich port number).
  • EtatMachine: read the value on the board and return 0 or 1 if the heating value is controlled manual or by computer.
  • LireChauffeMachine: read the heating value setting up on the cnc board.
  • GetDescription: return a small description of the plugin to print it on Jedicut settings window.
  • AdapterOrdres: i use it in the last step in my algorithm if i want to rework all individual orders calculated by Jedicut. With this the plugin can adapt orders like you want: example, send 4 orders, one by stepper, at the same time.

Liebe Grüße

Martin
Re: Jedicut and Arduino over USB
September 18, 2012 11:36AM
Hi Martin,

thank you!!!smileys with beer
Andy Erwin
Re: Jedicut and Arduino over USB
September 21, 2012 07:44PM
thats very cool! what CNC board are you using and will ones on EBAY work with this system? I need to learn the arduino system and get this up and going, I have the foam cutting mechanicals just sitting there, i need to get the electronics set up and this sounds like a great way to go
Re: Jedicut and Arduino over USB
September 22, 2012 09:55AM
My CNC board is the MDLCNC from rc-letmathe. It is a board operating on a parallel printer port using the usual step/direction interface. I think every board using this interface can be used, only the arduino code needs to be adapted. When you learn to program the arduino, you will be able to operate CNC boards with completely different interfaces too, but using the standards may the way to start. We will be happy to hear from your progress in mastering the arduino and building up your system. smiling smiley
Re: Jedicut and Arduino over USB
September 28, 2012 02:58PM
Hello Martin,

i have install the USB_Serial.dll in Jedicut-Direktory DLL.

When i start Jedicut, i become a Error.



Greetings Manfred
Re: Jedicut and Arduino over USB
September 29, 2012 09:19AM
Hi Manfred,

it is not possible to download the dll by right-click and "save as" (I tested it with zip-files too). If you do so, you will get an unusable file. To get the dll you need to use a svn tool. If you wont install a svn client you can find a simple tool here: http://downloadsvn.codeplex.com/. It needs no installation. If you use e.g. https://jedicut-extension.googlecode.com/svn/branches/Jedicut_2.3/USBSerial/ for the SVN Source URL you will get all files under this path (set Type to SVN).
Have a nice weekendsmiling smiley
Re: Jedicut and Arduino over USB
September 29, 2012 03:51PM
Hi Martin,

thank's, now it goes!! smileys with beer

Greetings, Manfred
Re: Jedicut and Arduino over USB
September 29, 2012 08:52PM
Hello Martin,

you have a System, to debug the dll.

I have install VS 2010 C++ express.
What ist to do, to debug the dll.

Can you help me confused smiley

Manfred
Re: Jedicut and Arduino over USB
September 30, 2012 10:41AM
Hi Manfed,

to debug a dll in case you have no debug-able version of the program which uses the dll (in our case jedicut.exe), is a liitle bit tricky. You need to launch jedicut.exe and then using the attach-to-process feature of the visual studio debugger to connect it to the jedicut process. If you have no menu entry for 'attach to process' configured, try crtl-alt-p. After that (and the dll is already loaded) you can set breakpoints within the dll as usual in the visual studio. I hope this helps for starting.

Martin
Re: Jedicut and Arduino over USB
September 30, 2012 12:28PM
Hi Martin,

thank you, i wil exercise it.

Manfred
Re: Jedicut and Arduino over USB
September 30, 2012 09:58PM
Hi, Martin
How I can change bitrate?
For my not arduino system 115200 is too much (2x).

ZbigPL



Edited 1 time(s). Last edit at 09/30/2012 09:59PM by ZbigPL.
Re: Jedicut and Arduino over USB
September 30, 2012 10:50PM
Hi Martin,

the Debug work's, great Softwarework from you!!! thumbs up

Now i can develop a serial-port with a PIC. (tongue sticking out smiley)

Thank's and greetings, Manfred
Re: Jedicut and Arduino over USB
October 01, 2012 08:33AM
Hi ZbigPL,

yes, bascom programs may not fast enough to handle the high baudrate. I uploaded a new version of the dll's (release and debug). Now you can define within the ini-file the baud-rate the dll uses. Simply add the line e.g. "BAUDRATE = 57600" to comport.ini.smiling smiley
Re: Jedicut and Arduino over USB
October 01, 2012 01:37PM
Hi Martin,

I was probably out of print in the smiley.
Tongue I did not stick out to you.

Regards, Manfred
Re: Jedicut and Arduino over USB
October 03, 2012 07:18PM
Hello !

I work on Jedicut when I have time and the next step is to publish a small app to test plugin easily. Are you interesting ?

Manfred, what are you working on ? A new kind of adapter without arduino ? Will you share firmware code source, all plans and your Jedicut's plugin source code ?

All this projects are fascinating !

Jerome
Re: Jedicut and Arduino over USB
October 04, 2012 12:19PM
Jerome,

i work in the Winter on Adapter with a PIC-Controller in serial-com. with the Arduino dll.
On the Adapter i will create the PWM and the Driver for the Hotwire.

When the Adapter work's, i will share all Dokument's.

Manfred
Re: Jedicut and Arduino over USB
October 07, 2012 09:40AM
Very interesting project winking smiley

Jerome
Re: Jedicut and Arduino over USB
October 08, 2012 07:07PM
Quote
Martin
Hi ZbigPL,
yes, bascom programs may not fast enough to handle the high baudrate...

Thanks, Martin!
With 8 MHz clock didn't work baudrate 115200 but 128000 is OK!
My machne with chip TA8435H now works with USBserial.
I found in my treasure chest some Atmega168 chips.
So I started a few days ago Bascom and it works without any additional components!
Flash is 95% free. I must to think about heat control and so on...

We say "The farther into the forest, the more trees" (read: problems):

1. I have real parameter 0,05 mm/step in Jedicut. Now I must set about 0,003 mm/s. It would be better with real factor.
2. I unsuccesfully try change speed of wire. Where is snag?confused smiley
3. I have not tried "Pause". It will work?
4. I'm dreaming about "End of transmision" (for example "A2" in Your 2byte convention)
Re: Jedicut and Arduino over USB
October 09, 2012 09:37AM
Hi ZbigPL,

I sent you a PM concerning the points 1 and 2 (You may have something configured wrong).
-- "Pause" works, but the commands already sent to the micro controller and stored in the command buffer can't be unsent, so they will be executed, but then jedicut stops the transmission of commands.
-- You can use the command A0 (all motors off) for the "End of transmission command". It will be sent every time as last command.

Martin
Re: Jedicut and Arduino over USB
October 10, 2012 11:27AM
Quote
Martin
I sent you a PM concerning the points 1 and 2 (You may have something configured wrong).

Thank you. Of course, a lack the knowledge.

ZbigPL
Re: Jedicut and Arduino over USB
November 12, 2012 07:53AM
hello martin :-)
my English is by google translator :-)

I am not expert, but I could not find software for arduino
let alone the plugin to jedicut :-(

you may post the complete package for beginners
like me?

thanks :-)
Re: Jedicut and Arduino over USB
November 13, 2012 07:03AM
Hello apone4,

I don't have computer non but tonight or tomorrow I will post a link to download a zip file.

Where do you come from ?

Have a nice day winking smiley

Jerome
Re: Jedicut and Arduino over USB
November 20, 2012 04:40PM
Hello,
May this could work with an Arduino Nano board ?? it's more cheap : 10$ on Hobbyking...And so small that it could be integrated in the câble with sink, between CNC interface and PC...

I'll try grinning smiley
Re: Jedicut and Arduino over USB
November 21, 2012 07:48AM
Hi Vincent !
When can you try this solution ? I'm waiting for it :p

Jerome
Re: Jedicut and Arduino over USB
November 21, 2012 08:43AM
Hi,

the arduino nano has the same microcontroller as the uno. So I'm sure, that it will work. I have planned to buy a handful of this cheap boards from hobbyking, too. So maybe we can together develop an arduino powered interface cable? The software should be useable as it is.smiling smiley

Martin
Sorry, only registered users may post in this forum.

Click here to login



Aeropassion

Paris en photo | Design by Le Flaketou, création de site internet

Phorum