Need Help! Problem jig grinding machine. - Page 3


Page 3 of 5 FirstFirst 12345 LastLast
Results 25 to 36 of 55

Thread: Problem jig grinding machine.

  1. #25
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2513
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    Sorry for completely miss understanding. That should be possible. It will require a bit of C Code to Output in that Sign+Magnitude format instead of the normal +/-10V format.

    You might look at the "Setup Gcode 4 axis PWM signMag.c" example. Change the OutputSignMag() function to output to a DAC instead of a PWM. So for example change:

    FPGA(IO_PWMS+pwm*2) = chan[ch].Output;

    to

    DAC(pwm, chan[ch].Output);

    Set the Output Mode to No Output as you will be doing the Output with the C Program.

    I assume you will have encoder feedback?

    I believe this Gentleman did something similar using a hydraulic proportional valve:



    HTH
    Regards

    TK
    http://dynomotion.com


  2. #26
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi, Tom!
    Thanks a lot for Your supporting and patience! But we have some issues (again). There is problem while compiling (after changes in example, see picture). Our knowledges in C programming not very good)), maybe You can prompt us what we doing wrong?
    Problem jig grinding machine.-jpg
    P.S. our cylinder has optical linear encoder.

    Attached Thumbnails Attached Thumbnails Problem jig grinding machine.-jpg  


  3. #27
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2513
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Opps the DAC value needs to be an integer. Try changing:

    DAC(pwm, chan[ch].Output);

    to

    DAC(pwm, (int)chan[ch].Output);

    You must also change the other 3 places where fixed data is written to the FPGA to write to the DAC instead

    MAXPWM will probably need to be increased to 2047 if you require the full 0-10V output.

    Regards

    TK
    http://dynomotion.com


  4. #28
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2513
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Also I now see you missed a negative sign on the second instance. The idea is that when the output is negative then we output the negative of it which would be a positive value:

    DAC(pwm, (int)-chan[ch].Output);

    Regards

    TK
    http://dynomotion.com


  5. #29
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi, Tom!
    We try to change this strings and program really compiles, but "dir_bit" wont set correctly. We need to set one bit, when voltage is negative and set another one bit and reset first bit, when voltage is positive and in reverse order.
    For example, we need to determine sign of voltage on ch3 and switch bit accordingly to sign of measured voltage.

    Problem jig grinding machine.-png

    Attached Thumbnails Attached Thumbnails Problem jig grinding machine.-png  


  6. #30
    Registered
    Join Date
    Jun 2004
    Location
    Scotland
    Posts
    265
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Can you post the actual c file, or copy and paste it into code tags, rather than a screenshot?

    What you want is easily doable, but I'd rather not re-type the whole file, for what is a only a couple lines of extra code.



  7. #31
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    No problem, there is the file.
    Code:
    #include "KMotionDef.h"
    
    
    // Defines axis as Servos with output as PWM Sign and Magnitude
    // enables them
    // sets them as an xy coordinate system for GCode
    
    
    #define MAXPWM 242
    #define DIR_BIT0 30
    #define DIR_BIT1 31
    #define DIR_BIT2 32
    #define DIR_BIT3 33
    
    
    void OutputSignMag(int ch, int pwm, int dir_bit);
    
    
    int main() 
    {
        ch0->InputMode=ENCODER_MODE;
        ch0->OutputMode=NO_OUTPUT_MODE;
        ch0->Vel=100.000000;
        ch0->Accel=1000.000000;
        ch0->Jerk=10000.000000;
        ch0->P=1.000000;
        ch0->I=0.000000;
        ch0->D=0.000000;
        ch0->FFAccel=0.000000;
        ch0->FFVel=0.000000;
        ch0->MaxI=200.000000;
        ch0->MaxErr=200.000000;
        ch0->MaxOutput=200.000000;
        ch0->DeadBandGain=1.000000;
        ch0->DeadBandRange=0.000000;
        ch0->InputChan0=0;
        ch0->InputChan1=1;
        ch0->OutputChan0=0;
        ch0->OutputChan1=1;
        ch0->LimitSwitchOptions=0x0;
        ch0->InputGain0=1.000000;
        ch0->InputGain1=1.000000;
        ch0->InputOffset0=0.000000;
        ch0->InputOffset1=0.000000;
        ch0->invDistPerCycle=1.000000;
        ch0->Lead=0.000000;
        ch0->MaxFollowingError=1000000000.000000;
        ch0->StepperAmplitude=250.000000;
    
    
        ch0->iir[0].B0=1.000000;
        ch0->iir[0].B1=0.000000;
        ch0->iir[0].B2=0.000000;
        ch0->iir[0].A1=0.000000;
        ch0->iir[0].A2=0.000000;
    
    
        ch0->iir[1].B0=1.000000;
        ch0->iir[1].B1=0.000000;
        ch0->iir[1].B2=0.000000;
        ch0->iir[1].A1=0.000000;
        ch0->iir[1].A2=0.000000;
    
    
        ch0->iir[2].B0=1.000000;
        ch0->iir[2].B1=0.000000;
        ch0->iir[2].B2=0.000000;
        ch0->iir[2].A1=0.000000;
        ch0->iir[2].A2=0.000000;
    
    
        ch1->InputMode=ENCODER_MODE;
        ch1->OutputMode=NO_OUTPUT_MODE;
        ch1->Vel=100.000000;
        ch1->Accel=1000.000000;
        ch1->Jerk=10000.000000;
        ch1->P=1.000000;
        ch1->I=0.000000;
        ch1->D=0.000000;
        ch1->FFAccel=0.000000;
        ch1->FFVel=0.000000;
        ch1->MaxI=200.000000;
        ch1->MaxErr=200.000000;
        ch1->MaxOutput=200.000000;
        ch1->DeadBandGain=1.000000;
        ch1->DeadBandRange=0.000000;
        ch1->InputChan0=1;
        ch1->InputChan1=2;
        ch1->OutputChan0=3;
        ch1->OutputChan1=2;
        ch1->LimitSwitchOptions=0x0;
        ch1->InputGain0=1.000000;
        ch1->InputGain1=1.000000;
        ch1->InputOffset0=0.000000;
        ch1->InputOffset1=0.000000;
        ch1->invDistPerCycle=1.000000;
        ch1->Lead=0.000000;
        ch1->MaxFollowingError=1000000000.000000;
        ch1->StepperAmplitude=250.000000;
    
    
        ch1->iir[0].B0=1.000000;
        ch1->iir[0].B1=0.000000;
        ch1->iir[0].B2=0.000000;
        ch1->iir[0].A1=0.000000;
        ch1->iir[0].A2=0.000000;
    
    
        ch1->iir[1].B0=1.000000;
        ch1->iir[1].B1=0.000000;
        ch1->iir[1].B2=0.000000;
        ch1->iir[1].A1=0.000000;
        ch1->iir[1].A2=0.000000;
    
    
        ch1->iir[2].B0=1.000000;
        ch1->iir[2].B1=0.000000;
        ch1->iir[2].B2=0.000000;
        ch1->iir[2].A1=0.000000;
        ch1->iir[2].A2=0.000000;
    
    
        ch2->InputMode=ENCODER_MODE;
        ch2->OutputMode=NO_OUTPUT_MODE;
        ch2->Vel=100.000000;
        ch2->Accel=1000.000000;
        ch2->Jerk=10000.000000;
        ch2->P=1.000000;
        ch2->I=0.000000;
        ch2->D=0.000000;
        ch2->FFAccel=0.000000;
        ch2->FFVel=0.000000;
        ch2->MaxI=200.000000;
        ch2->MaxErr=200.000000;
        ch2->MaxOutput=200.000000;
        ch2->DeadBandGain=1.000000;
        ch2->DeadBandRange=0.000000;
        ch2->InputChan0=2;
        ch2->InputChan1=3;
        ch2->OutputChan0=4;
        ch2->OutputChan1=5;
        ch2->LimitSwitchOptions=0x0;
        ch2->InputGain0=1.000000;
        ch2->InputGain1=1.000000;
        ch2->InputOffset0=0.000000;
        ch2->InputOffset1=0.000000;
        ch2->invDistPerCycle=1.000000;
        ch2->Lead=0.000000;
        ch2->MaxFollowingError=1000000000.000000;
        ch2->StepperAmplitude=250.000000;
    
    
        ch2->iir[0].B0=1.000000;
        ch2->iir[0].B1=0.000000;
        ch2->iir[0].B2=0.000000;
        ch2->iir[0].A1=0.000000;
        ch2->iir[0].A2=0.000000;
    
    
        ch2->iir[1].B0=1.000000;
        ch2->iir[1].B1=0.000000;
        ch2->iir[1].B2=0.000000;
        ch2->iir[1].A1=0.000000;
        ch2->iir[1].A2=0.000000;
    
    
        ch2->iir[2].B0=1.000000;
        ch2->iir[2].B1=0.000000;
        ch2->iir[2].B2=0.000000;
        ch2->iir[2].A1=0.000000;
        ch2->iir[2].A2=0.000000;
    
    
        ch3->InputMode=ENCODER_MODE;
        ch3->OutputMode=NO_OUTPUT_MODE;
        ch3->Vel=100.000000;
        ch3->Accel=1000.000000;
        ch3->Jerk=10000.000000;
        ch3->P=1.000000;
        ch3->I=0.000000;
        ch3->D=0.000000;
        ch3->FFAccel=0.000000;
        ch3->FFVel=0.000000;
        ch3->MaxI=200.000000;
        ch3->MaxErr=200.000000;
        ch3->MaxOutput=200.000000;
        ch3->DeadBandGain=1.000000;
        ch3->DeadBandRange=0.000000;
        ch3->InputChan0=3;
        ch3->InputChan1=4;
        ch3->OutputChan0=7;
        ch3->OutputChan1=6;
        ch3->LimitSwitchOptions=0x0;
        ch3->InputGain0=1.000000;
        ch3->InputGain1=1.000000;
        ch3->InputOffset0=0.000000;
        ch3->InputOffset1=0.000000;
        ch3->invDistPerCycle=1.000000;
        ch3->Lead=0.000000;
        ch3->MaxFollowingError=1000000000.000000;
        ch3->StepperAmplitude=250.000000;
    
    
        ch3->iir[0].B0=1.000000;
        ch3->iir[0].B1=0.000000;
        ch3->iir[0].B2=0.000000;
        ch3->iir[0].A1=0.000000;
        ch3->iir[0].A2=0.000000;
    
    
        ch3->iir[1].B0=1.000000;
        ch3->iir[1].B1=0.000000;
        ch3->iir[1].B2=0.000000;
        ch3->iir[1].A1=0.000000;
        ch3->iir[1].A2=0.000000;
    
    
        ch3->iir[2].B0=1.000000;
        ch3->iir[2].B1=0.000000;
        ch3->iir[2].B2=0.000000;
        ch3->iir[2].A1=0.000000;
        ch3->iir[2].A2=0.000000;
        
        EnableAxisDest(0,0);
        EnableAxisDest(1,0);
        EnableAxisDest(2,0);
        EnableAxisDest(3,0);
    
    
        DefineCoordSystem(0,1,2,3);
        SetBitDirection(26,1);          // Set bit 26 (PWM 0 as an output)
        SetBitDirection(27,1);          // Set bit 27 (PWM 1 as an output)
        SetBitDirection(28,1);          // Set bit 28 (PWM 2 as an output)
        SetBitDirection(29,1);          // Set bit 29 (PWM 3 as an output)
        
        SetBitDirection(DIR_BIT0,1);    // Set bit 30 (Direction an output)
        SetBitDirection(DIR_BIT1,1);    // Set bit 31 (Direction an output)
        SetBitDirection(DIR_BIT2,1);    // Set bit 32 (Direction an output)
        SetBitDirection(DIR_BIT3,1);    // Set bit 33 (Direction an output)
        
        FPGA(IO_PWMS_PRESCALE) = 1;      // set pwm period to 30 KHz
        FPGA(IO_PWMS+1) = 1;            // enable the PWM
        FPGA(IO_PWMS+3) = 1;            // enable the PWM
        FPGA(IO_PWMS+5) = 1;            // enable the PWM
        FPGA(IO_PWMS+7) = 1;            // enable the PWM
    
    
        for (;;)  //loop forever
        {
            WaitNextTimeSlice();
            OutputSignMag(0,0,DIR_BIT0);
            OutputSignMag(1,1,DIR_BIT1);
            OutputSignMag(2,2,DIR_BIT2);
            OutputSignMag(3,3,DIR_BIT3);
        }
    }
    
    
    // put the servo Output to a specified PWM channel 
    // and direction bit in signed and magnitude mode
    
    
    void OutputSignMag(int ch, int pwm, int dir_bit)
    {
        if (chan[ch].Enable)
        {
            if (chan[ch].Output >= 0)
            {
                if (chan[ch].Output > MAXPWM) // don't go to 100%
                    FPGA(IO_PWMS+pwm*2) = MAXPWM;  
                else
                    DAC(pwm, (int)-chan[ch].Output);  
                SetBit(dir_bit);
            }
            else
            {
                if (chan[ch].Output < -MAXPWM) // don't go to 100%
                    FPGA(IO_PWMS+pwm*2) = MAXPWM;  
                else
                    DAC(pwm, (int)-chan[ch].Output);  
                ClearBit(dir_bit);
            }
        }
        else
        {
            FPGA(IO_PWMS+pwm*2) = 0;  // whenever not enabled put 0% duty cycle
        }
    }


    Attached Files Attached Files


  8. #32
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2513
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    I'd prefer that you learn to modify the program yourself. Its like:

    Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime

    We need to set one bit, when voltage is negative and set another one bit and reset first bit, when voltage is positive and in reverse order.
    So if I understand this correctly you require two outputs that must be always driven opposite polarity? If so what two Output bits are they wired to?

    Please answer each of the following questions:

    #1 Have you read through the code?

    #2 Can you understand any parts of it?

    #3 Can you see that blocks of code are identified with curly brackets { } that mark a beginning and end?
    You might read this.

    #4 Do you understand the programming concept of "if" and "else" ?

    #5 Do you understand what SetBit and ClearBit do?

    #6 Do you understand the concept of a function (subroutine)

    Regards

    TK
    http://dynomotion.com


  9. #33
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi Tom!
    You understand us correctly. This bits are 144 and 145.
    About this questions:
    #1 Yes, of course
    #2 Partially
    #3 We read it. We understand that
    #4 In a general sense, we understand, but the problems with syntax
    #5 Yes, setbit sets some bit to '1' and clearbit sets to '0'
    #6 Probably, yes

    Code:
    DefineCoordSystem(0,1,2,3);
        SetBitDirection(26,1);          // Set bit 26 (PWM 0 as an output)
        SetBitDirection(27,1);          // Set bit 27 (PWM 1 as an output)
        SetBitDirection(28,1);          // Set bit 28 (PWM 2 as an output)
        SetBitDirection(29,1);          // Set bit 29 (PWM 3 as an output)
        
        SetBitDirection(DIR_BIT0,1);    // Set bit 30 (Direction an output)
        SetBitDirection(DIR_BIT1,1);    // Set bit 31 (Direction an output)
        SetBitDirection(DIR_BIT2,1);    // Set bit 32 (Direction an output)
        SetBitDirection(DIR_BIT3,1);    // Set bit 33 (Direction an output)
        
        FPGA(IO_PWMS_PRESCALE) = 1;      // set pwm period to 30 KHz             (this is a multiplier for PWM)
        FPGA(IO_PWMS+1) = 1;            // enable the PWM                         (i am not fully understand, what digit is added to IO_PWMS)
        FPGA(IO_PWMS+3) = 1;            // enable the PWM                        -//-
        FPGA(IO_PWMS+5) = 1;            // enable the PWM                        -//-
        FPGA(IO_PWMS+7) = 1;            // enable the PWM                        -//-
    
    
        for (;;)  //loop forever
        {
            WaitNextTimeSlice();
            OutputSignMag(0,0,DIR_BIT0);                                        // (now i don`t understand this string )
            OutputSignMag(1,1,DIR_BIT1);                                        //  -//-
            OutputSignMag(2,2,DIR_BIT2);                                        //  -//-
            OutputSignMag(3,3,DIR_BIT3);                                        //  -//-
        }
    }
    
    
    // put the servo Output to a specified PWM channel 
    // and direction bit in signed and magnitude mode
    
    
    void OutputSignMag(int ch, int pwm, int dir_bit) (function and args)
    {
        if (chan[ch].Enable)
        {
            if (chan[ch].Output >= 0)                                             //(if output channel above or equally zero value, then run next actions)
            {
                if (chan[ch].Output > MAXPWM) // don't go to 100%
                    FPGA(IO_PWMS+pwm*2) = MAXPWM;                                  //(i don`t understand value for FPGA, i mean 'IO_PWMS+pwm*2')
                else
                    DAC(pwm, (int)-chan[ch].Output);  
                SetBit(dir_bit);                                                //(set value '1' to 'dirbit' )
            }
            else
            {
                if (chan[ch].Output < -MAXPWM) // don't go to 100%                // (same, as previous)
                    FPGA(IO_PWMS+pwm*2) = MAXPWM;  
                else
                    DAC(pwm, (int)-chan[ch].Output);  
                ClearBit(dir_bit);
            }
        }
        else
        {
            FPGA(IO_PWMS+pwm*2) = 0;  // whenever not enabled put 0% duty cycle            
            
            
        }
    }

    Best regards!



  10. #34
    Gold Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    2513
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Hi vadim_cnc,

    Here are some things you should fully understand:

    #1 The original example was Outputting to KFLOP PWMs (Pulse Width Modulation) by writing to FPGA Registers. Each PWM has an Output that has to be set to Output Mode. Each PWM has to be enabled. There is a Pre-Scaler for all the PWMs to set the Frequency. To set the value of a PWM an FPGA register is written to. The PWMs are controlled by 8 addresses (2 each) starting at address IO_PWMS. So that is why a digit is added to determine which register to write to.

    In your case you want to use a Kanalog DAC instead. DACs are simpler and don't need to be configured or enabled. Just use the DAC(X,Y); command to set the voltage where X is which DAC to use and Y is a value from -2047 to +2047 which represents +/-10V. But you only want positive magnitude so the value should always be 0-2047.

    Every line that wrote a value to the FPGA should now write a value to a DAC instead. There should be no FPGA commands left in the program at all.

    All the stuff initializing for the PWMs is unnecessary and can be removed (Setting PWMs as Outputs, Prescale, and Enables).

    #2 The original example was for 4 Axes. A function was used, OutputSignMag() and called 4 times for the 4 axes. The function passed 3 parameters. Which Axis, which PWM, and which IO bit to use for the Direction output.

    In your case I believe you only have 1 Axis. So only call the function one time not 4 times. You will need to pass 4 parameters because you have 2 output bits to set based on the direction. Which Axis, Which DAC, the first Direction Bit (144), and the second Direction Bit (145).

    Change the function definition to have 4 appropriate parameters like this:
    void OutputSignMag(int ch, int dac, int dir_bit0, int dir_bit1)


    #3 The "if" statement is used to be able to do different things based on whether the Output is positive or negative. When the value is negative we want to take the negative of it (negative of negative is positive). Your latetest code outputs the negative in both cases regardless of whether the value is negative or positive.

    if (chan[ch].Output >= 0)
    ......
    ...... This code is used when value is positive
    ......
    else
    ......
    ...... This code is used when value is negative
    ......

    #4 change the code to SetBit and ClearBit two bits instead of only one bit.

    #5 because we are controlling a DAC not a PWM change the term MAXPWM to MAXDAC (everywheere in the program) and change the definition to 2047


    Let us know how much of this you understand.

    Regards

    TK
    http://dynomotion.com


  11. #35
    Registered
    Join Date
    Jun 2004
    Location
    Scotland
    Posts
    265
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Modified code is below.
    Additional comments are in bold
    Additional code is in green
    As you are only using a single axis, I have also removed extra code.
    I've not tried compiling this code in KMotion, but it should give you an idea of what you need to do, and hopefully my comments will help clarify things.

    Code:
    DefineCoordSystem(0,1,2,3);
    
        // If you're using fixed outputs (I.e. Kanalog output optos/FET relay drivers), you don't need to set bit direction, so the following two lines can be removed, but you will still need to modify the defines at the top of the file
        SetBitDirection(DIR_BIT0_POS,1);    // You will need to rename DIR_BIT0 to DIR_BIT0_POS at the top of the file
        SetBitDirection(DIR_BIT0_NEG,1);    // You will need to add a define for DIR_BIT0_NEG  at the top of the file
    
    
        for (;;)  //loop forever
        {
            WaitNextTimeSlice();
            OutputSignMag(0,DIR_BIT0_POS,DIR_BIT0_NEG);              // This calls, and passes the required values to the function
       }
    }
    
    
    // write the servo output value to the relative DAC, and activate/deactivate direction bits depending on negative/positive output
    
    void OutputSignMag(int ch, int dir_bit_pos, int dir_bit_neg) //(function and args)
    {
        if (chan[ch].Enable)   // if channel is enabled, we need to check the channel output
        {
            if (chan[ch].Output >= 0)                                             //(if output channel above or equally zero value, then run next actions)
            {
                DAC(ch, (int)chan[ch].Output);  // Set DAC output, using channel output
                ClearBit(dir_bit_neg);   // Clear negative direction bit/output
                SetBit(dir_bit_pos);   // Set positive direction bit/output                                             //(set value '1' to 'dirbit' )
    
            }
            else // else our channel output is negative
            {
                DAC(ch, (int)chan[ch].Output*-1);  // As we need an always positive DAC, we multiply by -1
                ClearBit(dir_bit_pos);   // Clear positive direction bit/output
                SetBit(dir_bit_neg);    // Set negative direction bit/output
            }
        }
        else // else the channel is disabled so set DAC to zero, and disable both outputs 
        {
            DAC(ch, 0);          
           ClearBit(dir_bit_pos);
           ClearBit(dir_bit_neg);
            
        }
    }




  12. #36
    Registered
    Join Date
    Nov 2016
    Posts
    28
    Downloads
    0
    Uploads
    0

    Default Re: Problem jig grinding machine.

    Thanks a lot to everyone! Your advices helps us!
    Hydraulic cylider works, but not as we expect(( I will try to explain:
    there is a hydraulic proportional valve, which is controlled by amplifier; amplifier controlled by 0...10 V, but voltage from Kanalog`s DAC won`t exceed appreoximately 2.5 V, what do not allow to work on full speed. To increasing speed we increased feed in G-code, expecting voltage increase, but nothing happend.



    Code:
    #include "KMotionDef.h"
    
    
    //#define MAXPWM 2047
    #define DIR_BIT0_POS 144
    #define DIR_BIT0_NEG 145
    
    
    
    
    main()
    {
        int BitA,Change1=0,Change2=0, DiffX2;
        int PosNoWrap, NewPos, Pos=0, wraps;
        double Factor=0;
        
        SetBit(152);
        SetBit(157);
        SetBit(158);
        
        ch0->InputMode=ENCODER_MODE;
        ch0->OutputMode=DAC_SERVO_MODE;
        ch0->Vel=100000;
        ch0->Accel=2e+006;
        ch0->Jerk=2e+006;
        ch0->P=1;
        ch0->I=0;
        ch0->D=0;
        ch0->FFAccel=0;
        ch0->FFVel=0;
        ch0->MaxI=200;
        ch0->MaxErr=40000;
        ch0->MaxOutput=2000;
        ch0->DeadBandGain=1;
        ch0->DeadBandRange=0;
        ch0->InputChan0=0;
        ch0->InputChan1=0;
        ch0->OutputChan0=0;
        ch0->OutputChan1=0;
        ch0->MasterAxis=-1;
        ch0->LimitSwitchOptions=0x100;
        ch0->LimitSwitchNegBit=0;
        ch0->LimitSwitchPosBit=0;
        ch0->SoftLimitPos=1e+009;
        ch0->SoftLimitNeg=-1e+009;
        ch0->InputGain0=1;
        ch0->InputGain1=1;
        ch0->InputOffset0=0;
        ch0->InputOffset1=0;
        ch0->OutputGain=1;
        ch0->OutputOffset=0;
        ch0->SlaveGain=1;
        ch0->BacklashMode=BACKLASH_OFF;
        ch0->BacklashAmount=0;
        ch0->BacklashRate=0;
        ch0->invDistPerCycle=0.00025;
        ch0->Lead=0;
        ch0->MaxFollowingError=10000000;
        ch0->StepperAmplitude=100;
    
    
        ch0->iir[0].B0=0.027497;
        ch0->iir[0].B1=0.027497;
        ch0->iir[0].B2=0.000000;
        ch0->iir[0].A1=0.945006;
        ch0->iir[0].A2=0.000000;
    
    
        ch0->iir[1].B0=1.000000;
        ch0->iir[1].B1=0.000000;
        ch0->iir[1].B2=0.000000;
        ch0->iir[1].A1=0.000000;
        ch0->iir[1].A2=0.000000;
    
    
        ch0->iir[2].B0=1.000000;
        ch0->iir[2].B1=0.000000;
        ch0->iir[2].B2=0.000000;
        ch0->iir[2].A1=0.000000;
        ch0->iir[2].A2=0.000000;
    
    
    
    
    
    
    
    
        
        ch1->InputMode=ENCODER_MODE;
        ch1->OutputMode=DAC_SERVO_MODE;
        ch1->Vel=100000;
        ch1->Accel=2e+006;
        ch1->Jerk=2e+006;
        ch1->P=1;
        ch1->I=0;
        ch1->D=0;
        ch1->FFAccel=0;
        ch1->FFVel=0;
        ch1->MaxI=2000;
        ch1->MaxErr=40000;
        ch1->MaxOutput=2000;
        ch1->DeadBandGain=1;
        ch1->DeadBandRange=0;
        ch1->InputChan0=1;
        ch1->InputChan1=1;
        ch1->OutputChan0=1;
        ch1->OutputChan1=1;
        ch1->MasterAxis=-1;
        ch1->LimitSwitchOptions=0x100;
        ch1->LimitSwitchNegBit=0;
        ch1->LimitSwitchPosBit=0;
        ch1->SoftLimitPos=1e+009;
        ch1->SoftLimitNeg=-1e+009;
        ch1->InputGain0=-1;
        ch1->InputGain1=-1;
        ch1->InputOffset0=0;
        ch1->InputOffset1=0;
        ch1->OutputGain=1;
        ch1->OutputOffset=0;
        ch1->SlaveGain=1;
        ch1->BacklashMode=BACKLASH_OFF;
        ch1->BacklashAmount=0;
        ch1->BacklashRate=0;
        ch1->invDistPerCycle=0.00025;
        ch1->Lead=0;
        ch1->MaxFollowingError=10000000;
        ch1->StepperAmplitude=100;
    
    
    
    
        ch1->iir[0].B0=0.002819;
        ch1->iir[0].B1=0.002819;
        ch1->iir[0].B2=0.000000;
        ch1->iir[0].A1=0.994361;
        ch1->iir[0].A2=0.000000;
    
    
        ch1->iir[1].B0=1.000000;
        ch1->iir[1].B1=0.000000;
        ch1->iir[1].B2=0.000000;
        ch1->iir[1].A1=0.000000;
        ch1->iir[1].A2=0.000000;
    
    
        ch1->iir[2].B0=1.000000;
        ch1->iir[2].B1=0.000000;
        ch1->iir[2].B2=0.000000;
        ch1->iir[2].A1=0.000000;
        ch1->iir[2].A2=0.000000;
    
    
    
    
    
    
    
    
    
    
        
        ch2->InputMode=ENCODER_MODE;
        ch2->OutputMode=DAC_SERVO_MODE;
        ch2->Vel=100000;
        ch2->Accel=1e+006;
        ch2->Jerk=1e+006;
        ch2->P=1;
        ch2->I=0;
        ch2->D=0;
        ch2->FFAccel=0;
        ch2->FFVel=0;
        ch2->MaxI=2000;
        ch2->MaxErr=40000;
        ch2->MaxOutput=2000;
        ch2->DeadBandGain=1;
        ch2->DeadBandRange=0;
        ch2->InputChan0=2;
        ch2->InputChan1=2;
        ch2->OutputChan0=2;
        ch2->OutputChan1=2;
        ch2->MasterAxis=-1;
        ch2->LimitSwitchOptions=0x100;
        ch2->LimitSwitchNegBit=0;
        ch2->LimitSwitchPosBit=0;
        ch2->SoftLimitPos=1e+009;
        ch2->SoftLimitNeg=-1e+009;
        ch2->InputGain0=-1;
        ch2->InputGain1=-1;
        ch2->InputOffset0=0;
        ch2->InputOffset1=0;
        ch2->OutputGain=-1;
        ch2->OutputOffset=0;
        ch2->SlaveGain=1;
        ch2->BacklashMode=BACKLASH_OFF;
        ch2->BacklashAmount=0;
        ch2->BacklashRate=0;
        ch2->invDistPerCycle=0.00025;
        ch2->Lead=0;
        ch2->MaxFollowingError=10000000;
        ch2->StepperAmplitude=100;
        
        
    
    
        ch2->iir[0].B0=0.002819;
        ch2->iir[0].B1=0.002819;
        ch2->iir[0].B2=0.000000;
        ch2->iir[0].A1=0.994361;
        ch2->iir[0].A2=0.000000;
    
    
        ch2->iir[1].B0=1.000000;
        ch2->iir[1].B1=0.000000;
        ch2->iir[1].B2=0.000000;
        ch2->iir[1].A1=0.000000;
        ch2->iir[1].A2=0.000000;
    
    
        ch2->iir[2].B0=1.000000;
        ch2->iir[2].B1=0.000000;
        ch2->iir[2].B2=0.000000;
        ch2->iir[2].A1=0.000000;
        ch2->iir[2].A2=0.000000;
    
    
    
    
    
    
    
    
        ch3->InputMode=ENCODER_MODE;
        ch3->OutputMode=NO_OUTPUT_MODE;
        ch3->Vel=1000;
        ch3->Accel=100000;
        ch3->Jerk=2e+06;
        ch3->P=0.05;
        ch3->I=0.000001;
        ch3->D=5;
        ch3->FFAccel=0;
        ch3->FFVel=0;
        ch3->MaxI=2000;
        ch3->MaxErr=40000;
        ch3->MaxOutput=1000;
        ch3->DeadBandGain=1;
        ch3->DeadBandRange=0;
        ch3->InputChan0=3;
        ch3->InputChan1=0;
        ch3->OutputChan0=3;
        ch3->OutputChan1=0;
        ch3->MasterAxis=-1;
        ch3->LimitSwitchOptions=0x100;
        ch3->LimitSwitchNegBit=0;
        ch3->LimitSwitchPosBit=0;
        ch3->SoftLimitPos=1e+09;
        ch3->SoftLimitNeg=-1e+09;
        ch3->InputGain0=1;
        ch3->InputGain1=1;
        ch3->InputOffset0=0;
        ch3->InputOffset1=0;
        ch3->OutputGain=1;
        ch3->OutputOffset=0;
        ch3->SlaveGain=1;
        ch3->BacklashMode=BACKLASH_OFF;
        ch3->BacklashAmount=0;
        ch3->BacklashRate=0;
        ch3->invDistPerCycle=1;
        ch3->Lead=0;
        ch3->MaxFollowingError=10000000;
        ch3->StepperAmplitude=100;
    
    
        ch3->iir[0].B0=1;
        ch3->iir[0].B1=0;
        ch3->iir[0].B2=0;
        ch3->iir[0].A1=0;
        ch3->iir[0].A2=0;
    
    
        ch3->iir[1].B0=1;
        ch3->iir[1].B1=0;
        ch3->iir[1].B2=0;
        ch3->iir[1].A1=0;
        ch3->iir[1].A2=0;
    
    
        ch3->iir[2].B0=1;
        ch3->iir[2].B1=0;
        ch3->iir[2].B2=0;
        ch3->iir[2].A1=0;
        ch3->iir[2].A2=0;
    
    
    
    
    
    
    
    
        EnableAxis(0);
        EnableAxis(1);
        EnableAxis(2);
        EnableAxis(3);
    
    
        DefineCoordSystem(0,1,2,3);
    
    
    
    
        // If you're using fixed outputs (I.e. Kanalog output optos/FET relay drivers), you don't need to set bit direction, so the following two lines can be removed, but you will still need to modify the defines at the top of the file
        SetBitDirection(DIR_BIT0_POS,1);    // You will need to rename DIR_BIT0 to DIR_BIT0_POS at the top of the file
        SetBitDirection(DIR_BIT0_NEG,1);    // You will need to add a define for DIR_BIT0_NEG  at the top of the file
    
    
    
    
        for (;;)  //loop forever
        {
            WaitNextTimeSlice();
            OutputSignMag(0,DIR_BIT0_POS,DIR_BIT0_NEG);              // This calls, and passes the required values to the function
       }
    }
    
    
    
    
    // write the servo output value to the relative DAC, and activate/deactivate direction bits depending on negative/positive output
    
    
    void OutputSignMag() //(function and args)
    
    
    {
        if (chan[3].Enable)
        {
            if (chan[3].Output >= 0)
            
            {
                DAC(3, (int)chan[3].Output*-3);  // Set DAC output, using channel output
                ClearBit(DIR_BIT0_NEG);   // Clear negative direction bit/output
                SetBit(DIR_BIT0_POS);   // Set positive direction bit/output           //(set value '1' to 'dirbit' )
            }
            else // else our channel output is negative
            
            {   
                DAC(3, (int)chan[3].Output*3);  // As we need an always positive DAC, we multiply by -1
                ClearBit(DIR_BIT0_POS);   // Clear positive direction bit/output
                SetBit(DIR_BIT0_NEG);    // Set negative direction bit/output
            }
    }    
            else // else the channel is disabled so set DAC to zero, and disable both outputs 
            {
                DAC(3, 0);          
                ClearBit(DIR_BIT0_POS);
                ClearBit(DIR_BIT0_NEG);
            }   
        }
    What can be changed to increase voltage?



Page 3 of 5 FirstFirst 12345 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Problem jig grinding machine.
Problem jig grinding machine.