Jump to content

Zander

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. There is almost no change. What's happening is I'm reading off a 10k potentiometer in voltage division configuration, high side is 5 volts low side is ground. P1.6 is just 2 volts under no load condition and only turns on or off when the potentiometer gets to a certain point. And the output is not a square way but what appears to be a capacitor quickly charging and then slowly discharging. As for P1.2 even with the RXD jumper taken out nothing at all occurs I do see stray square ways but this appears to be serial communication. Got it working. Fix in bold. int analogInPin = A4; int voltage_forward = P1_2; int voltage_reverse = P1_6; //Controls the speed level int temp; // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: /* Serial.begin(9600);*/ pinMode(voltage_forward, OUTPUT); pinMode(voltage_reverse, OUTPUT); analogReference(DEFAULT); } // the loop routine runs over and over again forever: void loop() { /*int input_speed; // the input speed int temp; //temp variable input_speed= analogRead(analogInPin) * (5.0 / 1023.0); //Read the input from 0-5V temp=(input_speed >> 1) - 255; */ //Make range from -5V to 5V instead of 0V to 5V temp = analogRead(analogInPin); if(temp>=768) { analogWrite(voltage_forward, (temp>> 1) - 256); } if((256<=temp) && (temp<=768) ) { digitalWrite(voltage_reverse,LOW); digitalWrite(voltage_forward,LOW); } if(temp<256) { analogWrite(voltage_reverse, 255 - (temp>>1)); } }
  2. Quick update I just trimmed some more fat. I'm getting no PWM according to my oscilloscpe
  3. /* */ int analogInPin = P1_0; int voltage_forward = P1_2; int voltage_reverse = P1_6; //Controls the speed level // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: /* Serial.begin(9600);*/ pinMode(voltage_forward, OUTPUT); pinMode(voltage_reverse, OUTPUT); } // the loop routine runs over and over again forever: void loop() { /*int input_speed; // the input speed int temp; //temp variable input_speed= analogRead(analogInPin) * (5.0 / 1023.0); //Read the input from 0-5V temp=(input_speed >> 1) - 255; //Make range from -5V to 5V instead of 0V to 5V */ unsigned int temp = analogRead(analogInPin); if(temp>=768) { analogWrite(voltage_forward, (temp>> 1) - 256); } if((256<=temp) && (temp<=768) ) { digitalWrite(voltage_reverse,LOW); digitalWrite(voltage_forward,LOW); } if(temp<256) { analogWrite(voltage_reverse, 255 - (temp>>1)); } } I made some changes but I still have too much code. Because it compiles when I use a different board... If I switchback to the arduino board in the disable mode section I still see pulses.
  4. I recently damaged my arudino trying to bridge an H-bridge project. So as a back up I went over to the MSP430 launch pad. I have had it for maybe 1 or 2 years but have not done anything with it since how complex it appears to write a code for the MSP430. Then I heard of the energia and decided to take the following code from the arduino then to MSP430 int stby = P1_3; int fwd = P1_4; int rev = P1_5; const int analogInPin = P1_0; float voltage_forward = P1_2; float voltage_reverse = P1_6; //Controls the speed level // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: /* Serial.begin(9600);*/ pinMode(voltage_forward, OUTPUT); pinMode(voltage_reverse, OUTPUT); pinMode(fwd, OUTPUT); pinMode(rev, OUTPUT); pinMode(stby, OUTPUT); } // the loop routine runs over and over again forever: void loop() { float input_speed; // the input speed float temp; //temp variable boolean sign; input_speed= analogRead(analogInPin) * (5.0 / 1023.0); //Read the input from 0-5V temp=2*input_speed-5; //Make range from -5V to 5V instead of 0V to 5V temp=(255.0 / 5.0) *temp; if(temp>127.5) { analogWrite(voltage_forward,temp); digitalWrite(fwd,HIGH); digitalWrite(rev,LOW); digitalWrite(stby,LOW); } if(-127.4<=temp<=127.4) { digitalWrite(voltage_reverse,LOW); delay(10); digitalWrite(voltage_forward,LOW); delay(10); digitalWrite(fwd,LOW); digitalWrite(stby,HIGH); digitalWrite(rev,LOW); } if(temp<-127.5) { /*temp=-temp;*/ analogWrite(voltage_reverse,temp); digitalWrite(fwd,LOW); digitalWrite(stby,LOW); digitalWrite(rev,HIGH); } temp=temp * (5.0 / 255.0); //Calculate the value of voltage applied to the motor /******* Print the values to the Serial Monitor *******/ /* Serial.print(F("Potiemeter reading= ")); //PRINT ERROR AS A VOLTAGE Serial.print(input_speed); Serial.print(F("\tVoltage applied= ")); //PRINT ERROR AS A VOLTAGE Serial.print(temp); Serial.print(F("\n")); delay(100); // delay in between reads for stability */ } I know there are still some bugs in it but what I wanted to check if it would compile and what I got was this error message: c:/users/progra~1/docume~1/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld.exe: Project_Ported_to_MSP.cpp.elf section `.text' will not fit in region `rom' c:/users/progra~1/docume~1/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld.exe: section .vectors loaded at [0000ffe0,0000ffff] overlaps section .text loaded at [0000f800,00010169] c:/users/progra~1/docume~1/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/../../../../msp430/bin/ld.exe: region `rom' overflowed by 476 bytes c:/users/progra~1/docume~1/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3\libcrt0.a(_copy_data.o): In function `__do_copy_data': /root/mspgcc-20120406/BUILD/gcc/gcc/../../../gcc-4.6.3/gcc/config/msp430/crt0.S:195: relocation truncated to fit: R_MSP430_16_BYTE against symbol `__data_load_start' defined in *ABS* section in Project_Ported_to_MSP.cpp.elf c:/users/progra~1/docume~1/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3/crt0ivtbl16.o: In function `__isr_14': (.text+0x2): relocation truncated to fit: R_MSP430_16 against symbol `_unexpected_' defined in .text.crt0 section in c:/users/progra~1/docume~1/energi~1/hardware/tools/msp430/bin/../lib/gcc/msp430/4.6.3\libcrt0.a(_unexpected_.o) core.a(wiring_digital.c.o): In function `pinMode': C:\Users\Programing\Documents\energia-0101E0009\hardware\msp430\cores\msp430/wiring_digital.c:38: relocation truncated to fit: R_MSP430_16_BYTE against symbol `digital_pin_to_bit_mask' defined in .rodata.digital_pin_to_bit_mask section in core.a(wiring_digital.c.o) C:\Users\Programing\Documents\energia-0101E0009\hardware\msp430\cores\msp430/wiring_digital.c:39: relocation truncated to fit: R_MSP430_16_BYTE against symbol `digital_pin_to_port' defined in .rodata.digital_pin_to_port section in core.a(wiring_digital.c.o) C:\Users\Programing\Documents\energia-0101E0009\hardware\msp430\cores\msp430/wiring_digital.c:47: relocation truncated to fit: R_MSP430_16_BYTE against symbol `port_to_dir' defined in .rodata.port_to_dir section in core.a(wiring_digital.c.o) C:\Users\Programing\Documents\energia-0101E0009\hardware\msp430\cores\msp430/wiring_digital.c:48: relocation truncated to fit: R_MSP430_16_BYTE against symbol `port_to_ren' defined in .rodata.port_to_ren section in core.a(wiring_digital.c.o) C:\Users\Programing\Documents\energia-0101E0009\hardware\msp430\cores\msp430/wiring_digital.c:49: relocation truncated to fit: R_MSP430_16_BYTE against symbol `port_to_output' defined in .rodata.port_to_output section in core.a(wiring_digital.c.o) core.a(wiring_digital.c.o).debug_info+0x59c): relocation truncated to fit: R_MSP430_16_BYTE against symbol `digital_pin_to_port' defined in .rodata.digital_pin_to_port section in core.a(wiring_digital.c.o) core.a(wiring_digital.c.o).debug_info+0x5b1): relocation truncated to fit: R_MSP430_16_BYTE against symbol `digital_pin_to_bit_mask' defined in .rodata.digital_pin_to_bit_mask section in core.a(wiring_digital.c.o) core.a(wiring_digital.c.o).debug_info+0x625): relocation truncated to fit: R_MSP430_16_BYTE against symbol `port_to_output' defined in .rodata.port_to_output section in core.a(wiring_digital.c.o) core.a(wiring_digital.c.o).debug_info+0x63a): additional relocation overflows omitted from the output collect2: ld returned 1 exit status I just have a funny feeling that I can't fit the code on to this chip because of the size of the flash memory. Just a final note is that I have heard that the chip only has one counter, I have the external clock soldered on so is there a way to use that in addition to this so I also suspect this.
×
×
  • Create New...