pokmo

Members
  • Content count

    19
  • Joined

  • Last visited

  1. Hi I'm very new and have a few basic questions about the code. How come TA0CCR0 takes the decimal value 20000? Also, why does it need to wait for CounterValue to reach 400? My understanding is that CounterValue is incremented for each positive edge. Why does it need to wait for 400 positive edges? Thanks
  2. Hi Does anyone know of a fast method for computing square roots of 16-bit integers? I've had a look at StellarisWare, but is there something more lightweight since the input is only 16-bit? Any thought appreciated.
  3. Hi I'm planning to build a low-power water level alarm which can last for at least 4 months on continuous usage. I've found a schematic using the 555 timer but it'd use some 30mW. I wonder if it'd be a good idea to use MSP430, put it to sleep and raise an interrupt when a certain pin is short by water's conduction. Is water conductive enough to wake up the MSP430? Any thought appreciated. Thanks
  4. Indeed. Could this schematic be used for OOK though?
  5. How about a circuit like this? I found it here: https://github.com/arms22/SoftModem
  6. Indeed, I'm trying to communicate commands from the PI to the MSP430 via the PI's audio output. The laptop I have isn't actually all that old and doesn't have serial ports. Plus, I'm hoping to generate the commands from javascript, so I think audio output might be easier. Beside the voltage divider and diodes, would I need an opamp? I've seen some circuits with an opamp for "signal conditioning".
  7. Hi I wonder if there's an analog comparator built into the MSP430. That is, could an analog comparator be be set up to trigger an interrupt when the voltage on the one pin exceeds the voltage on another pin. Thanks for the help in advance.
  8. I see. I'm just hoping to take (audio) commands from the PI and control a DC motor with a MSP430. So the data won't need to be transmitted. Does that mean the Soft Modem demo is irrelevant since it expects a phone line and UART on RX and TX, respectively? Sorry, I'm very new. I know I could use USB instead, but I wanted to control the MSP430 with javascript. Rather than an ADC and FFT filtering, could I just use RC filters? Thanks
  9. I was reading http://www.ti.com/lit/an/slaa204/slaa204.pdf so I was thinking about using MSP430F1121: Do you think there'll be enough RAM? This is the circuit provided - Is it right that TX and RX are audio signals? Thanks
  10. There's actually no specific preference over the audio characteristics. So long messages can be transmitted as audio output and be read on the MSP. I'm working with a raspberry pi right now, but ultimately I'll want to use it with an old laptop without working USB ports.
  11. Hi all, I wonder if it'd be a relatively straightforward exercise to read data from a 3.5mm audio jack using a MSP430 and a raspberry pi. The communication will be unidirectional: raspberry pi transmits data as audio output to MSP, so the MSP will do the reading. Does anyone know how this could be accomplished? Note that I'm trying to communicate over the audio jack and not serial. Any thought appreciated.
  12. Mostly because of space limitations. Unfortunately, even the Arduino Pro Mini is too big here. I was planning to design a tighter PCB for the MSP.
  13. Sure. Here it is: #include <SPI.h>long recOmegaD = 0; long omegaD = 0; long thetaM = 0; long recMicros = 0; long recOmegaDa = 0; long omegaDa = 0; long thetaMa = 0; long deg1000 = 0; int variPwm = 0; byte phase = 0; int rz, rza, dRz, dRza; long R, Ra; const int motorPin1 = 3; const int motorPin2 = 9; const int motorPin3 = 10; const long L1000 = 51429; const int nLnT1000 = 2140; const int LnT1000 = 4291; const int LnLvl10 = 390; const long slope1000 = 41245; void L3GD20_write(byte reg, byte val) { digitalWrite(5, LOW); SPI.transfer(reg); SPI.transfer(val); digitalWrite(5, HIGH); } byte L3GD20_read(byte reg) { byte ret = 0; digitalWrite(5, LOW); SPI.transfer(reg | 0x80); ret = SPI.transfer(0); digitalWrite(5, HIGH); return ret; } void L3GD20a_write(byte reg, byte val) { digitalWrite(6, LOW); SPI.transfer(reg); SPI.transfer(val); digitalWrite(6, HIGH); } byte L3GD20a_read(byte reg) { byte ret = 0; digitalWrite(6, LOW); SPI.transfer(reg | 0x80); ret = SPI.transfer(0); digitalWrite(6, HIGH); return ret; } void setup () { Serial.begin(9600); pinMode(motorPin1, OUTPUT); pinMode(motorPin2, OUTPUT); pinMode(motorPin3, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); digitalWrite(5, HIGH); digitalWrite(6, HIGH); SPI.begin(); SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE3); SPI.setClockDivider(SPI_CLOCK_DIV2); L3GD20_write(0x20, B11001111); L3GD20_write(0x23, B00000000); L3GD20a_write(0x20, B11001111); L3GD20a_write(0x23, B00000000); TCCR1B &= B11111000; TCCR1B |= B00000001; TCCR2B &= B11111000; TCCR2B |= B00000001; calibrate(); delay(50); recMicros = micros(); } void loop () { chkAndCtl(); calcPwms(); if ( phase == 1 ) { analogWrite(motorPin1, variPwm); analogWrite(motorPin2, 255); analogWrite(motorPin3, 0); } if ( phase == 2 ) { analogWrite(motorPin1, 255); analogWrite(motorPin2, variPwm); analogWrite(motorPin3, 0); } if ( phase == 3 ) { analogWrite(motorPin1, 255); analogWrite(motorPin2, 0); analogWrite(motorPin3, variPwm); } if ( phase == 4 ) { analogWrite(motorPin1, variPwm); analogWrite(motorPin2, 0); analogWrite(motorPin3, 255); } if ( phase == 5 ) { analogWrite(motorPin1, 0); analogWrite(motorPin2, variPwm); analogWrite(motorPin3, 255); } if ( phase == 6 ) { analogWrite(motorPin1, 0); analogWrite(motorPin2, 255); analogWrite(motorPin3, variPwm); } } void calibrate() { analogWrite(motorPin1, 217); analogWrite(motorPin2, 0); analogWrite(motorPin3, 255); delay (3000); R = 0; Ra = 0; for (long i = 0 ; i < 4000 ; i++ ){ if ( i > 1000 ) { rz = ( (L3GD20_read(0x2D) << 8) | L3GD20_read(0x2C) ); R = R + rz; rza = ( (L3GD20a_read(0x2D) << 8) | L3GD20a_read(0x2C) ); Ra = Ra + rza; delayMicroseconds( 25 ); } } dRz = R / 750; dRza = Ra / 750; } void chkAndCtl() { R = 0; Ra = 0; for (int i = 0 ; i < 4 ; i++ ) { rz = ( (L3GD20_read(0x2D) << 8) | L3GD20_read(0x2C) ); R = R + rz; rza = ( (L3GD20a_read(0x2D) << 8) | L3GD20a_read(0x2C) ); Ra = Ra + rza; delayMicroseconds( 25 ); } omegaD = ( R - dRz ) * 0.025; omegaDa = ( Ra - dRza ) * 0.025; recMicros = micros() - recMicros; thetaM = thetaM + ( (omegaD+recOmegaD)/20 ) * recMicros; thetaMa = thetaMa + ( - (omegaDa+recOmegaDa)/20 ) * recMicros; // Line A deg1000 = thetaM / 1000 - 1*omegaDa * recMicros /500 + 1*thetaMa/1000;// Line B recMicros = micros(); recOmegaD = omegaD; recOmegaDa = omegaDa; } void calcPwms() { int degPwm1000 = deg1000 % 8571; if ( degPwm1000 < 0 ) { degPwm1000 = degPwm1000 + 8571; } long linePwm = ( LnLvl10 + ( slope1000 * degPwm1000 ) / 100000 + 5 ) / 10; long degNL1000 =abs( degPwm1000 - LnT1000 - nLnT1000 ); long nLinePwm = 255 - ( ( - 2935 * (sq( sq(degNL1000)/1000 ) /1000 ) + 8413 * ( (sq(degNL1000)/1000 ) * degNL1000 /1000 ) - 11421 * (sq(degNL1000)/1000 ) + 32929 * ( degNL1000 ) ) / 100000 + 5 ) / 10; int pwmShape = 0; if ( degPwm1000 < LnT1000 ) { pwmShape = linePwm; } else { pwmShape = nLinePwm; } int dDegPwm1000 = deg1000 % 17143; if ( dDegPwm1000 < 0 ) { dDegPwm1000 = dDegPwm1000 + 17143; } if ( dDegPwm1000 < 8571 ) { variPwm = 255 - pwmShape; } else { variPwm = pwmShape; } long shftDeg1000 = ( deg1000 + L1000/2 + nLnT1000 ) % L1000; if ( shftDeg1000 < 0 ) { shftDeg1000 = shftDeg1000 + L1000; } phase = 0; if ( shftDeg1000 < 8571 ) { phase = 1; } else { if ( shftDeg1000 < 17143 ) { phase = 2; } else { if ( shftDeg1000 < 25714 ) { phase = 3; } else { if ( shftDeg1000 < 34286 ) { phase = 4; } else { if ( shftDeg1000 < 42857 ) { phase = 5; } else { phase = 6; } } } } } }
  14. Hi Bob, I'm looking at trying the IAR 4K Kickstart version as well. I have no experience in CCS or IAR. Could CCS code be compiled on IAR? I've heard many good things about IAR, which is why I'm thinking of giving it a try.
  15. Hi I have an Arduino sketch that I'd like to port to the MSP. I know I could use Energia, but I was hoping to use a better toolchain for better optimisation. The sketch takes readings from a gyro and controls a BLDC motor - like a stabiliser. I haven't made up my mind on which MSP430 to use though. Does anyone know how I could approach to the porting? Should I just get the most 'performant' MSP430 and ensure the code runs first? Should I jump straight into CCS? Any thought would be appreciated. Thanks