Jump to content
Sign in to follow this  
FrostyTheDadMan

Laser Projector

Recommended Posts

I must be honest here I am no programmer,,, so please excuse me if I make this a learning experiance.

 

I plan to use the C2K to conrtol 3 Lasers and X & Y galvo mirrors.

 

What I need is to monitor 3 ACD inputs I want to use adcinA0 adcina1 and adcinA3 because they are next to each other.

 

But I don't know the code to monitor the ADC inputs.

is their a Doc with a list of basic codes?¿

 

All 3 Lasers requier more Amperage then the C2K can handle so I know I have to design the LD Driver Board.

I have that part under control.

 

I was planning to use TPL8002-25 to control the output power to the Lasers.

I figure if I have 64 levels of red and 64 levels of blue and 64 levels of green that will give me 262,144 different colors

 

Trey informed me that the C2K's ADC inputs are 0 to 3.3 Volt max,,

so as per Trey I am intergrading 3 voltage dividers.

Share this post


Link to post
Share on other sites

Did you download ControlSuite from TI? There are alot of sample code in there for the ADCs and to use them in different sequences. Start simple first.

Looking forward to this.

Share this post


Link to post
Share on other sites

ControlSuite Yes I have a copy along with CCSv5

It just doesn't seem to see the C2K so it does not give me any options.

 

now I can access the files in CCS thats how I got as far as I have to this point. Confused. LOL

 

Is the codes close to the Arduino codes?

 

Thanks for the help.

Share this post


Link to post
Share on other sites

Also very much looking forward to seeing this thing light up!

 

When you say it doesn't see C2k and doesn't give you any options are you referring to the GUI interface (Resource Explorer)? I have been getting varying reports about this working for some people, but not working for others. What OS are you using and are you on a 32 bit or 64 bit machine? You can always import examples by going to file import in the main CCS window.

 

I would start with the ADC_SOC example. It will show you how to start a conversion (SOC). There was a bug that was found in that example that prevented it from work, but it is fixed in the next revision on controlSUITE. I should be able to get the release done late this week or early next week. In the mean time, you can just replace the code in the .c file with this:

 

//#############################################################################
//
// File: f2802x_examples_ccsv4/adc_soc/Example_F2802xAdcSoc.c
//
// Title: F2802x ADC Start-Of-Conversion (SOC) Example Program.
//
// Group: C2000
// Target Device: TMS320F2802x
//
//! \addtogroup example_list
//!
[b]	ADC Start-Of-Conversion (SOC)[/b]


//!
//! Interrupts are enabled and the ePWM1 is setup to generate a periodic
//! ADC SOC - ADCINT1. Two channels are converted, ADCINA4 and ADCINA2.
//!
//! Watch Variables:
//!
//! - Voltage1[10] - Last 10 ADCRESULT0 values
//! - Voltage2[10] - Last 10 ADCRESULT1 values
//! - ConversionCount - Current result number 0-9
//! - LoopCount - Idle loop counter
//
// (C) Copyright 2012, Texas Instruments, Inc.
//#############################################################################
// $TI Release: PACKAGE NAME $
// $Release Date: PACKAGE RELEASE DATE $
//#############################################################################

#include "DSP28x_Project.h" // Device Headerfile and Examples Include File

#include "f2802x_common/include/adc.h"
#include "f2802x_common/include/clk.h"
#include "f2802x_common/include/flash.h"
#include "f2802x_common/include/gpio.h"
#include "f2802x_common/include/pie.h"
#include "f2802x_common/include/pll.h"
#include "f2802x_common/include/pwm.h"
#include "f2802x_common/include/wdog.h"

// Prototype statements for functions found within this file.
interrupt void adc_isr(void);
void Adc_Config(void);

// Global variables used in this example:
uint16_t LoopCount;
uint16_t ConversionCount;
uint16_t Voltage1[10];
uint16_t Voltage2[10];

ADC_Handle myAdc;
CLK_Handle myClk;
FLASH_Handle myFlash;
GPIO_Handle myGpio;
PIE_Handle myPie;
PWM_Handle myPwm;

void main(void)
{

CPU_Handle myCpu;
PLL_Handle myPll;
WDOG_Handle myWDog;

// Initialize all the handles needed for this application
myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
myPwm = PWM_init((void *)PWM_ePWM1_BASE_ADDR, sizeof(PWM_Obj));
myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));

// Perform basic system initialization
WDOG_disable(myWDog);
CLK_enableAdcClock(myClk);
(*Device_cal)();

//Select the internal oscillator 1 as the clock source
CLK_setOscSrc(myClk, CLK_OscSrc_Internal);

// Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2
PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2);

// Disable the PIE and all interrupts
PIE_disable(myPie);
PIE_disableAllInts(myPie);
CPU_disableGlobalInts(myCpu);
CPU_clearIntFlags(myCpu);

// If running from flash copy RAM only functions to RAM
#ifdef _FLASH
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
#endif

// Setup a debug vector table and enable the PIE
PIE_setDebugIntVectorTable(myPie);
PIE_enable(myPie);

// Register interrupt handlers in the PIE vector table
PIE_registerPieIntHandler(myPie, PIE_GroupNumber_10, PIE_SubGroupNumber_1, (intVec_t)&adc_isr);

// Initialize the ADC
ADC_enableBandGap(myAdc);
ADC_enableRefBuffers(myAdc);
ADC_powerUp(myAdc);
ADC_enable(myAdc);
ADC_setVoltRefSrc(myAdc, ADC_VoltageRefSrc_Int);

// Enable ADCINT1 in PIE
PIE_enableAdcInt(myPie, ADC_IntNumber_1);
// Enable CPU Interrupt 1
CPU_enableInt(myCpu, CPU_IntNumber_10);
// Enable Global interrupt INTM
CPU_enableGlobalInts(myCpu);
// Enable Global realtime interrupt DBGM
CPU_enableDebugInt(myCpu);

LoopCount = 0;
ConversionCount = 0;

// Configure ADC
//Note: Channel ADCINA4 will be double sampled to workaround the ADC 1st sample issue for rev0 silicon errata
ADC_setIntPulseGenMode(myAdc, ADC_IntPulseGenMode_Prior); //ADCINT1 trips after AdcResults latch
ADC_enableInt(myAdc, ADC_IntNumber_1); //Enabled ADCINT1
ADC_setIntMode(myAdc, ADC_IntNumber_1, ADC_IntMode_ClearFlag); //Disable ADCINT1 Continuous mode
ADC_setIntSrc(myAdc, ADC_IntNumber_1, ADC_IntSrc_EOC2); //setup EOC2 to trigger ADCINT1 to fire
ADC_setSocChanNumber (myAdc, ADC_SocNumber_0, ADC_SocChanNumber_A4); //set SOC0 channel select to ADCINA4
ADC_setSocChanNumber (myAdc, ADC_SocNumber_1, ADC_SocChanNumber_A4); //set SOC1 channel select to ADCINA4
ADC_setSocChanNumber (myAdc, ADC_SocNumber_2, ADC_SocChanNumber_A2); //set SOC2 channel select to ADCINA2
ADC_setSocTrigSrc(myAdc, ADC_SocNumber_0, ADC_SocTrigSrc_EPWM1_ADCSOCA); //set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
ADC_setSocTrigSrc(myAdc, ADC_SocNumber_1, ADC_SocTrigSrc_EPWM1_ADCSOCA); //set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1
ADC_setSocTrigSrc(myAdc, ADC_SocNumber_2, ADC_SocTrigSrc_EPWM1_ADCSOCA); //set SOC2 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1, then SOC2
ADC_setSocSampleWindow(myAdc, ADC_SocNumber_0, ADC_SocSampleWindow_7_cycles); //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
ADC_setSocSampleWindow(myAdc, ADC_SocNumber_1, ADC_SocSampleWindow_7_cycles); //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
ADC_setSocSampleWindow(myAdc, ADC_SocNumber_2, ADC_SocSampleWindow_7_cycles); //set SOC2 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)

// Enable PWM clock
CLK_enablePwmClock(myClk, PWM_Number_1);

// Setup PWM
PWM_enableSocAPulse(myPwm); // Enable SOC on A group
PWM_setSocAPulseSrc(myPwm, PWM_SocPulseSrc_CounterEqualCmpAIncr); // Select SOC from from CPMA on upcount
PWM_setSocAPeriod(myPwm, PWM_SocPeriod_FirstEvent); // Generate pulse on 1st event
PWM_setCmpA(myPwm, 0x0080); // Set compare A value
PWM_setPeriod(myPwm, 0xFFFF); // Set period for ePWM1
PWM_setCounterMode(myPwm, PWM_CounterMode_Up); // count up and start
CLK_enableTbClockSync(myClk);

// Wait for ADC interrupt
for(;
{
LoopCount++;
}

}


interrupt void adc_isr(void)
{

//discard ADCRESULT0 as part of the workaround to the 1st sample errata for rev0
Voltage1[ConversionCount] = ADC_readResult(myAdc, ADC_ResultNumber_1);
Voltage2[ConversionCount] = ADC_readResult(myAdc, ADC_ResultNumber_2);

// If 10 conversions have been logged, start over
if(ConversionCount == 9)
{
ConversionCount = 0;
}
else ConversionCount++;

// Clear ADCINT1 flag reinitialize for next SOC
ADC_clearIntFlag(myAdc, ADC_IntNumber_1);
// Acknowledge interrupt to PIE
PIE_clearInt(myPie, PIE_GroupNumber_10);

return;
}

Share this post


Link to post
Share on other sites

Also....I'm not super familiar with laser diodes, but they effectively need a constant current source to drive them, yes? The ideal way to drive this would be to use the C2000 to do a digital control loop around a boost/buck converter in a constant current control scheme. That is what the chip is designed to do.

Share this post


Link to post
Share on other sites

Hello Trey

 

WoW You are a Man on the Move!

 

The Control Suite issue,,, the only thing in resource explorer is for the MSP chip,,, I must be honest here,,, I think in my case it was the operator.

Because the first time I opened it up I did not have the C2K connected,, and I was just looking at it and the only option was the MSP chip.

But now thats all it sees is the MSP chip,,, I just don't have a MSP.

 

I can access all the files in CCS v5.

 

My system is the

AMD 64 X2 939 pin

 

but I am running XPSP3 32 bit

 

Mother board is Asus A8n-SLI

 

Ram Memory 2GB

 

-------------------------------------------------------

 

most of the 5.6mm or 9mm Laser diodes are are designed for DVD burners the faster the wright speed the more powerful the diode but they are designed to reach their max power in a pulse wave setting,,,

 

see the emitter will store a small amount of energy for about 10 to 30 ns then when the Diode turns back on (peak point of stored energy) it has that energy plus everything you are giving it.

 

Timing is everything,, to fast of a frequency over heats and shortens the diode life,,, to slow and over heating occurs again.

 

 

 

a digital loop around a buck boost driver? thats close to what I had in mind.

 

I want a current reg to maintain a user set max amperage for each laser output,

I have some PTL8002-25 that will control the adj pin to a 5 amp Voltage regulator LM1084adj. their will be 2 per color.

 

total Max power out 30 Amp.

The Current reg is a safety so even if their is a malfunction with my programing I won't overdrive my Lasers

 

I was looking at maybe one day using the PTH12040W for 50 Amp per Laser.

 

That will be for use in a second project to bond Oxygen molecules to emission molecules to mimic the Try-Oxygen molecules that makes up our Ozone.

 

That one will control 5, 40 Watt Lasers and a ion generator

 

At

N.G.A.

we solve problems on a molecular level.

Share this post


Link to post
Share on other sites

Up Date

 

I have found this to be Verry helpful in my programming Quest.

I don't know if you all have it in your data here but if not it will be useful for anyone else in my shoes.

http://www.cplusplus.com/files/tutorial.pdf

 

Also is their a CCS standard reserved keyword list?¿

or is it the same as the standard C++ reserved keyword list?¿

 

Also I should be starting the write this weekend.

I am to the 124th page. B)

20 more pages to go. :blink:

Share this post


Link to post
Share on other sites

Up Date

 

I have found this to be Verry helpful in my programming Quest.

I don't know if you all have it in your data here but if not it will be useful for anyone else in my shoes.

http://www.cplusplus...es/tutorial.pdf

 

Also is their a CCS standard reserved keyword list?¿

or is it the same as the standard C++ reserved keyword list?¿

 

Also I should be starting the write this weekend.

I am to the 124th page. B)

20 more pages to go. :blink:

There is a compiler manual:

TMS320C28x Optimizing C/C++ Compiler v6.1 User's Guide (Rev. E), but I don't think it will have a reserved keyword list. That would be in a book like K&R.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...