Hello Guest it is October 27, 2021, 01:46:57 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - freedom2000

Pages: « 1 2 3 4 »
11
Finished Plugins for Download / Re: Free USB JoyPad plugin
« on: July 21, 2010, 01:53:54 PM »
Hi Joakim,

I really enjoy your plugin. It has added what was missing on the Art's joystick plugin (3rd and 4th axis)

As it is based on a USB HID standard device, it should work with any device supporting this standard.

I have tested it with a microchip board emulating a joystick --> and it is recognized --> Well done.

If I dared, I would ask you to poivide the source code (you mentonned you would do it in the readme file)...
What I would like to do with it is only snif the code for the HID connection... (so I don't need the full software, and I would understand I you don't want to do it !)

I plan to try to setup a simple THC for plasma torch (see my post on tis post http://www.machsupport.com/forum/index.php?topic=10339.new;topicseen#new

As you can see the elctronics is pretty much finished, I am just missing an elegant way to communicate with Mach3... I think that the HID solution with my PIC18F4550 could be the best solution ...

But as I am only an hobbyist without too much time for coding... your help would be highly appreciated !
Of course anything I code is given under GPL license as well... exemple here a driver for CNC DIY board : http://www.usinages.com/driver-de-puissance-maison-pour-moteur-pas-a-pas-t3046-315.html

Cheers
JP

12
Hi Ed,

First of all I would like to thank you A LOT for the excellent job you have performed and most of all for the so clear videos you posted.

I must say that I am impressed.

I am pretty new on SDK and plugin development, and I just wanted to try to hook an usb device to Mach3 via a plugin.
Well I know that's simple... but not so much !

I have installed your framework and successfully compiled and run it (it was quite simple thanks to your tutorials)

On the other hand I have a C++ code using a HID dll to communicate with my device (a simple PIC18F4550) --> it works fine

To start with pulgins I wanted to reference this dll into your code and call it.

I have added a reference to it into Visual Studio
I have modified the code to refrence the namesapce : using namespace HIDClass;
and just added a dll call to check the usb attachement : MCHPHIDClass::USBHIDClassInit (0x4D8, 0x003F, 64);

Well just two lines of modifications... The compilation and link are OK

but when running on the second line (the call to the dll) I have a fatal error :

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.
Additional information: Impossible de charger le fichier ou l'assembly 'HID class, Version=1.0.3376.23070, Culture=neutral, PublicKeyToken=null' ou une de ses dépendances. Le fichier spécifié est introuvable.

Which in english means that the dll is not found...

Any help please, I have the feeling to be "so close" to the success !!!

Here is the plugin.cpp full code (just two lines moded from the original)

Thanks in advance
JP

Code: [Select]
//=====================================================================
//
// Plugin.cpp - the optional custom part of the plugin
//
// this source file can be filled with the actual custom code that
// makes the plugin work. it is the choice of the developer to enable
// which functions will be used from the available MachDevice calls.
//
// if this is a mixed mode dll each function can be declared as either
// an unmanaged or managed function.
//
// please see the documentation in Plugin.h for the #define statements
// that control each functions compilation.
//
// if this is a mixed mode dll and you need to keep global managed
// reference please see the MG class in ManagedGlobal.h
//
// please read the notes and comments in MachDevice.cpp for general
// information and disclaimers.
//
//=====================================================================

#include "stdafx.h"
#include "Plugin.h"
#include "MachDevice.h"
#include "ConfigDialog.h"
#include "PlugInControlDialog.h"
#include "XYZDemoDialog.h"
#include "XMLNetProfile.h"
#include "ManagedGlobal.h"

#include <stdlib.h>

//---------------------------------------------------------------------
// the default namespace for managed functions and classes
//---------------------------------------------------------------------
using namespace HIDClass;
using namespace TestMachWizard;

//---------------------------------------------------------------------
// data area
//---------------------------------------------------------------------

int menuStart; // the starting menu id

//---------------------------------------------------------------------
//
// piInitControl() - Plugin extension of InitControl()
//
// XML file can NOT be accessed since SetProName hasn't
// been called yet
//
// called EVEN if plugin is disabled
//
//---------------------------------------------------------------------

#ifdef PI_INITCONTROL
#ifdef _MANAGED
#pragma PI_MIX_INITCONTROL
#endif
bool piInitControl()
{
menuStart = GetMenuRange(MENU_COUNT);

return true;
}
#endif

//---------------------------------------------------------------------
//
// piSetProName() - Plugin extension of SetProName()
//
// XML file CAN be accessed
//
// called EVEN if plugin is disabled
//
//---------------------------------------------------------------------

#ifdef PI_SETPRONAME
#ifdef _MANAGED
#pragma PI_MIX_SETPRONAME
#endif
char* piSetProName(LPCSTR name)
{
XYZDemoConfig^ xyzDemoConfig = gcnew XYZDemoConfig;
XMLNetProfile^ profile = gcnew XMLNetProfile(gcnew String(ProfileName), "TestMachWizardPlugin", true);

profile->Load();

xyzDemoConfig->enableDlg = profile->ReadBool("Dlg"   , false);
xyzDemoConfig->enableX   = profile->ReadBool("Axis/X", true);
xyzDemoConfig->enableY   = profile->ReadBool("Axis/Y", true);
xyzDemoConfig->enableZ   = profile->ReadBool("Axis/Z", true);

MG::xyzDemoConfig = xyzDemoConfig;

return "TestMachWizard-Author-v1.0.0.0";
}
#endif

//---------------------------------------------------------------------
//
// piPostInitControl() - Plugin extension of PostInitControl()
//
// XML file can NOT be accessed
//
// called ONLY if plugin is enabled
//
//---------------------------------------------------------------------

#ifdef PI_POSTINITCONTROL
#ifdef _MANAGED
#pragma PI_MIX_POSTINITCONTROL
#endif
void piPostInitControl()
{
HMENU hMachMenu = GetMenu(MachView->MachFrame->m_hWnd);
HMENU hPluginMenu = 0;
int machMenuCnt = GetMenuItemCount(hMachMenu);
MENUITEMINFO mii;
LPTSTR txt;

for (int i = 0; i < machMenuCnt; i++)
{
mii.cbSize     = sizeof(MENUITEMINFO);
mii.fMask      = MIIM_FTYPE | MIIM_ID | MIIM_SUBMENU | MIIM_STRING;
mii.dwTypeData = NULL;

if (GetMenuItemInfo(hMachMenu, i, true, &mii))
{
txt = (LPTSTR) malloc(++mii.cch);
mii.dwTypeData = txt;

if (GetMenuItemInfo(hMachMenu, i, true, &mii))
{
if (strcmp(txt, "PlugIn Control") == 0)
{
hPluginMenu = mii.hSubMenu;
i = machMenuCnt;
}
}

free(txt);
}

if (hPluginMenu)
{
InsertMenu(hPluginMenu, -1, MF_BYPOSITION, menuStart  , "TestMachWizard");
}
}

XYZDemoDialog^ xyzDemoDialog = gcnew XYZDemoDialog();

xyzDemoDialog->labelX->Visible = MG::xyzDemoConfig->enableX;
xyzDemoDialog->labelY->Visible = MG::xyzDemoConfig->enableY;
xyzDemoDialog->labelZ->Visible = MG::xyzDemoConfig->enableZ;

xyzDemoDialog->textBoxX->Visible = MG::xyzDemoConfig->enableX;
xyzDemoDialog->textBoxY->Visible = MG::xyzDemoConfig->enableY;
xyzDemoDialog->textBoxZ->Visible = MG::xyzDemoConfig->enableZ;

xyzDemoDialog->Visible = MG::xyzDemoConfig->enableDlg;

MG::xyzDemoDialog = xyzDemoDialog;
//MCHPHIDClass::USBHIDClassInit (0x4D8, 0x003F, 64);
}
#endif

//---------------------------------------------------------------------
//
// piConfig() - Plugin extension of Config()
//
// called if user presses CONFIG in Config|Config Plugins
// even if plugin is disabled
//
// XML file CAN be accessed
//
//---------------------------------------------------------------------

#ifdef PI_CONFIG
#ifdef _MANAGED
#pragma PI_MIX_CONFIG
#endif
void piConfig()
{
ConfigDialog^ configDialog = gcnew ConfigDialog();

configDialog->ShowDialog();
MCHPHIDClass::USBHIDClassInit (0x4D8, 0x003F, 64);
}
#endif

//---------------------------------------------------------------------
//
// piStopPlug() - Plugin extension of StopPlug()
//
//---------------------------------------------------------------------

#ifdef PI_STOPPLUG
#ifdef _MANAGED
#pragma PI_MIX_STOPPLUG
#endif
void piStopPlug()
{
XYZDemoConfig^ xyzDemoConfig = MG::xyzDemoConfig;
XMLNetProfile^ profile = gcnew XMLNetProfile(gcnew String(ProfileName), "TestMachWizardPlugin", true);

if (profile->Load())
{
if (MG::xyzDemoDialog) xyzDemoConfig->enableDlg = MG::xyzDemoDialog->Visible;

profile->WriteBool("Dlg"   ,xyzDemoConfig->enableDlg);
profile->WriteBool("Axis/X",xyzDemoConfig->enableX);
profile->WriteBool("Axis/Y",xyzDemoConfig->enableY);
profile->WriteBool("Axis/Z",xyzDemoConfig->enableZ);

profile->Save();
}
}
#endif

//---------------------------------------------------------------------
//
// piUpdate() - Plugin extension of Update()
//
// XML file can NOT be accessed
//
// called ONLY if plugin is enabled
//
// WARNING - when you enable a plugin it immediately is added
// to the update loop. if you haven't initialized some items
// because PostInitControl() hasn't been called you can get
// some problems!!!
//
//---------------------------------------------------------------------

#ifdef PI_UPDATE
#ifdef _MANAGED
#pragma PI_MIX_UPDATE
#endif
void piUpdate()
{
if (MG::xyzDemoDialog)
{
XYZDemoDialog^ xyzDemoDialog = MG::xyzDemoDialog;

xyzDemoDialog->textBoxX->Text = GetDRO(800).ToString("F4");
xyzDemoDialog->textBoxY->Text = GetDRO(801).ToString("F4");
xyzDemoDialog->textBoxZ->Text = GetDRO(802).ToString("F4");
}
}
#endif

//---------------------------------------------------------------------
//
// piNotify() - Plugin extension of Notify()
//
// among other notices this is where we are notified when the
// user clicks on our 'PlugIn Control' menu item.
//
// XML file CAN be accessed on a menu item notify
//
//---------------------------------------------------------------------

#ifdef PI_NOTIFY
#ifdef _MANAGED
#pragma PI_MIX_NOTIFY
#endif
void piNotify(int id)
{
if (id == menuStart)
{
PlugInControlDialog^ pluginControlDialog = gcnew PlugInControlDialog();
XYZDemoConfig^ xyzDemoConfig = MG::xyzDemoConfig;

xyzDemoConfig->enableDlg = MG::xyzDemoDialog->Visible;

pluginControlDialog->checkBoxDlg->Checked = xyzDemoConfig->enableDlg;
pluginControlDialog->checkBoxX->Checked   = xyzDemoConfig->enableX;
pluginControlDialog->checkBoxY->Checked   = xyzDemoConfig->enableY;
pluginControlDialog->checkBoxZ->Checked   = xyzDemoConfig->enableZ;

if (pluginControlDialog->ShowDialog() == DialogResult::OK)
{
xyzDemoConfig->enableDlg = pluginControlDialog->checkBoxDlg->Checked;
xyzDemoConfig->enableX   = pluginControlDialog->checkBoxX->Checked;
xyzDemoConfig->enableY   = pluginControlDialog->checkBoxY->Checked;
xyzDemoConfig->enableZ   = pluginControlDialog->checkBoxZ->Checked;

XYZDemoDialog^ xyzDemoDialog = MG::xyzDemoDialog;

xyzDemoDialog->labelX->Visible = xyzDemoConfig->enableX;
xyzDemoDialog->labelY->Visible = xyzDemoConfig->enableY;
xyzDemoDialog->labelZ->Visible = xyzDemoConfig->enableZ;

xyzDemoDialog->textBoxX->Visible = xyzDemoConfig->enableX;
xyzDemoDialog->textBoxY->Visible = xyzDemoConfig->enableY;
xyzDemoDialog->textBoxZ->Visible = xyzDemoConfig->enableZ;

xyzDemoDialog->Visible = xyzDemoConfig->enableDlg;
}
}
}
#endif

//---------------------------------------------------------------------
//
// piDoDwell() - Plugin extension of DoDwell()
//
//---------------------------------------------------------------------

#ifdef PI_DODWELL
#ifdef _MANAGED
#pragma PI_MIX_DODWELL
#endif
void piDoDwell(double time)
{
}
#endif

//---------------------------------------------------------------------
//
// piReset() - Plugin extension of Reset()
//
//---------------------------------------------------------------------

#ifdef PI_RESET
#ifdef _MANAGED
#pragma PI_MIX_RESET
#endif
void piReset()
{
}
#endif

//---------------------------------------------------------------------
//
// piJogOn() - Plugin extension of JogOn()
//
//---------------------------------------------------------------------

#ifdef PI_JOGON
#ifdef _MANAGED
#pragma PI_MIX_JOGON
#endif
void piJogOn(short axis, short dir, double speed)
{
}
#endif

//---------------------------------------------------------------------
//
// piJogOff() - Plugin extension of JogOff()
//
//---------------------------------------------------------------------

#ifdef PI_JOGOFF
#ifdef _MANAGED
#pragma PI_MIX_JOGOFF
#endif
void piJogOff(short axis)
{
}
#endif

//---------------------------------------------------------------------
//
// piPurge() - Plugin extension of Purge()
//
//---------------------------------------------------------------------

#ifdef PI_PURGE
#ifdef _MANAGED
#pragma PI_MIX_PURGE
#endif
void piPurge(short flags)
{
}
#endif

//---------------------------------------------------------------------
//
// piProbe() - Plugin extension of Probe()
//
//---------------------------------------------------------------------

#ifdef PI_PROBE
#ifdef _MANAGED
#pragma PI_MIX_PROBE
#endif
void piProbe()
{
}
#endif

//---------------------------------------------------------------------
//
// piHome() - Plugin extension of Home()
//
//---------------------------------------------------------------------

#ifdef PI_HOME
#ifdef _MANAGED
#pragma PI_MIX_HOME
#endif
void piHome(short axis)
{
}
#endif

JP

13
I think im in the same camp as stirling there, there is no avoiding it is negative with respect to true earth and so has to be inverted

Hi Matt,

Why do you say this ?

VClamp - VTorch = 0 - (- 300) = 300 V --> there is no trick here.

If you put the "black" on the tip and the "red" on the clamp you WILL measure a positive voltage

f you connect the clamp to the earth (even if it is not the case electrically speaking on my Plasma) then you will still measure a positive voltage between clamp and tip (clamp - tip = 300V)

Right or not ?
JP


14
Just to go on a bit !

You are absolutely right when saying that Vss (and Vdd) will float (or rather sink) under the earth level. But who cares ?

The only NEEDED condition is also that any signal entering in (or going out from) the µcontroler is NOT connected both to earth and Vss (or Vdd). And this is achieved safely as these connections are optical ones (via the optocoupler). These signals are thus fully isolated from the plasma side. You can go on using your PC without risking an "explosion"  ;)

Note also that I have on purpose (for clarity) suppressed the diode bridge as it is useless when you know where the + and - sides at the plasma level are.
(If not or if you want an "universal" system just put the diode birdge).

Is this schema safe ? The answer is YES (if not please go on explaining why)
I proposed to put the PCB into a plastic box --> this is NOT a joke : we must do it
And by the way it is exactly how electronic devices not grouded work. Let's look at a dremel : it is NOT grounded, and to be safe it is surrounded by a plastic body...

JP


15
Hi,


Any time you are using a voltage transformer, you are working "un earthed"



Any time you connect an electrical device on sector (110VAC or 220 VAC) neither the phase nor the neutral is connected to earth.

However these devices are safe... Only the body is connected to earth to protect you against leakage between sector and you (earth)

Of course the plasma "clamp" will be connected to earth on the CNC, it will be difficult not to do it !

Thus the Torch "clamp" V+ will be connected de facto to earth

And my schema will still work ... provided that neither Vss nor Vdd touch the earth (which is easy to achieve --> put it in a plastic box  ;)
And even if you touch the earth with Vss... it would be the same as touching the metal part with the torch tip...
My electronics should survive if the plasma does.
In those conditions voltage difference between Vdd-Vss will be 5V (in blue)  when voltage difference between torch clamp and torch tip will be 300V (in red)



JP

16
LOL - I hope the next time I need a tooth pulled the dentist has an easier time than this!
Just for me, like I said - humour me - stick one lead (I don't care which) of your scope/voltmeter on your your "clamp" and the other lead onto your Vss, fire the torch and take the reading. Then stick one lead onto your "plasma metal body" and leave your other lead on your Vss, fire the torch and take the reading. You never know - you might find the results interesting.

well... I don't know how to say it more clearly...

V"clamp" - Vss = 0V

earth - Vss = nothing (oscillating between -0.xx and +0.xx V --> not a fixed votage)
earth - plasma clamp = nothing
earth- torch tip = nothing

and that's normal as earth is NOT connected to torch tip nor torch ground... (unless you connect the metal part to be cut to earth you will not have a voltage reference between earth and plasma "clamp" or plasma torch tip...)

That's also normal as the power supply for my PIC is not connected to earth.

keep you teeth :-)
JP

17
Hi all,

Just to be clear on terminology ...

What I call "ground" is the earth of the 220V AC plug connected to the frame of the plasma device
What I call + is the clamp of the plasma connected to the metal to be cut
What I call - is the tip of the torch



The ground is connected to nothing... No measure of voltage possible between earth/ground and + or minus

The voltage between + (clamp) and - (tip torch) is -300V when the arc is off but trigerred
The voltage between + and minus is betwen -50V to -200V when cutting

BTW, my serail connexion from the PIC to the PC is working  ;)
I will be able to monitor voltage on an excel spreadsheet

JP

18
I have not connected the ground to anything... so I cannot do this measure...
???

You just put one probe from your scope or meter to plasma ground and the other probe to Vss - that gives you the potential difference (voltage) accross them.

What do you mean by "Ground" ?
Neither the torch tip (torch -) nor the clamp (torch +) are connected with the plasma metal body which is connected to real ground...

JP

19
The Vss is connected both to the minus signal of the bridge and to the minus power supply of the PIC (exactly as on my schema)
The PIC itself is powered by a small mobile phone 220V to 5V DC power supply

I appreciate you guys are on a role here but just indulge me one more time if you will. Can you (carefully) take a voltage reading between TRUE ground and Vss whilst the torch is firing and let me know what it is please?

I have not connected the ground to anything... so I cannot do this measure...
The voltage between the plasma "ground" (ie the metal plate) and the troch tip is -300V before cutting and drops to -50 to -200V when cutting.

I will try to monitor this voltage more precisely after ADC conversion and input in my PC via serail link.

JP

20
Thanks Scott for these informations.

On my side, as I am an hobbyist, I do not plan to use modbus and so I look for the cheapest solution available.
A Pic + a few componants could give a "standalone" THC for less than 10$  ;)

A believe that Mach3 is fast enough on the Z axis to achieve a proper motion when ready the UP/DOWN signals on the // port.
All the rest could be done in the PIC at a rate of 0,1s per measure (roughly).

To save a few pins on my PIC I wanted to send some DRO to my board via a standard serial port (not modbus).
I don't care about the speed of this serial link as these parameters will just be sent for initialisation purpose from a VBscript attached to a button. So I don't need real time.

Well I go on with my breadboard solution... Just to see !


JP




Pages: « 1 2 3 4 »