About CNC Software Development

Post anything you want to discuss with others about the software.

About CNC Software Development

Postby Alprn27 » Wed Feb 22, 2023 12:43 pm

Hi !

I am using Stepcraft M500 CNC machine and I am trying to use this machine with my own code which is written with the UC100.dll file and the UC100.h files from the API file in the UCCNC software's source files. But unfortunately I can't move the machine with my codes. I don't know where I am doing wrong or missing. I also can use the header file's some functions with my code so I can see with my code " How much devices connected the pc ?","What is the device type ?". But like I said I cant move the head of CNC. I am sharing my codes below. If you guys can help I would be glad. :D
Attachments
Kod.txt
(7.69 KiB) Downloaded 285 times
Alprn27
 
Posts: 5
Joined: Wed Feb 22, 2023 12:27 pm

Re: About CNC Software Development

Postby cncdrive » Wed Feb 22, 2023 10:31 pm

Device type is a structure defining the type of motion controller.
The structures you can find in the C# header file which you can also find in the UCCNC/API folder, my advice is to check that file for the structure definition.
cncdrive
Site Admin
 
Posts: 4888
Joined: Tue Aug 12, 2014 11:17 pm

Re: About CNC Software Development

Postby Alprn27 » Thu Feb 23, 2023 2:15 pm

I looked the files that you said before. Me and my friend tried another code with C++ and we can't still move CNC head. Can you guys please look again ?

Code: Select all
#include "UC100.h" // UC100API Adding
#include <iostream>
#include <conio.h>

using namespace std;

int main() {

    int deviceCount;
    ListDevices(&deviceCount);
    cout << "Device Count is : " << deviceCount << endl;
    int BoardId = 1;
    int Type;
    int SerialNumber;
    DeviceInfo(BoardId, &Type, &SerialNumber);
    cout << "Device Type : " << Type << endl;
    cout << "Device Serial Number : " << SerialNumber << endl;
    int resul = Open(BoardId);
    if (resul == 0)
        cout << "Device is open now" << endl;
    unsigned __int64 Out;
    unsigned __int64 Inp;
    unsigned __int64 ınp = GetInput(&Inp);
    unsigned __int64 out = GetOutput(&Out);

    cout << ınp << endl;
    cout << out << endl;
   
    int Rate = 100;
    SetStepRate(Rate);

 

    AxisSetting ax;

    ax.Axis = 0;
    ax.Enable = true;
    ax.EnablePin = 0;
    ax.DirPin = 2;
    ax.StepPin = 3;
    ax.MaxAccel = 400;
    ax.MaxVel = 4100;
    ax.StepPer = 320;
    ax.HomePin = 12;
    ax.LimitPPin = 12;
    ax.SoftLimitP = 100000;
    ax.LimitNPin = 12;
    ax.SoftLimitN = -100000;
    ax.CompAccel = 480;
    cout << ax.MaxAccel << "  " << ax.Enable << "  " << ax.StepPin << endl;

    //-------------------------Get ve Set fonksiyonlarıyla Structlar----------------------------------------
    Stop();          // Reset Tuşu yerine Stop fonksiyonu

    int getaxis = GetAxisSetting(&ax);
    if (getaxis == 0)
    {
        cout << " Axis getting is accomplished " << endl;
    }
    else
        cout << " Get Axis Result error code : " << getaxis << endl;

    Versio vers;
    GetVersio(&vers);
    cout << "firmware version number : " << vers.FWVersion << endl;
    cout << "hardware version number : " << vers.HWVersion << endl;
    cout << "API dll version number : " << vers.APIVersion << endl;
    cout << "serial number in decimal value : " << vers.SerialNumber << endl;
    cout << "Device Type : " << vers.DeviceType << endl;
   
    Stat stat;
    GetStatus(&stat);
    int ID = stat.CurrentID;
    cout << "Current ID is : " << stat.CurrentID << endl;
    cout << "Idle is : " << stat.Idle << endl;

    int setaxis = SetAxisSetting(&ax);
    if (setaxis == 0)
        cout << "axis setting is accomplished " << endl;
    else
        cout << " Set Axis Result error code : " << setaxis << endl;
   
    TrajParam traj;
    traj.ConstantVel = true;
    int trajResult = SetTrajParam(&traj);
    if (trajResult == 0)
    {
        GetTrajParam(&traj);
        cout << "Traj Constant Vel : " << traj.ConstantVel << endl;
    }
    else
        cout << " Traj Result error code : " << trajResult << endl;

    Statistics statis;
    GetStatistics(&statis);
    double distA = statis.DistA;
    cout << distA << endl;
    statis.DistA = 10.0;
    SetStatistics(&statis);
    //--------------------------------Hareket Fonksiyonu Denemeleri-----------------
    SetFeedMode(10);
    SetMotionProgressState(true);
    int jogon =JogOn(0, true, true);

    if (jogon == 0)
        cout << " Jog On Function is accomplished " << endl;
    else
        cout << " Jog On Result error code : " << jogon << endl;


    int Xpos, Ypos, Zpos, Apos, Bpos, Cpos;

    GetAxisIndex(&Xpos, &Ypos, &Zpos, &Apos, &Bpos, &Cpos);
    cout << Xpos <<" "<< Ypos <<" "<< Zpos << " " << Apos << " " << Bpos << " " << Cpos << endl;

           // AddLinearMove işlevini çağırmak
    double x = 100.0, y = 0.0, z = 0.0, a = 0.0, b = 0.0, c = 0.0, Feed = 10.0;
    int result = AddLinearMove(x, y, z, a, b, c, Feed, ID);
    if (result == 0)
    {
        cout << "Add Linear Move Command is activated " << endl;
        int axisControl = SetAxisPosition(200, y, z, a, b, c);
        if (axisControl == 0)
            cout << "Axis Position Setted " << endl;
        else
            cout << " Traj Result error code : " << axisControl << endl;
    }
    else
        cout << " Linear Move Result error code : " << result << endl;

    int axis = 0, stepcount = 2;
    double step = 2.0 , speed = 30.0;
    bool dir = true;

    int linear = AddLinearMoveRel(axis, step, stepcount, speed, dir);

    if (linear == 0)
        cout << "Relative Linear Move Position Added " << endl;
    else
        cout << " Relative Linear Move Position Result error code : " << linear << endl;

    cout << "Puffer is : " << stat.Puffer << endl;
    cout << "Actuall Feed rate is : " << stat.Feed << endl;
    cout << "Programmed Feed rate is : " << stat.ProgrammedFeed << endl;

    SetMotionProgressState(false);
   
    return 0;
}
Alprn27
 
Posts: 5
Joined: Wed Feb 22, 2023 12:27 pm

Re: About CNC Software Development

Postby dezsoe » Thu Feb 23, 2023 4:43 pm

Which UC controller do you test?
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: About CNC Software Development

Postby Alprn27 » Fri Feb 24, 2023 7:52 am

dezsoe wrote:Which UC controller do you test?


I am trying to use UC100 USB CNC motion controller.
Alprn27
 
Posts: 5
Joined: Wed Feb 22, 2023 12:27 pm

Re: About CNC Software Development

Postby A_Camera » Fri Feb 24, 2023 10:33 am

Alprn27 wrote:
dezsoe wrote:Which UC controller do you test?


I am trying to use UC100 USB CNC motion controller.

Made by CNC Drive Hungary or is it a pirate copy?
A_Camera
 
Posts: 639
Joined: Tue Sep 20, 2016 11:37 am

Re: About CNC Software Development

Postby Alprn27 » Fri Feb 24, 2023 10:42 am

A_Camera wrote:
Alprn27 wrote:
dezsoe wrote:Which UC controller do you test?


I am trying to use UC100 USB CNC motion controller.

Made by CNC Drive Hungary or is it a pirate copy?


I think it's original but just in case I am adding a picture of it.
Attachments
WhatsApp Image 2023-02-24 at 13.39.15.jpeg
The UC100 that I have
Alprn27
 
Posts: 5
Joined: Wed Feb 22, 2023 12:27 pm

Re: About CNC Software Development

Postby cncdrive » Fri Feb 24, 2023 1:45 pm

Your UC100 looks original.
And if the blue LED is on when you connect with the API then it is sure a genuine UC100.

Fake Chinese UC100 controllers do not work with any of our softwares, because they are not clones or copies, they are Chinese controllers with Chinese code, so they are not at all compatible with any of our softwares.
The only common between our UC100 and the Chinese UC100 is the name 'UC100'.
cncdrive
Site Admin
 
Posts: 4888
Joined: Tue Aug 12, 2014 11:17 pm

Re: About CNC Software Development

Postby dezsoe » Fri Feb 24, 2023 9:21 pm

I am trying to use UC100 USB CNC motion controller.

That's OK. I asked it because controllers other than UC100 need conversion from port/pin to UCpin. (UCpin is the bit number + 1 and you have to set this in AxisSettings etc.) The UC100 has only one port and using UC100 the UCpin equals to the pin number.

(But when you use GetInput, GetOutput or SetOutput you'll find that even the UC100 needs this conversion. The bit in the 64 bit value that these functions use is 1 << (UCpin - 1). The map of bits is different for inputs and outputs. The UC100 UCpin values are:
- outputs: 1 to 12 are for pins 1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 16, 17
- inputs: 1 to 5 are for pins 10, 11, 12, 13, 15.)
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: About CNC Software Development

Postby Alprn27 » Mon Feb 27, 2023 8:31 am

dezsoe wrote:
I am trying to use UC100 USB CNC motion controller.

That's OK. I asked it because controllers other than UC100 need conversion from port/pin to UCpin. (UCpin is the bit number + 1 and you have to set this in AxisSettings etc.) The UC100 has only one port and using UC100 the UCpin equals to the pin number.

(But when you use GetInput, GetOutput or SetOutput you'll find that even the UC100 needs this conversion. The bit in the 64 bit value that these functions use is 1 << (UCpin - 1). The map of bits is different for inputs and outputs. The UC100 UCpin values are:
- outputs: 1 to 12 are for pins 1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 16, 17
- inputs: 1 to 5 are for pins 10, 11, 12, 13, 15.)


Can you please share me any code about this ? When you tell theoricly I am confused. With any code I can understand better.
Alprn27
 
Posts: 5
Joined: Wed Feb 22, 2023 12:27 pm

Next

Return to General discussion about the UCCNC software

Who is online

Users browsing this forum: Tweakie.CNC and 11 guests

cron