DAC

Spindles & Lasers.
Forum rules
Be Kind to other's.
No Cussing or Swearing.
Don't post anything Illegal or Obscene.
Image attachment size limit is 500 KiB.
User avatar
Picengraver
Full Access Moderator
Posts: 375
Joined: Tue Dec 23, 2014 5:40 pm
Contact:

Re: DAC

Postby Picengraver » Tue Apr 07, 2015 6:45 pm

Ahmet,
I wish I had the time to learn how to program and use the Pic chip. As Jeff wrote, please keep us advised as to how it is working for you.

Thanks for sharing.
John

User avatar
ta1dr
Posts: 16
Joined: Mon Mar 30, 2015 11:30 am

Re: DAC

Postby ta1dr » Wed Apr 08, 2015 3:35 am

thanks for good wishes
it is very simple...PIC has a internal PWM modul that modul produce 8 bit PWM I set 5KHz ...
pic like a work stepper motor background...

Code: Select all


int  current_duty;
bit  change_duty;
char dutyx;

void InitMain()
{
  osccon= 0x75;
  ANSEL  = 0;                         // Configure AN pins as digital
  trisio=0xfb;
  gpio=0;
  option_reg=0x80;
  wpu=0xff;
  ioc=0;
  cmcon0=7;
  PWM1_Init(5000);
 
}



void main()
{
  InitMain();
  current_duty  = 0;
  PWM1_Start();
  PWM1_Set_Duty(current_duty);  // 0 to 255 duty cycle
  dutyx=0;
  while (1) // background code
  {
    while (!gpio.f5);          // check step pin  if not low wait for high.....
    if (gpio.f4==0)             // check dir pin    if dir pin low increase duty cycle....
    {
        if (dutyx < 255) dutyx++;

    }
    else               // if dir pin high dec..
    {
       if (dutyx > 0) dutyx--;

    }
    PWM1_Set_Duty(dutyx);      //update PWM modul
    while (gpio.f5);         //wait step pin low.

  }
}



I set laser max and min value 0 to 255 ....and I set my cnc Z axis step/mm 10000 ( 10000 step for 1 mm)

and PEP creat gcode ( 3D version) for example ;
G1 X10 Y10
M106 S255.0 ; DARK PIXEL
.
.
.
M106 S127.0 ;gray gradient
.
.
.
.
.M106 S0.0. ;WHITE

my vb program read all gcode but only change M106 S... rows

exp:
M106 S 255.0 -------> G1 Z0.255

if pic_dac( I call like this) pwm duty cycle %0 ( 0 ) and CNC controller produce 2550 step pulse for G1 Z0.255 speedly why 2250 pulse because 1 mm 10000 step----> 10000x0.255=2550 (like a steppermotor also assume pulser method)

This circuit can also use the Mach3 or other...I want use PrinterBoard because I have 3 boards and 3D printer mechanics...:-)

I will upload hex file my server as soon as posibble ...

I didnt test full my laser driver TLL not analog I check PWM output with digital oscilloscope...

I hope you can understand me my english not good...:-(
Ahmet UCAN
TA1DR
TURKEY/Istanbul

User avatar
Picengraver
Full Access Moderator
Posts: 375
Joined: Tue Dec 23, 2014 5:40 pm
Contact:

Re: DAC

Postby Picengraver » Wed Apr 08, 2015 12:33 pm

Ahmet,
Your English is far more better than our Turkish. We really appreciate your postings here. We can all learn much from each other.

Thank you for sharing,
John

User avatar
ta1dr
Posts: 16
Joined: Mon Mar 30, 2015 11:30 am

Re: DAC

Postby ta1dr » Wed Apr 08, 2015 1:36 pm

Ahmet UCAN
TA1DR
TURKEY/Istanbul


Return to “Hardware Discussions”

Who is online

Users browsing this forum: No registered users and 4 guests

cron