Jump to content

Search the Community

Showing results for tags 'adc'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News
    • Announcements
    • Suggestions
    • New users say Hi!
  • Spotlight!
    • Sponsor Spotlight
    • Sponsor Giveaways
  • Energia
    • Energia - MSP
    • Energia - TivaC/CC3XXX
    • Energia - C2000
    • Energia Libraries
  • MSP Technical Forums
    • General
    • Compilers and IDEs
    • Development Kits
    • Programmers and Debuggers
    • Code vault
    • Projects
    • Booster Packs
    • Energia
  • Tiva-C, Hercules, CCXXXX ARM Technical Forums
    • General
    • SensorTag
    • Tiva-C, Hercules, CC3XXX Launchpad Booster Packs
    • Code Vault
    • Projects
    • Compilers and IDEs
    • Development Kits and Custom Boards
  • Beagle ARM Cortex A8 Technical Forums
    • General
    • Code Snippets and Scripts
    • Cases, Capes and Plugin Boards
    • Projects
  • General Electronics Forum
    • General Electronics
    • Other Microcontrollers
  • Connect
    • Embedded Systems/Test Equipment Deals
    • Buy, Trade and Sell
    • The 43oh Store
    • Community Projects
    • Fireside Chat
  • C2000 Technical Forums
    • General
    • Development Kits
    • Code Vault
    • Projects
    • BoosterPacks

Calendars

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Location


Interests


Sparkfun


Github

Found 58 results

  1. Hello! I am a fresh beginner in the domain of embedded systems and this MSP430F5529 is my very first development board. I am now trying to make an ADC conversion and send it through the UART to try a signal treatment algorithm with real-world values. I used an example code in Energia that i modified a little bit: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // Comment: I see many people preferring the 115200 BR for this board. // Is there a particular reason for this choice? } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin A3: int sensorValue = analogRead(A3); // Comment: I think the F5529 actually writes its ADC results on 12 bits. // Should i try to use a long, 16-bit integer? // print out the value you read: Serial.println(sensorValue); } The Energia console gives me expected readings, using an AA battery and an old function generator. For my first UART tests, I tried using Processing, a multipurpose javascript program that i use for drawing. import processing.serial.*; float[] y; // Array to contain the values read through the UART Serial myPort; // Create object from Serial class int val; // Data received from the serial port void setup() { // I define the size of the drawing board to be 600 X 400 pixels. size(600, 400); // I initialize my 'y' array y = new float[width]; for(int i = 0; i<width; i++){ y[i] = 0.0; } // This is to open the correct port. The number in square brackets might vary. String portName = Serial.list()[3]; // Here i define the baudrate, so it's the same as the one in Energia. myPort = new Serial(this, portName, 9600); } void draw() { // This draws a white background background(255); // This tells that i want to draw with the color black. stroke(0); for (int i = 0; i<width; i++){ // For every entry in my 'y' array, I draw a black dot. point(i,y[i]); } // I read a new value from the UART and feed it to my "update" routine. val = myPort.read(); update(val); } void update(int value){ // I shift every value to the left in my array. // This is to get a "strip-chart" feeling to my graph. for (int i = 0; i<width-1; i++){ y[i] = y[i+1]; } // For the last value, i use the value read from the serial port. // I convert it so that i have a correspondance: // min(UART) = bottom of screen, max(UART) = 2^12 - 1 = 4095 = top of screen. y[width-1] = (float)height - value * (float)height / 4095.0; // I also print the UART read value to this software's console for debugging. print(value,"\n"); } What prints on the console is a repetitive pattern of something like 13-10-48-13-10-48-etc. when my pin is grounded. When it's not grounded i get pretty much the same exact numbers with a little bit more variations. At first I thought it was a long int problem with the UART, beacause of the 12-bit ADC conversion, but i'm not so sure anymore. Help me! Thank you very much! readVoltage_ver1.ino
  2. I have a sinusoidal wave of 50Hz, this is the code that I used to read adc. for(i = 0;i<20;i++)//chosen 20 values { ADCValue = analogRead(analogInPin); delay(20); sample[i] = ADCValue;} the results were correct with sine wave display at correct value, however, the signal is at 50Hz, hence this delay(20) is at the time period of each cycle of this waveform, Why am I getting the correct adc results rather than a constant value of each time it reads at the same point? Please can someone answer, thank you so much!
  3. Tiva- Connected Launchpad DSO Here is a beginners version of an Oscilloscope and Network Analyser, using the Connected Launchpad as digitiser and a modified version of the CircuitGear Mini Graphic User Interface of Syscomp Electronic Design Ltd. www.syscompdesign.com. Spec’s: 1 channel differential @ 4 Msps or 2 channel diff. @ 2 Msps max. The 12 bit ADCs sample always at 2Msps, on lower required speeds the signals are oversampled as much as practical for an output of 14 bit unsigned integers. This makes aliasing-filtering easier. The timing is entirely done by the ADC-clock. The software is made with "Energia version 0101E0012" ; thanks for this "easy to start with" tool. and with the wiring_analog.c from https://github.com/vladn2/Energia/ . (this one does not use interrupts). There are many comments in the code to explain the workings. There are timing problems while using Energia version 0101E0013 even with the new pde.jar for optimisation. With a AD9850 direct digital synthesis (DDS) as sine-wave generator, output frequency resolution of 0.0291 Hz with a 125 MHz reference clock. This is based on: http://forum.stellarisiti.com/topic/558-ad9850-with-energia/ CircuitGear GUI modification. The offset (new in vertical.tcl) and Gnd-shift (in cursors.tcl) is now handled in the GUI (display.tcl), not in hardware. In display.tcl is channel C embedded as product of chan.A and B for power measurement. Change of the vertical settings or the cursors ends in a re-plot of the screen with the old data for further investigation. For the trigger-modes and options are buttons used, very handy especially for Single-shot to quickly stop acquisition when a freak signal occurs (the menus are still there). The Single-shot mode now also functions in the scan-mode, so that acquisition stops at the end of the screen. While developing, it became necessary to add a ‘disconnect, item to the hardware menu. The Waveform Generator GUI sends its frequency value as one big number to the LaunchPad. Amplitude and offset are not used (yet). In the Network Analyser mode the logarithmic frequency settings and the right plot limit are changed and the ‘End Frequency’ is as measurement step added. The logarithmic steps are now set by the number of steps per decade. To implement these changes, install the GUI from www.syscompdesign.com. Than rename the original tcl-files in the source-directory that must be replaced by the modified ones and copy the modified versions in the source-directory. Also copy the two images (these were necessary to better fit my screen) in the Images-directory. Future plans: Build the analog part. Implement amplitude setting on the DDS. Implement a Hi-Res-mode by using a longer circular buffer. Tiva-DSO and GUI modification.zip CircuitGear display.zip
  4. Hi, I had interface MSP430F5529 launchpad with FatFS Sd card. I was trying to store value from ADC into SD card and I found that I cannot store the value on SD Card, unless I do "sprintf" or equivalent printf of the data, only then I was able to store the value on SD card. However, sprintf is expensive command and takes more cycle then ADC output i.e some of the data is lost from ADC in doing sprintf. Is there a better alternative than sprintf or something like if I store raw value and later post process it? Any help will be highly appreciated. Thanks
  5. Trying to use SysTick to set the sampling frequency of my ADC. Im a bit confused on the interaction of the two though. If my ADC is running at 125KSPS how do I need to set SysTick to 125KHz? 250Khz?? Or how does this work? my code: #include "Energia.h" #include "inc/lm4f120h5qr.h" #include <stdint.h> #include <stdbool.h> #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "inc/hw_ints.h" #include "driverlib/interrupt.h" #include "driverlib/sysctl.h" #include "driverlib/timer.h" #include "driverlib/cpu.h" int result; int i = 0; volatile unsigned long Counts=0; void SysTick_Init(unsigned long period); void SysTick_Handler(void); void ADC0_InitSWTriggerSeq3_Ch9(void); unsigned long ADC0_InSeq3(void); byte audio_buff[511]; void setup(){ // running at 16 MHz SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); ADC0_InitSWTriggerSeq3_Ch9(); SysTick_Init(50); // initialize SysTick timer, f = 1/(1/16000000/50) ROM_IntMasterEnable(); // enable after everything initialized } void loop(){ while(1){ // interrupts every 1ms, 500 Hz flash } } void SysTick_Init(unsigned long period){ NVIC_ST_CTRL_R = 0; // disable SysTick during setup NVIC_ST_RELOAD_R = period-1;// reload value NVIC_ST_CURRENT_R = 0; // any write to current clears it NVIC_SYS_PRI3_R = (NVIC_SYS_PRI3_R&0x00FFFFFF)|0x40000000; // priority 2 NVIC_ST_CTRL_R = 0x07; // enable SysTick with core clock and interrupts // enable interrupts after all initialization is finished } void SysTick_Handler(void){ if(i==511){ i = 0; } ADC0_PSSI_R = 0x0008; // 1) initiate SS3 while((ADC0_RIS_R&0x08)==0){}; // 2) wait for conversion done result = ADC0_SSFIFO3_R&0xFFF; // 3) read result audio_buff = result; ADC0_ISC_R = 0x0008; // 4) acknowledge completion i++; } void ADC0_InitSWTriggerSeq3_Ch9(void){ volatile unsigned long delay; SYSCTL_RCGC2_R |= 0x00000010; // 1) activate clock for Port E delay = SYSCTL_RCGC2_R; // allow time for clock to stabilize GPIO_PORTE_DIR_R &= ~0x04; // 2) make PE4 input GPIO_PORTE_AFSEL_R |= 0x04; // 3) enable alternate function on PE2 GPIO_PORTE_DEN_R &= ~0x04; // 4) disable digital I/O on PE2 GPIO_PORTE_AMSEL_R |= 0x04; // 5) enable analog function on PE2 SYSCTL_RCGC0_R |= 0x00010000; // 6) activate ADC0 delay = SYSCTL_RCGC2_R; SYSCTL_RCGC0_R &= ~0x00000300; // 7) configure for 125K ADC0_SSPRI_R = 0x0123; // 8) Sequencer 3 is highest priority ADC0_ACTSS_R &= ~0x0008; // 9) disable sample sequencer 3 ADC0_EMUX_R &= ~0xF000; // 10) seq3 is software trigger ADC0_SSMUX3_R &= ~0x000F; // 11) clear SS3 field ADC0_SSMUX3_R += 9; // set channel Ain9 (PE4) ADC0_SSCTL3_R = 0x0006; // 12) no TS0 D0, yes IE0 END0 ADC0_ACTSS_R |= 0x0008; // 13) enable sample sequencer 3 }
  6. hello friends, I have a big problem with small MSP430G2553, I would like to make a capture samples at P1.2 of the microcontroller, but my code does not work, what am I doing wrong, can someone help me. My code: unsigned int adcValue = 0; int i, BPM[10]; int maior = BPM[0]; int menor = BPM[0]; int contagem =0; /*****************************************************************/ /********* LOCAL FUNCTIONS *********/ /*****************************************************************/ void ADC_ConfigAnalogInput(void){ P1DIR2IN(BIT0); ADC10CTL0 &= ~(ENC); ADC10CTL1 = (INCH_0 + ADC10DIV_0); ADC10CTL0 = (SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE); ADC10AE0 |= BIT0; ADC10CTL0 |= ENC; } void ADC_ReadAnalogInput(void){ ADC_ConfigAnalogInput(); while (ADC10CTL1 & BUSY); // WAIT IF BUSY ADC10CTL0 |= ADC10SC; __bis_SR_register(CPUOFF + GIE); // LPM0, ADC10_ISR will force exit adcValue = ADC10MEM; } /* * */ unsigned int ADC_GetValue(void) { return adcValue; for (j=0;j<timer; j++){ BPM[j]=adcValue; if(maior < BPM[i]){ maior = BPM[j]; } if(menor > BPM[j]){ menor = BPM[j]; } } if(contagem>59) contagem =0; else contagem++; } /*****************************************************************/ /********* END *********/ /*****************************************************************/
  7. I'm using a Tiva C series TM4C123G and I need to write 2 arrays of about 30000 places each, and this can't be done on the RAM memory so I was wondering if I could use the Flash memory instead. Is there a better way to solve this problem? And does anybody have a piece of code showing how to assign a array to the flash memory? On the same matter, I will need to ADC sample between 10khz and 15Khz, is there enough time to write to the flash memory? My clock is set to 80Mhz.
  8. Hi all, I have made a couple of MSP430 Tutorials and thought I would share the links here: ADC tutorial and example code I did this one awhile ago and just covers the ADC with 3 example codes, multiple channels, multiple reads etc http://coder-tronics.com/msp430-adc-tutorial/ Timer tutorial and example code Only posted recently and covers both timers on the MSP430G2253, again with 3 examples PWM, interrupts etc. http://coder-tronics.com/msp430-timer-tutorial/ Programming tutorial covering the GPIO and peripheral registers I found this all a little confusing when I started out and had a question from someone recently, so thought I would try and break it down into simple terms. http://coder-tronics.com/msp430-programming-tutorial-pt1/ http://coder-tronics.com/msp430-programming-tutorial-pt2/ Switch Debouncing tutorial with several MSP430 code examples Just some useful information on switch debouncing as well as some code useful code examples http://coder-tronics.com/switch-debouncing-tutorial-pt1/ http://coder-tronics.com/switch-debouncing-tutorial-pt2/ Hopefully they are of some use , Cheers, Ant
  9. can we interface ADC chip directly to our PC..I am targeting for LabVIEW software in PC.I want to design oscilloscope without using any controller hardware...??Also suggest me ADC chip which has wireless UART
  10. I wrote program of ADC in tiva c launchpad..I am using PB5 pin(AIN11) for analog input..But How to connect Sensor (voltage input-3.3 voltage input )to launchpad...My sensor has 2 wire Vin,Gnd.....Should i have to connect Vin to PB5 and Gnd of sensor to GND pin of Launchpad..
  11. According to the docs, it takes ~100 microseconds: http://energia.nu/AnalogRead.html. I measured this and it seems to be almost exactly 100 microseconds. Why does it take so long? This limits me to 10kHz sample speed. By the way, how fast have any of you guys sampled on the ADC12 of F5529?
  12. Hello everyone ! I started to use Energia to create simple projects using MSP430G2553 LaunchPad and somehow I've succeded until now! Today I encountered a problem as I was trying to read values from a HIH-4000-001 humidity sensor.The sensor is powered with 5V and can return a value ranging from 0.826 V to 3.976V coresponding to 0 - 100 % RH. Because 3.976 V is much more than the MSP430 can manage I used a 1:2 resistive divider to scale down the signal.Moreover the sensor needs an load resistance of minimum 80kohms so the resistors I used for my divider were R1= 36kohms and R2=68kohms.NOW comes the error : Regarding that , the RH level is normally around 50% that would corespond to a value of 1.3 V after the scale-down so in terms of ADC readings that would be around 445 and that is the value I get but, if I take multiple readings 1 sec apart of each other this is what happens : 445 442 443 0 0 0 443 440 ..................... Why 0 ? Can anyone tell me ? If I measure for some period of time the output of the sensor, the multimeter indicates a constant value of 1.3 V so I assume that the ADC is the problem! Please help me solve this issue as I need to create a functional project for my Bachelor Degree ! Thanks in advance !
  13. Hi! I need some help with ADC in MSP430g2553, I have 3 buttons which you need to do readings and obtain digital values. P1.1- Batterry P1.2-temperature P1.4. Pin button Switch In P1.3. Pin Switch button, I have 3 buttons which do the readings each using voltage dividers, but also need to know the load that still exists in the battery and take readings continuously. how can I do this, since I have to be able to do 3 things at once, but separate values??? #define BATTERY_PIN BIT1 #define TEMPERAT_PIN BIT2 #define SWITCH_BUTTON BIT4 void butonAdc(void) { ADC10CTL1 = INCH_4 + ADC10DIV_0; ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; ADC10AE0 |= SWITCH_BUTTON; } void tempAdc(void) { ADC10CTL1 = INCH_2 + ADC10DIV_0; ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; ADC10AE0 |= TEMPERAT_PIN; } void BattAdc(void) { ADC10CTL1 = INCH_1 + ADC10DIV_0; ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; ADC10AE0 |= BATTERY_PIN; } #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR (void) { __bic_SR_register_on_exit(CPUOFF); } Now how can I read separately each values?
  14. hi there, i'm trying to measure impedance by applying sinusoidal wave to a chemical gel. it cannot operate by dc voltages. i can achieve to measure resistance from a dc circuit and send the solution to an LCD screen by reading two channels as follows: my code: #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); lcd.print("impedance :"); } void loop() { int sensorValue1 = analogRead(A0); int sensorValue2=analogRead(A1); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltagech1 = sensorValue1 * (5.0 / 1023.0); float voltagech2 =sensorValue2 * (5.0 / 1023.0); float current= (voltagech1-voltagech2)/50; float impedance=voltagech2/current; delayMicroseconds(50); // display each character to the LCD lcd.setCursor(0,1); lcd.print(impedance); } I'm using msp launchpad ver 1.5 G2553 chip on it. Since i cannot read ac voltages without offsetting and since offset voltage corrupts my sample, i really need to apply sinusoidal signals (10, 100,500, 1000 Hz, ~3 Vpp) and detect the peaks and use as my sensorValue's. Any sample code will be appreciated. thank you in advance..
  15. Hi, i would like to move data from ADC12MEM0 from its memory location to a choosen mamoery location by the means of DMA. the ADC is working correctly. Here it follows DMA configuration : __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) ADC_MEM_0_ADDRESS); //SHOULD BE ADC12MEM0 // Source single address __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) IMAGE_START_ADDRESS); // Destination single address DMACTL0 =DMA0TSEL_26; //DMA Trigger Assignments:26==ADC12 end of conversion DMA0SZ =12544; // Block size DMA0CTL = DMADT_4 | DMASRCINCR_0 | DMADSTINCR_3 | DMADSTBYTE |DMASRCBYTE; // Rpt, inc DMA0CTL |= DMAEN; // Enable DMA0 i expect the DMA to transfer 12544 byte at once, and at each ADCcycle i expect DMA0SZ to decrease of one unit. But looking at DMA0SZ durign the dug it seems like it doen't even decreases at any ADC cycle despite what it is written in the datasheet SLAU367b "DMAxSZ register decrements with each word or byte transfer." any tips on what i'm missing? thx in advance irene
  16. Here's code performing ADC on Pin E5 on the Tiva C Series meant for struggling beginners like myself #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/debug.h" main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ); //Set clock at 40 Mhz , Sometimes //ADC may not work at 80Mhz SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ADCReferenceSet(ADC0_BASE, ADC_REF_INT); //Set reference to the internal reference // You can set it to 1V or 3 V GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5); //Configure GPIO as ADC ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior //to usage ,else the ADC may not be accurate // due to previous initializations ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); //Use the 3rd Sample sequencer ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH8 | ADC_CTL_IE | ADC_CTL_END); //Configure ADC to read from channel 8 ,trigger the interrupt to end data capture // ADCSequenceEnable(ADC0_BASE, 3); //Enable the ADC ADCIntClear(ADC0_BASE, 3); //Clear interrupt to proceed to data capture while (1) { ADCProcessorTrigger(ADC0_BASE, 3); //Ask processor to trigger ADC while (!ADCIntStatus(ADC0_BASE, 3, false)) { //Do nothing until interrupt is triggered } ADCIntClear(ADC0_BASE, 3); //Clear Interrupt to proceed to next data capture ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); //pui32ADC0Value is the value read SysCtlDelay(SysCtlClockGet() / 12); } //Suitable delay } It is important to refer to datasheet before selecting the GPIO for the ADC and the channel through which it is done .
  17. Hi, I've recently upgraded my Energia IDE to the latest release 0101E0011. I'm using the Stellaris Launchpad with lm4f120h5qr. My sample ADC code doesn't seem to work right. Worked well in the previous release of Energia. The code compiles properly but does not produce the right output. The only changes made were to change "ADC_BASE" to "ADC0_BASE" as required. I've added Serial output code for debugging purposes. The serial output produced is: 1 2 3 Code: #include "Energia.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" void setup() { Serial.begin(115200); Serial.println("1"); //enable the adc0 peripherial. SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); Serial.println("2"); //set the speed to 1msps. SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); Serial.println("3"); //set the auto avergage to 64. ADCHardwareOversampleConfigure(ADC0_BASE, 64); Serial.println("4"); //before setting up I must disable the sequence 3. ADCSequenceDisable(ADC0_BASE, 3); Serial.println("5"); //set the sequence to use (adc0 sequence 3). ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); Serial.println("6"); //set up the sequence step. //set up the last step and start an interrupt when the conversion it's over. ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END); Serial.println("7"); //enable the sequence again! ADCSequenceEnable(ADC0_BASE, 3); Serial.println("8"); } void loop() { }
  18. Okay, so I found out from my previous post that the output value from the ADC can be accessed through pui32ADC0Value...now, im trying to send that data via USB device mode in Tiva, however, my concerns are will my code work? And if it works, how do I access that data via MatLab. Thanks Once again, credits to the maker of the ADC code. #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/usb.h" #include "usblib/usblib.h" #include "usblib/usblibpriv.h" #include "usblib/device/usbdevice.h" #include "usblib/device/usbdevicepriv.h" main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ); //Set clock at 40 Mhz , Sometimes //ADC may not work at 80Mhz SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ADCReferenceSet(ADC0_BASE, ADC_REF_INT); //Set reference to the internal reference // You can set it to 1V or 3 V GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5); //Configure GPIO as ADC ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior //to usage ,else the ADC may not be accurate // due to previous initializations ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); //Use the 3rd Sample sequencer ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH8 | ADC_CTL_IE | ADC_CTL_END); //Configure ADC to read from channel 8 ,trigger the interrupt to end data capture // ADCSequenceEnable(ADC0_BASE, 3); //Enable the ADC ADCIntClear(ADC0_BASE, 3); //Clear interrupt to proceed to data capture uint8_t* Data = "pui32ADC0Value"; // // Configure Endpoint 1. // USBDevEndpointConfigSet(USB0_BASE, USB_EP_1, 64, //DISABLE_NAK_LIMIT, USB_EP_MODE_BULK | USB_EP_DEV_IN); // // Configure FIFO as a device IN endpoint FIFO starting at address 64 // and is 64 bytes in size. // USBFIFOConfigSet(USB0_BASE, USB_EP_1, 64, USB_FIFO_SZ_64, USB_EP_DEV_IN); while (1) { ADCProcessorTrigger(ADC0_BASE, 3); //Ask processor to trigger ADC while (!ADCIntStatus(ADC0_BASE, 3, false)) { //Do nothing until interrupt is triggered } ADCIntClear(ADC0_BASE, 3); //Clear Interrupt to proceed to next data capture ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); //pui32ADC0Value is the value read SysCtlDelay(SysCtlClockGet() / 12); // // Put the data in the FIFO. // USBEndpointDataPut(USB0_BASE, USB_EP_1, Data, 64); // // Start the transmission of data. // USBEndpointDataSend(USB0_BASE, USB_EP_1, USB_TRANS_IN); //USBEndpointDataGet(USB0_BASE, USB_EP_1, Data, 32); } //Suitable delay }
  19. rnightbane

    ADC Output

    Hi, I recently found a ADC code in the forums. I plan to input it with a signal, but I dont know where to test the output. Here's the code, credits to the maker. #include <stdbool.h> #include <stdint.h> #include "inc/hw_memmap.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "inc/hw_types.h" #include "driverlib/debug.h" main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN| SYSCTL_XTAL_16MHZ); //Set clock at 40 Mhz , Sometimes //ADC may not work at 80Mhz SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ADCReferenceSet(ADC0_BASE, ADC_REF_INT); //Set reference to the internal reference // You can set it to 1V or 3 V GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_5); //Configure GPIO as ADC ADCSequenceDisable(ADC0_BASE, 3); //It is always a good practice to disable ADC prior //to usage ,else the ADC may not be accurate // due to previous initializations ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); //Use the 3rd Sample sequencer ADCSequenceStepConfigure(ADC0_BASE, 3, 0,ADC_CTL_CH8 | ADC_CTL_IE | ADC_CTL_END); //Configure ADC to read from channel 8 ,trigger the interrupt to end data capture // ADCSequenceEnable(ADC0_BASE, 3); //Enable the ADC ADCIntClear(ADC0_BASE, 3); //Clear interrupt to proceed to data capture while (1) { ADCProcessorTrigger(ADC0_BASE, 3); //Ask processor to trigger ADC while (!ADCIntStatus(ADC0_BASE, 3, false)) { //Do nothing until interrupt is triggered } ADCIntClear(ADC0_BASE, 3); //Clear Interrupt to proceed to next data capture ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); //pui32ADC0Value is the value read SysCtlDelay(SysCtlClockGet() / 12); } //Suitable delay }
  20. Hello, I have an LCD working, and I also have an adc working to get voltage from a potentiometer. I am able to display adc values on the LCD, and they change when I change the value of the pot. But I am stuck with one thing, I know that it is a 10bit adc, which means it can only get 0x3FF different values of data. I have a DMM connected to the voltage from the pot, that same voltage is going to the adc on the msp340. Here are some of the values that I got: 5V--------->0x0000 4.5V------->0x009D 4V---------->0x0126 3.5V-------->0x01BD 3V---------->0x0249 2.5V-------->0x02DF 2V---------->0x036B 1.5V-------->0x3FD~(F) -----> Anything below 1.5v is not detected by the adc. Does anyone know of a way to get the adc to read the full range of the 5v? Thanks
  21. I have designed my very first circuit, it is a simple non-inverting amplifier. Its purpose is to take line-level audio (1.6v) and double it (3.2v) so that the TIva ADC can process the audio. It seems to work, as in when I am not playing music, AIN0 returns values around 0. Where as when I play music AIN0 reports much larger numbers. The problem however is that the numbers seem random, and don't seem to be following the music in anyway I can tell. I am wondering if I have done something silly with my circuit or do I require a low-pass filter or something to remove noise?? I have tried a 1uf cap between the audio in and the non-inverted input as a low pass filter, but results seemed the same. Perhaps something in my code is incorrect, I did however just use similar code provided with Tivaware (single_ended.c). I would like the numbers to reflect the bass in the music, so I guess frequencies less than 200hz. Any suggestion very much welcomed! Here is my circuit And here is my code main(void) { uint32_t pui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 3); while(1) { ADCProcessorTrigger(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, false)) { } ADCIntClear(ADC0_BASE, 3); ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value); System_printf("AIN0 = %4d\r", pui32ADC0Value[0]); SysCtlDelay(SysCtlClockGet() / 120); } }
  22. I'm trying to read analog values from a photoresistor(off of a voltage divider) connected to pin PC5 . I use the following code #include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/sysctl.h" #include "driverlib/adc.h" #include "driverlib/gpio.h" #ifdef DEBUG void__error__(char *pcFilename, uint32_t ui32Line) { } #endif int main(void) { uint32_t ui32ADC0Value[1]; SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); GPIOPinTypeADC(GPIO_PORTC_BASE,GPIO_PIN_5); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_PROCESSOR, 0); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE |ADC_CTL_END); ADCSequenceEnable(ADC0_BASE, 3); ADCIntClear(ADC0_BASE, 3); while(1) { ADCProcessorTrigger(ADC0_BASE, 3); while(!ADCIntStatus(ADC0_BASE, 3, false)) { } ADCIntClear(ADC0_BASE, 3); ADCSequenceDataGet(ADC0_BASE, 3, ui32ADC0Value); // Watch on ui32ADC0Value SysCtlDelay(20000); } } But unfortunately I'm getting random values of ui32ADC0Value that don't correspond to the ambient light . What am i doing wrong here ?
  23. Hey All, Hieeeee When i am debugging my code, it is giving a error called Multiple markers at this line - <a href="file:/D:/code%20composer%20studiov5/ccsv5/tools/compiler/dmed/HTML/MSP430/1527.html">#1527-D</a> (ULP 2.1) Detected SW delay loop using empty loop. Recommend using a timer module instead - #20 identifier "ADC10TL1" is undefined ON THIS LINE while(ADC10CTL1 & ADC10BUSY); Thanks in anticipation Nikki
  24. I'm trying to measure load current controlled with TI DRV8801 (http://www.pololu.com/catalog/product/2136) with a Launchpad Rev. 1.5 and MSPG2231 using this code #define CURRENT BIT1 ... // start adc //ADC10CTL0 &= ~ENC; // Disable ADC ADC10AE0 = POS | CURRENT; ADC10CTL0 = ADC10SHT_2 // sample-and-hold time (64) + MSC // "sequential conversion"? //+ REF2_5V // //+ REFON // + ADC10ON // ADC on + ADC10IE // ADC interrupt enable ; ADC10CTL1 = INCH_1 // Channel //+ ADC10SSEL_3 // SMCLK //+ CONSEQ_0 // Conversion sequence (single channel) //+ CONSEQ_1 // Conversion sequence (scan) + CONSEQ_2 // Conversion sequence (repeat channel) //+ CONSEQ_3 // Conversion sequence (repeat scan) ; ADC10CTL0 |= ENC + ADC10SC; // Enable and start conversion Pin1.1 is connected to the driver module's CS (current sense) pin, in addition to VCC (3.3V), GND, DIR, PWM. The module' load side is powered by a lab supply at about 11 V (too low of a supply voltage and the DRV8801 started to oscillate when supplying 100%, probably because of the supply leads or so). I observe the following If the pin is configured as normal input, the floating level is pretty much zero Unconnected ADC pin with buffers disabled has 0 V Unconnected ADC pin as above but configured as ADC input has about 1/2 Vcc, e.g. 1.5 V (am I outputting the reference voltage?)This will pull up the sensor signal from 40 mV to 150 mV and render it useless The ADC reading from ADC10MEM is consistent with the externally measured voltage, e.g. 155e-3 V /(3,6V/1024) = 44 Same effect with other pin and other G2231 not connected to DRV8801 Launchpad TXD/RXD jumpers are open Is this normal? How can the ADC input pull up the output? Will I have to use a buffer amp for the signal? The DRV8801 datasheet does not say much about the VPROPI output drive capability.
  25. hi everyone, i'm sampling from single channel ADC and send the data over UART. now i need to two channel simultaneously and send the data. for one channel my code is below: ----------------------------------------------- ADC10CTL1 = INCH_5 + ADC10DIV_3 ; // Channel 5, ADC10CLK/4 ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; //Vcc & Vss as reference ADC10AE0 |= BIT5; ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start, single measure! while(1) { if(!((P1IN & BUTTON)==BUTTON)) { ADC10CTL0 |= ENC + ADC10SC; value1 = ADC10MEM>>2; // used only 8 bits of 10bits adc conversion... while ((UCA0STAT & UCBUSY)); // Wait if line TX/RX module is busy with data UCA0TXBUF = value1; } } } ------------------------------------------------- can you please help me to make following changes... i need to use p1.4 and p1.5 for ADC conversion (two channel), and the ADC referance voltage should be 2.5V or lower. thank you all...
×
×
  • Create New...