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.


Found 56 results

  1. When using analog read function, ADC never gives 0 value even when it is directly connected to the ground. But when I connect it to 3.3V it gives constant 4095 value. What is the problem?
  2. I would like to measure the voltage of a NiMH DC battery not exceeding 12V and I just knew that msp430g2553's ADC has an internal voltage divider. Is it appropriate to use the internal voltage divider directly without any external circuit?
  3. I'm using the FRC Gamepad Tool to load the TI-supplied firmware for a USD HID joystick with a KMA210 magnetic angle sensor. I have a voltage divider taking the KMA210's 5V max output to 3.3V, and when plugging in the MSP and checking the windows game controllers, an axis does respond when I turn a magnet near the sensor, but the reading is all over the place. Bouncing back and forth by 40% of the whole angle range. I've tried using an external 5V supply, tried changing the sampling on the ADC, the Vref, the clock multiplier, the wires, the input pin, just about everything. Does anyone have any advice?
  4. Hello, I recently ported over an Energia sketch that had working WiFi functionality in order to help with remote logging for a project I'm working on. The WiFi works well, but now the CCS code that was handling the ADC interrupts and measuring data is no longer functioning. If possible, I would like to make minimal changes to the CCS code as it was working exactly as we desired. I feel like there must be a relatively simple fix that I'm missing but I can't seem to figure it out. Can someone please help figure out what's wrong the ADC interrupt in the following code? #include <stdint.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <math.h> #include "inc/hw_types.h" #include "inc/hw_gpio.h" #include "inc/hw_memmap.h" #include "inc/hw_ints.h" #include "sysctl.h" #include "gpio.h" #include "driverlib/gpio.h" #include "driverlib/timer.h" #include "driverlib/interrupt.h" #include "driverlib/debug.h" #include "driverlib/adc.h" #include "inc/tm4c123gh6pm.h" #include <string.h> #include <WiFiClient.h> #ifndef __CC3200R1M1RGC__ // Do not include SPI for CC3200 LaunchPad #include <SPI.h> #endif #include <WiFi.h> // your network name also called SSID char ssid[] = ""; // your network password char password[] = ""; WiFiClient client; IPAddress server(); uint16_t port = ; #define SAMPLING_RATE 80000.0 // #define TARGET_FREQUENCY 10000.0 // #define BLOCK_SIZE 80 #define BUFFER_SIZE 255 //result cannot be declared in interrupt handler uint8_t flag = 0; uint32_t buffer[BUFFER_SIZE]; uint32_t bufferIndex = 0; float goertzel(uint32_t buffer[]) { int k, i; const float floatN = (float)BLOCK_SIZE; float omega; k = (int) (0.5 + ((floatN * TARGET_FREQUENCY ) / SAMPLING_RATE)); omega = (2.0 * 3.14 * k)/floatN; float sine = sin(omega); float cosine = cos(omega); float coeff = 2.0 * cosine; float Q0 = 0; float Q1 = 0; float Q2 = 0; float scaling_factor = BLOCK_SIZE/2.0; for (i = 0; i < BUFFER_SIZE; i++) { Q0 = coeff * Q1 - Q2 + buffer[i]; Q2 = Q1; Q1 = Q0; } float imag, real, result; real = (Q1 - Q2 * cosine) / scaling_factor; imag = (Q2 * sine) / scaling_factor; result = sqrtf(real * real + imag * imag); return result; } void ADC3IntHandler(void) { float result = 0.0; ADCIntClear(ADC0_BASE, 3); if (flag == 0) { //GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_PIN_0); flag = 1; } else { //GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0); flag = 0; } if (bufferIndex >= 255) { bufferIndex = 0; ADCSequenceDisable(ADC0_BASE, 3); result = goertzel(buffer); client.println(result); ADCSequenceEnable(ADC0_BASE, 3); } ADCSequenceDataGet(ADC0_BASE, 3, (buffer + bufferIndex)); bufferIndex++; } void setupADC(void) { SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_25MHZ); //Enable ADC0 and timer SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); //pin for testing //GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0); TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); TimerClockSourceSet(TIMER0_BASE, TIMER_CLOCK_SYSTEM); //625 - 40 kHz sampling rate TimerLoadSet(TIMER0_BASE, TIMER_B, 625); TimerControlTrigger(TIMER0_BASE, TIMER_B, true); //Disable before configuring ADCSequenceDisable(ADC0_BASE, 3); ADCSequenceConfigure(ADC0_BASE, 3, ADC_TRIGGER_TIMER, 0); ADCSequenceStepConfigure(ADC0_BASE, 3, 0, ADC_CTL_CH0 | ADC_CTL_IE | ADC_CTL_END); //sequencer 3 on PE3 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //PE3 ADC pin GPIOPinTypeADC(GPIO_PORTE_BASE, GPIO_PIN_3); IntRegister(INT_ADC0SS3, ADC3IntHandler); ADCIntRegister(ADC0_BASE, 3, ADC3IntHandler); IntMasterEnable(); IntEnable(INT_ADC0SS3); ADCIntEnable(ADC0_BASE, 3); ADCSequenceEnable(ADC0_BASE, 3); SysCtlDelay(10); TimerEnable(TIMER0_BASE, TIMER_B); //Timer A conflicts with SPI of wifi module ADCIntClear(ADC0_BASE, 3); } void setup() { setupADC(); WiFi.begin(ssid, password); while ( WiFi.status() != WL_CONNECTED) { delay(300); } while (WiFi.localIP() == INADDR_NONE) { delay(300); } uint8_t tries = 0; while (client.connect(server, port) == false) { if (tries++ > 100) { while(1); } delay(100); } delay(1000); } void loop() { //client.println("hello"); } Thank you!
  5. I am currently trying to read a couple of parameters from onboard sensrs on TelosB, then print out on monitor which I am using PuTTY. However, I am not getting any values here. Please could some on hlep me out? I attached my code and corresponding datasheets too THank you 00std_temp.c msp430f1611.pdf telosMote.pdf
  6. Hi, These after read this thread about how to use temperature calibration data, I tried to use TLV register to obtain the "real" voltage reference value and increase the ADC conversion by compensating the gain and offset. The test was performed in a Launchpad EXP430FR6989, but can be applied to other launchpads compatible with MSP430Ware driverlib. The increase in the accuracy is very interesting. in the table (sorry by the comma instead of point, brazilian notation). HP 3478A - value measured with DMM ADC_correct1 - value measured with MSP430 without any correction ADC_correct4 - with all corrections using float variables ADC_correct5 - using mainly integer Here there is an article about this test and the Github with the example. Regards
  7. Noise in ADC

    Hi, I have a non-profit (Smoky Mountain Scientific, smokymtsci.com) that develops and sells low cost instruments for science education. One of our instruments incorporates a Tiva-C launchpad that outputs a pwm voltage and measures voltage and current passed in electrochemical reactions. I recently purchased a fairly large batch of Tiva launchpads from Mouser and I am having trouble with noise in the analog read channels for about 1/4th of the boards. We have been building and selling these instruments for a couple of years now and have never had this problem before. To test the boards, I send a pwm signal through a simple low pass filter (a resistor and a capacitor) then read the output on two channels (A11 and A8). The attached figures show examples of output from a good (file Board46) and a bad (file Board37) boards as displayed on our user interface. This seems to be a hardware problem and I dont know how to go about resolving it. Any recommendations? Thanks, Jack
  8. So, this is partly for me, and partly for others who need a refresher, or just do not know how. But I will be making several post here over time on how to write very simply code, to do one thing, or another. These, used in conjunction with a shell script could be very useful / flexible. After several long talks with many people, including some here on these very forums. I've decided that using C, to communicate with hardware, or hardware interfaces is best as can be for many situations. However, when you need to run several tools all at once, and have output formatted in some fashion, or easily modified. Shell scripts are very good at that sort of thing. Read from a real-time clock This post I will make about reading from a real-time clock. I spent hours messing around code related to I2C communications, and could never get exactly what I wanted. Plus, I wanted something that output date / time that looked very similar to the date Linux command. This could definitely been done using a shell script, but code size would probably be a lot larger. Additionally, a shell script would very likely be a lot slower, as with a script, one would have to be calling external cmdline tools to perform various operations. This example code is very fast, and prints to screen immediately after issuing the command. Since this command is very simple, and only prints the formatted date / time to screen. This could very easily be called from a shell script, and formatted further if need be. The real-time clock I'm using for this demonstration is a Maxim DS3232 real-time clock which is very accurate, and also very expensive compared to other real-time clocks. At $7 + US each, it's not cheap. I also had to write my own device tree overlay for this RTC, which strictly speaking is not necessary. One can set the device up from the command line manually as demonstrated for many different RTC's on the web. In fact, all the device tree overlay that I wrote does, is set all this automatically up at boot. As far as teh actual overlay it's self. All I did was modify an existing overlay from the "official" bb-overlays repo on github. https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-RTC-01-00A0.dts To look something like this: /* * Copyright (C) 2015 Robert Nelson <robertcnelson@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ /dts-v1/; /plugin/; #include <dt-bindings/board/am335x-bbw-bbb-base.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/pinctrl/am33xx.h> / { compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green"; /* identification */ part-number = "BB-RTC-01"; version = "00A0"; fragment@2 { target = <&i2c2>; __overlay__ { status = "okay"; /* shut up DTC warnings */ #address-cells = <1>; #size-cells = <0>; /* MCP79410 RTC module */ rtc@68 { compatible = "maxim,ds3232"; reg = <0x68>; }; }; }; }; On our cape, the RTC is on bus I2C-2, which is already enabled by default for capemgr. The rest of the above just means that status is okay(load the device ), the kernel module to load is called "ds3232", and the device address on the bus is 0x68. Now on to the actual C code for reading from /dev/rtc1: #include <stdio.h> #include <stdlib.h> #include <linux/rtc.h> #include <sys/ioctl.h> #include <sys/time.h> #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> void display_date_time(void) { struct rtc_time rtc_tm; int fd = open("/dev/rtc1", O_RDONLY); if(fd == -1){ perror("/dev/rtc"); exit(errno); } /* Read the RTC time/date */ int retval = ioctl(fd, RTC_RD_TIME, &rtc_tm); if (retval == -1) { perror("ioctl"); exit(errno); } int d = rtc_tm.tm_mday; int m = rtc_tm.tm_mon + 1; int y = rtc_tm.tm_year + 1900; const char *wdays[] = {"Sun","Mon","Tues","Wed","Thur","Fri","Sat"}; const char *mnths[] = {"Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec"}; int wday = (d += m < 3 ? y-- : y - 2, 23*m/9 + d + 4 + y/4- y/100 + y/400)%7; fprintf(stdout, "%s %s %02d %02d:%02d:%02d %d UTC\n", wdays[wday], mnths[rtc_tm.tm_mon], rtc_tm.tm_mday, rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec, y); } int main( int argc, char **argv ) { display_date_time(); return 0; } As one can see, most of this code is for formatting the output in a specific way. In this case, the output will look exactly like the output one might expect to see after issuing the command "date". However, this output is fixed to output the date / time in the UTC time zone. As for one of the projects I'm using this in is for devices spread out all over the US, in 3 different time zones, and we do not care so much what the local time zone of that system so much, as much as knowing a given time "standard". e.g. if something fails, and we need to tell a customer what failed, and what time it failed, we can, Then if we need to convert that time to their time zone, easy. Notice that the read() is handled by ioctl(). . . Output: root@wgd:~/# gcc -Wall -o read_rtc read_rtc.c root@wgd:~/# ./read_rtc Tues May 09 23:08:49 2017 UTC
  9. Hello fellows, I need some help, with a situation, I want convert some analog signals to digital and send him by the UART communication, but I dont get how to solve this problem. my digital values is represented by "tempADC" variable, soo how can I get a buffer with values to the pc with UART communication. I try many things, but i dont understand how to put my output signal in the terminal in this format. temperature: 40º temperature: 41º temperature: 42º temperature: 43º can anyone help me?! my code: #include "uart_Tx.h" #include "stdio.h" void UART_TxConfig(void){ /*CLOCK SYSTEM SUPORT (CS)*/ CS->KEY = 0x695A;/*UNLOCK ALL 16 LSB CS REGISTERS*/ CS->CTL0 = 0;/*RESET PARAMETERS*/ CS->CTL0 = CS_CTL0_DCORSEL_5;/**/ /*CLOCK SYSTEM*/ /*SELA_2 ACLK = REFOCLK*/ /*SELS_3 SMCLK = DCOCLK*/ /*SELM_3 MCLK = DCOCLK*/ CS->CTL1 = CS_CTL1_SELA_2 | CS_CTL1_SELS_3 | CS_CTL1_SELM_3; /*LOCK ACESSES TO REGISTERS*/ CS->KEY = 0;/*UNLOCK ALL 16 LSB CS REGISTERS*/ /*UART PIN CONFIGURATION*/ P1-> SEL0 |= BIT2 | BIT3; /*SET 2 UART PIN's*/ /*ACTIVE INTERRUPTION's*/ __enable_interrupt(); /*ACTIVE eUSCIA0 INTERRUPT IN NVIC MODULE*/ NVIC->ISER[0] = 1 << ((EUSCIA0_IRQn) & 31); /*CONFIGURE UART*/ UCA0CTLW0 |= UCSWRST; UCA0CTLW0 |= UCSSEL__SMCLK;/*SELECT SMCLK CLOCK SOURCE*/ /*BAUD RATE CALCULATION * BAUD RATE DIVISOR (TRANSMITIONS RATE) * 12MHz/(16*9600) = 78.125 VELOCITY *FRACTIONAL PORTION = 0.125 *FRACTIONAL */ UCA0BR0 = 26; /*48000000/16/115200*/ UCA0BR1 = 0x00; UCA0MCTLW = 0x1000 | UCOS16 | 0x0020; /*CONTROL WORD REGISTER*/ UCA0CTLW0 &= ~UCSWRST; /*SOFTWARE RESET DISABLE*/ UCA0IE |=UCRXIE; while(1){ } } /*UART INTERRUPT SERVICE ROUTINE*/ void EUSCIA0_IRQHandler (void){ if (UCA0IFG & UCRXIFG){ while(!(UCA0IFG & UCTXIFG)); UCA0TXBUF = UCA0RXBUF; //UCA0TXBUF = adcTemp; //P1->OUT ^= BIT0; } }
  10. Hi All, I am working on a project using the CC1310 LaunchPad, and it will be powered directly from a 3V (nominally) battery. I want to use the ADC to accurately read the voltage from one of my sensors, and the problem that I am having is that the reference seems to be relating to the voltage the LaunchPad is running from. I have tried using analogReference(), but it wont compile with the parameter INTERNAL1V5, and when i try INTERNAL2V5 it does compile, but it still seems to be using the battery voltage as the ADC reference. Please can someone explain how I can get a stable voltage reading on the ADC despite the variation in the battery voltage? I am also designing a custom PCB for this project, based on the LaunchPad reference design, if that helps? Additionally, it would be very helpful to monitor the battery level. Can the cc1310 do this, or will I need to connect the battery to an ADC input pin? Regards, -Steve
  11. Hello, We are planning to do work on CC3200MOD LaunchpadXL. So, CC3200 GPIO/UART/ADC Energia IDE based header files can compatible in CC3200MOD? I also some confusion regarding Energia IDE based header file.Please mention below description. If you see pin_energia.h file in one array initialize for CC3200 LaunchXL like this, const uint16_t digital_pin_to_pin_num[] = { NOT_A_PIN, /* dummy */ NOT_A_PIN, /* 1 - 3.3V */ PIN_58, /* 2 - GPIO_03 */ <- pins_energia.h (CC3200) *Note : In CC3200MOD PIN_58 = GND PIN_04, /* 3 - GPIO_13 */ PIN_03, /* 4 - GPIO_12 */ PIN_61, /* 5 - GPIO_06 */ PIN_59, /* 6 - GPIO_04 */ PIN_05, /* 7 - GPIO_14 */ PIN_62, /* 8 - GPIO_07 */ PIN_01, /* 9 - GPIO_10 */ PIN_02, /* 10 - GPIO_11 */ PIN_15, /* 11 - GPIO_22 */ PIN_55, /* 12 - GPIO_01 */ PIN_21, /* 13 - GPIO_25 */ PIN_06, /* 14 - GPIO_15 */ PIN_07, /* 15 - GPIO_16 */ NOT_A_PIN, /* 16 - RESET */ PIN_45, /* 17 - GPIO_31 */ PIN_08, /* 18 - GPIO_17 */ PIN_18, /* 19 - GPIO_28 */ NOT_A_PIN, /* 20 - GND */ NOT_A_PIN, /* 21 - 5V */ NOT_A_PIN, /* 22 - GND */ PIN_57, /* 23 - GPIO_02 */ PIN_60, /* 24 - GPIO_05 */ PIN_58, /* 25 - GPIO_03 */ PIN_59, /* 26 - GPIO_04 */ PIN_63, /* 27 - GPIO_08 */ PIN_53, /* 28 - GPIO_30 */ PIN_64, /* 29 - GPIO_09 */ PIN_50, /* 30 - GPIO_00 */ PIN_17, /* 31 - GPIO_24 */ PIN_16, /* 32 - GPIO_23 */ PIN_60, /* 33 - GPIO_05 */ PIN_62, /* 34 - GPIO_07 */ PIN_18, /* 35 - GPIO_28 */ PIN_21, /* 36 - GPIO_25 */ PIN_64, /* 37 - GPIO_09 */ PIN_17, /* 38 - GPIO_24 */ PIN_01, /* 39 - GPIO_10 */ PIN_02 /* 40 - GPIO_11 */ }; github_Link : https://github.com/energia/Energia/blob/master/hardware/cc3200/variants/launchpad/pins_energia.h Here you can see highlighted portion. When you compare datasheet of CC3200 and CC3200MOD both PIN configuration are different. So, here mention pin_energia.h header file makes for CC3200. So, Is this pin_energia.h header file can support for CC3200MOD? If not then please give me a suggestion how to modify. Regards, Pratik pins_energia.h
  12. I am using the current sensor HO 10-P with my TM4C123 launchpad board. Essentially I have to connect the Vout pin to a GPIO, configure the GPIO as an ADC pin and then configure the ADC controller to read the Vout from the sensor. I will connect the Vout to PE2 (which is AIN2 and also a GPIO). Wondering how to configure this GPIO as an ADC and then read it? Can you show a sample code snippet?
  13. Hello all, I've been able to get the chatserver example to work. I did some modifications on it and I'm now printing data from adc when client connects. I was wondering if I can save the data from the adc in a file using a telnet command. I mean, as soon as the adc starts reading I'd like to send some kind of telnet or whatever command to save this into a file. I read about some telnet commands like: "telnet ip -f file_location" or even "telnet ip port >> file_location", but I don't know how to implement this at the end of the adc conversion. I mean, can I just do: client.write("telnet ip port >> file_location"); ? I tried something like that but it didn't work. Thank you in advance! Alex
  14. I am using this current sensor in my project. The Vout pin needs to be connected to the ADC. The best way to do this is to connect it to some analog pin and tie that analog pin to ADC through the code. Anything else? Can you refer to a sample code for this?
  15. MSP430G2553 ADC

    Hi, I'm new to MSP430, I'm using a MSP430G2553 in a project and need help with an in depth understanding of programming the ADC10 inputs of the MCU. I'm using a potentiometer in order to light one of 3 LEDs. For example, LED1 lights up when input voltage is 1V or less, LED2 lights up between 1V and 2V and LED3 lights up when the input voltage is greater than or equal to 2V. I have attached my code below but I am not clear on how to read, convert and store a voltage so that I can use the IF statements to light the respective LEDs. #include <msp430g2553.h> void indicator_LED(); int main(void) { unsigned int i; WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer P1DIR = 0x00; P2DIR = 0xff; P1OUT = 0x00; P2OUT = 0x00; while(1) // keep looping { ADC10CTL1 = CONSEQ_2 + INCH_0; // Repeat single channel, A0 ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE; // Sample & Hold Time + ADC10 ON + Interrupt Enable ADC10DTC1 = 0x0A; // 10 conversions ADC10AE0 |= 0x01; // P1.0 ADC option select ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __low_power_mode_0(); //__bis_SR_register (CPUOFF + GIE);// LPM0, ADC10_ISR will force exit if (ADC10MEM <= 0x228 && ADC10MEM > 0x1D6) { P2OUT = P2OUT | BIT1; for(i=0;i<=1;i++); } else if (ADC10MEM <= 0x1D6) { P2OUT = P2OUT | BIT2; for(i=0;i<=1;i++); } else if (ADC10MEM > 0x228) { P2OUT = P2OUT | BIT0; for(i=0;i<=1;i++); } else { P2OUT = ~P2OUT; for(i=0;i<=1;i++); } } }
  16. Hi, I want to use all of the 24 analog input channels of the MSP432P401R Launch Pad and print it serial. It works realy good for 23 of the 24 input channels, but only Pin 5.3 (ADC14INCH_2) doesn
  17. I'm using a Tiva C series launchpad (TM4C123G) to sample analog data using an external ADC (ADC0804). The ADC is clocked at 1.4MHz. The SysCtlClockSet command was used to set clock freq to 80MHz. A square wave is being generated on a pin, with a frequency same as the sampling rate, using the code given below. So this gives us the sampling rate on an oscilloscope. For some reason the sampling rate is TOO low. It is only ~330KHz with NO command in the loop. It drops to about ~280KHz with one digitalRead and to just a few hundred Hz with a SerialPrintln(). What is causing it to run so slow and how can it be improved? #include <tm4c123ge6pm.h> #include <stdint.h> #include <stdbool.h> #include <pin_map.h> #include <sysctl.h> int db0 = PB_3; int db1 = PC_4; int db2 = PC_5; int db3 = PC_6; int db4 = PC_7; int db5 = PD_6; int db6 = PD_7; int db7 = PF_4; int cs = PB_5; int rd = PD_1; int wr = PD_0; int intr = PE_4; int out = PD_3; int a = 0; int count = 1; int b; boolean flag = 0; void setup() { SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ); //SysCtlClockSet(SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ|SYSCTL_SYSDIV_2_5); pinMode(db0, INPUT); pinMode(db1, INPUT); pinMode(db2, INPUT); pinMode(db3, INPUT); pinMode(db4, INPUT); pinMode(db5, INPUT); pinMode(db6, INPUT); pinMode(db7, INPUT); pinMode(out, OUTPUT); pinMode(cs, OUTPUT); pinMode(rd, OUTPUT); pinMode(wr, OUTPUT); pinMode(out, OUTPUT); pinMode(intr, INPUT); pinMode(db0, INPUT); pinMode(db1, INPUT); pinMode(db2, INPUT); pinMode(db3, INPUT); pinMode(db4, INPUT); pinMode(db5, INPUT); pinMode(db6, INPUT); pinMode(db7, INPUT); Serial.begin(9600); //Code of initialzation... //Step C digitalWrite(cs, LOW); delay(100); //has to be type unsigned long digitalWrite(out,HIGH); b=1; } void loop() { flag = !flag; digitalWrite(out,flag); a= digitalRead(db0); count = 1; a = 0; a = a+ digitalRead(db0)*count; count = count*2; a = a+ digitalRead(db1)*count; count = count*2; a = a+ digitalRead(db2)*count; count = count*2; a = a+ digitalRead(db3)*count; count = count*2; a = a+ digitalRead(db4)*count; count = count*2; a = a+ digitalRead(db5)*count; count = count*2; a = a+ digitalRead(db6)*count; count = count*2; a = a+ digitalRead(db7)*count; count = count*2; Serial.println(a); //Serial.println(SysCtlClockGet()); }
  18. MSP432P401R, Energia 16, Windows 7 64-bit Hi, I am using MSP432 in Energia and my analog input can only take a value between 0 and 1023 (10 bit) but the ADC should be 14 bit. How do I change this? In the MSP432 user manual table 20-1 shows different ADC14 Conversion Result Formats but I am struggling to convert this into Energia code. Thanks1
  19. MCP3008 ADC Library

    The MCP3008 is an easily used 10bit, 8 channel, Serial Peripheral Interface (SPI) Analog to Digital Converter. I created an Energia library that can be found here and used to read any of the eight pins with a single call. Conversion is done for voltages between 0 and 3.3 V, including on the CC3200, and results in a integer reading between 0 and 1023. This library is for single ended operation only and uses hardware SPI. An example is included that demonstrates reading from all 8 channels. Tested with Energia 0101E0016 on the following LaunchPads * CC3200-LAUNCHXL Rev 4.1 (80 MHz) EMT * CC3200-LAUNCHXL Rev 4.1 (80 MHz) * MSP-EXP432P401R (48 MHz) EMT * MSP430F5529 Rev 1.5 (25 MHz) * MSP-EXP430FR5969 Rev 2.0 (16 MHz) * MSP-EXP430G2553 Rev 1.5 (16 MHz)
  20. Hi guys, this forum have already helped me a lot, but I never needed to make a post. So, here I am I am using the MSP432 LaunchPad with CC3100. I could not find useful examples to use the CC3100 on CCS, so I decide to use Energia. What I need to do is get some analog data, convert it to digital and send it through the TCP/IP protocol. So far, everything is working fine, the problem is that I need the ADC sample rate be around 1kHz and I could not find where I can change it or verify it. Do you guys know what is the default ADC sample rate for MSP432? Also, I am using ADC with 14 bits of resolution. Thank you!
  21. Hello everyone, I have a problem with Energia and my MSP430F5529, this micro is enable to use 12bits ADC, but I can't find the way to make it enable that configuration because Energia runs my code in default 10bits ADC, some one can tell me how can I configure the ADC to use 12 bits resolution??, this is my code: #include <Servo.h> Servo servo; int potpin = 23; int volt, i; void setup() { servo.attach(19); } void loop() { volt=analogRead(potpin); i=volt/6; //I'ms using 6, because 1023/6 = aprox ? 180 steps that I need. I want to use 4095/23 ? 180 steps servo.write(i); delay(100); } My code is working, but is working with 10bits resolution, and I need 12bits.Thanks for attention to my post ^^
  22. Hello, I am trying to measure voltage across a voltage diviter with a Tiva-C series boards, and I am consistently getting mis results. I get 0-4096 for 0 to 3.3V. I also have a seperate battery, that goes in to a 100K + 15K voltage divider network and PE_2 is connected to the middle of the voltage divider. It measures 1.1V approximately, when it should be measuring 0.77V. But here is the interesting part. When I use a multimeter to measure the same middle point in the voltage divider, it reads 0.77, and the value from the analog read also converges to 0.77 - then i disconnect the multimeter it will go up to 1.1V back. This brings the question: what is the analog state of this adc pin? does it has to be initialized with pinMode as input, in order to do analogRead? Best regards, C.A.
  23. Hi, I am trying to get the ADC sample timestamp on Energia, but I can not figure it out how it works. From the TI API I know that the ADC data saved on the register is made by two parts. bits [13:0] : ADC sample bits [31:14]: time stamp per ADC sample So I took the Energia library. From <driverlib/adc.h> and I found a method that returns only the time stamp. //***************************************************************************** // //! Gets the current value of ADC internal timer //! //! \param ulBase is the base address of the ADC //! //! This function the current value of 17-bit ADC internal timer //! //! \returns Return the current value of ADC internal timer. // //***************************************************************************** unsigned long ADCTimerValueGet(unsigned long ulBase) { return(HWREG(ulBase + ADC_O_adc_timer_current_count)); } So I have modified the wiring_analog.c library: uint16_t analogRead(uint8_t pin) { uint16_t channel, val; uint16_t pinNum = digitalPinToPinNum(pin); switch(pinNum) { case PIN_57: {channel = ADC_CH_0;}break; case PIN_58: {channel = ADC_CH_1;}break; case PIN_59: {channel = ADC_CH_2;}break; case PIN_60: {channel = ADC_CH_3;}break; default: return 0; } while(ADCFIFOLvlGet(ADC_BASE, channel)) { // flush the channel's FIFO if not empty ADCFIFORead(ADC_BASE, channel); } PinTypeADC(pinNum,0xFF); ADCChannelEnable(ADC_BASE, channel); ADCTimerConfig(ADC_BASE,2^17); ADCTimerEnable(ADC_BASE); ADCEnable(ADC_BASE); while(!ADCFIFOLvlGet(ADC_BASE, channel)); val = ADCFIFORead(ADC_BASE, channel) & 0x3FFF; // ***** TIME STAMP FIELD **** timestamp = ADCTimerValueGet(ADC_BASE); // ***** TIME STAMP FIELD **** ADCDisable(ADC_BASE); ADCChannelDisable(ADC_BASE, channel); ADCTimerDisable(ADC_BASE); val = val >> 2; return val; } // Return the ADC sample time stamp unsigned long ADCGetTime() { return timestamp; } And this is my test sketch #include <wiring_analog.c> int sensorPin = 2; // select the input pin for the potentiometer uint16_t long sensorValue[5] = {0}; // variable to store the value coming from the sensor unsigned long time[5] = {0}; unsigned long m = 0; unsigned int seconds = 0; unsigned int minutes = 0; unsigned int hours = 0; void setup() { Serial.begin(115200); } void loop() { // read the value from the sensor: for (int i = 0; i< 5; i++) { sensorValue [i] = analogRead(sensorPin); time[i] = ADCGetTime(); delay(1); } for(int i = 0; i < 5; i++) { minutes = ( time[i] / 1000 / 60); seconds = ( time[i] / 1000) % 60; m = ( time[i] % 100); Serial.println("ADC VALUE: "); Serial.print(sensorValue[i]); Serial.print(" --- TIME STAMP: "); Serial.print(minutes); Serial.print(":"); Serial.print(seconds); Serial.print(":"); Serial.println(m); Serial.print("\n"); } delay(5000); } The problem is that the value of the variable time do not change. It's always the same. What is wrong with my test sketch? How can I access to the time stamp of my samples? Thank you in advance.
  24. 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
  25. ADC MSP430 delay(20)

    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!
×