Jump to content

Arch_ETS

Members
  • Content Count

    15
  • Joined

  • Last visited

  1. Arch_ETS

    Giveaway Winners: MSP430 F5172 SchmartBoard

    Awesome, time to advance from G2553. Will PM you right now. Thanks. Regards, Arch.
  2. Arch_ETS

    Tachometer. Resolution vs speed issues.

    Here is the latest code, cannot check if it works properly, but I already have questions. Are there any benefits from detaching interrupt while calculations, lcd stuff, adc and so on are going on, and then re-attaching it? What are benefits using float over double? Isn't double more friendlier data type to MCU? Also, is it worth doing less important stuff less frequently by doing as in following code? Is that even "legal"? /Sorry for stupid questions./ EDIT: Edited all code, for better clarity. #include <LiquidCrystal.h> LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5); //RS,EN,D4,D5,D6,D7 const byte coilpin = P1_3; /*input/interrupt pin.*/ const byte sampletime = 300.0; /*adjust for speed/accuracy.*/ const byte carbswitch = P1_0; /*switch from carburator, when accelerator is not pushed, switch is connected to GND. When accelerator is getting floored, disconnects from GND. Internal PULLUP enabled for this pin.*/ const byte outputswitch = P1_1; /*enables/disables gas valve, HIGH at >1400 RPM and carbswitch HIGH. MSP430 -> 2N7000 -> Power Mosfet -> Valve(s). [Accelerator swich LOW -> MSP430 Output HIGH (if RPM > 1400)-> 2N7000 output LOW, Power FET off, valve closed]*/ const byte shiftlight = P1_2; /*enabled when RPM > 4900.*/ const byte engineok = P1_4; /*enabled when 5000 > RPM > 500.*/ const byte heateroutput = P1_5; /*if engine (manifold) temperature is lower than defined one, intake manifold heater is turned on. I am not sure yet if I will use it with time delay circuit (like 10 seconds on, then off) or control it only with lm36 readings.*/ const byte lm36engine = P1_6; /*lm36 analogue temp sensor, measures engine temperature.*/ const byte voltagepin = P1_7; /*monitors battery voltage through voltage divider 10k/47k.*/ int carbswitchstate; /*P1_0 state.*/ int valvestate = LOW; /*P1_1 state, also determines econstr value.*/ int RPM; String econstr; volatile unsigned long timeold; volatile unsigned long timenow; volatile unsigned long duration; unsigned long disp_timeold = 0.0; unsigned long timetemp = 0.0; void setup() { lcd.begin(16, 2); attachInterrupt(coilpin, RPM_fun, FALLING); pinMode(outputswitch, OUTPUT); pinMode(heateroutput, OUTPUT); pinMode(shiftlight, OUTPUT); pinMode(engineok, OUTPUT); pinMode(carbswitch, INPUT_PULLUP); pinMode(lm36engine, INPUT); pinMode(voltagepin, INPUT); } void loop() { timetemp = millis() - disp_timeold; if( timetemp >= sampletime) { detachInterrupt(coilpin); disp_timeold += timetemp; float RPMtemp = 30000000.0/duration; /*2 pulses per revolution*/ int RPM = (RPMtemp - RPMtemp/100.0*3.84)*1000; /*there was some error, so this is pretty dumb way to remove it, but it works. Kind of.*/ /*switches*/ carbswitchstate = digitalRead(carbswitch); if (RPM > 1400.0 && carbswitchstate == LOW) { digitalWrite(outputswitch, HIGH); } else { digitalWrite(outputswitch, LOW); } valvestate = digitalRead(outputswitch); if (valvestate == HIGH) { econstr = ("ON"); } else { econstr = ("OFF"); } /*LCD*/ lcd.clear(); lcd.print("RPM="); lcd.print(RPM,0); lcd.setCursor(0, 1); lcd.print ("ECON="); lcd.print(econstr); attachInterrupt(coilpin, RPM_fun, FALLING); } if( timetemp >= 10*sampletime) { int ADCValueEng = analogRead(lm36engine); float VEng = (ADCValueEng * 3.3)/1024; float TempEng = (VEng - 0.5) * 100; int ADCVoltage = analogRead (voltagepin); float tmpvoltage = (ADCVoltage * 3.3)/1024; float voltage = tmpvoltage * 5.7; if (RPM > 4900.0) { digitalWrite(shiftlight, HIGH); } else { digitalWrite(shiftlight, LOW); } if (RPM > 500.0 && RPM < 5000) { digitalWrite(engineok, HIGH); } else { digitalWrite(engineok, LOW); } if (TempEng < 15.0) { digitalWrite(heateroutput, HIGH); } else { digitalWrite(heateroutput, LOW); } lcd.setCursor(9, 0); lcd.print (" U="); lcd.print(voltage,1); lcd.print("V"); lcd.setCursor(9, 1); lcd.print (" T="); lcd.print(TempEng,0); lcd.print("C"); } } void RPM_fun() { timeold = timenow; timenow = micros(); duration = timenow-timeold; }
  3. Arch_ETS

    Tachometer. Resolution vs speed issues.

    Unfortunately I destroyed my only G2553 chip by connecting VccMSP to VccLCD (5v). (Yes, stupid mistake). But I will definitely try your suggestion, when I will receive parts and MCU chip. Thanks for response, Maldrax.
  4. Arch_ETS

    Tachometer. Resolution vs speed issues.

    Okay, thanks, calinp. I don't really know what did I do, but now it works a lot better, have not tested yet in real life, but with computer/audacity as signal generator it works fine, here is the new code. #include <LiquidCrystal.h> LiquidCrystal lcd(P1_2, P1_1, P1_4, P1_5, P1_6, P1_7); //RS,EN,D4,D5,D6,D7 const int coilpin = P1_3; //input/interrupt pin const int sampletime = 300.0; //adjust for speed/accuracy const int carbswitch = P2_2; //switch from carburator, when accelerator is not pushed, switch is connected to GND. When accelerator is getting floored, disconnects. const int outputswitch = P2_4; //enables/disables gas valve, HIGH at >1400 RPM and carbswitch LOW. const int shiftlight = P2_5; //enabled when RPM > 5000. const int engineok = P2_3; //enabled when RPM > 500. int carbswitchstate = LOW; int valvestate = LOW; int mymilis = 300; String ds; volatile unsigned long timeold; volatile unsigned long timenow; volatile unsigned long duration; unsigned long disp_timeold = 0.0; unsigned long timetemp = 0.0; void setup() { lcd.begin(16, 2); attachInterrupt(P1_3, RPM_fun, FALLING); pinMode (outputswitch, OUTPUT); pinMode (shiftlight, OUTPUT); pinMode (engineok, OUTPUT); pinMode(carbswitch, INPUT_PULLUP); } void loop() { timetemp = millis() - disp_timeold; if( timetemp >= sampletime) { detachInterrupt(P1_3); disp_timeold += timetemp; float RPMtemp = 30000000.0/duration; //2 pulses per revolution float RPM = RPMtemp - RPMtemp/100.0*3.84; //there was some error, so this is pretty dumb way to remove it, but it works. Kind of. //switches// carbswitchstate = digitalRead(carbswitch); if (RPM >= 1400.0 && carbswitchstate == HIGH) { digitalWrite(outputswitch, HIGH); } else { digitalWrite(outputswitch, LOW); } valvestate = digitalRead(outputswitch); if (valvestate == HIGH) { ds = ("ON"); } else { ds = ("OFF"); } if (RPM >= 5000.0) { digitalWrite(shiftlight, HIGH); } else { digitalWrite(shiftlight, LOW); } if (RPM >= 500.0) { digitalWrite(engineok, HIGH); } else { digitalWrite(engineok, LOW); } //end of switches// lcd.clear(); lcd.print(" RPM="); lcd.print(RPM); lcd.setCursor(0, 1); lcd.print (" ECON="); lcd.print(ds); attachInterrupt(P1_3, RPM_fun, FALLING); } } void RPM_fun() { timeold = timenow; timenow = micros(); duration = timenow-timeold; }
  5. Hello everyone. I am more of a hardware dude, so software always makes me stay up all nights while trying to understand why it doesn't work and why DOES it work. Anyway, below is the code I am using. It works, kind of, but there is a problem. If I decrease delay, resolution goes down pretty bad, with 300ms it is 100RPM. If I Increase, of course it gets slow, and that is not ok in my application. As I am a total noob, I hope someone here might give me advice, what can I possibly do. Regards, Arch. volatile unsigned int rpmcount; float rpm; float timeold; const int carbswitch = P2_2; //switch from carburator, when accelerator is not pushed, switch is connected to GND. When accelerator is getting floored, disconnects. const int outputswitch = P2_4; //enables/disables gas valve, HIGH at >1400 RPM and carbswitch HIGH. const int shiftlight = P2_5; //enabled when RPM > 5000. const int engineok = P2_3; //enabled when RPM > 500. int carbswitchstate = LOW; int valvestate = LOW; int mymilis = 300; String ds; #include <LiquidCrystal.h> LiquidCrystal lcd(P1_2, P1_1, P1_4, P1_5, P1_6, P1_7); void rpm_fun() { rpmcount++; } //INPUT from ignition coil's switching GND is wired to P1_3, with protection from high voltage spikes. void setup() { lcd.begin(16, 2); attachInterrupt(P1_3, rpm_fun, FALLING); rpmcount = 0.0; rpm = 0.0; timeold = 0.0; pinMode (outputswitch, OUTPUT); pinMode (shiftlight, OUTPUT); pinMode (engineok, OUTPUT); pinMode(carbswitch, INPUT_PULLUP); } void loop() { if(millis()-timeold>=mymilis){ detachInterrupt(P1_3); const float freqHz = ((float) rpmcount / (float) (millis() - timeold)) * 1000.0; const float rpm = freqHz * 30.0; rpmcount = 0; carbswitchstate = digitalRead(carbswitch); if (rpm >= 1400.0 && carbswitchstate == HIGH) { digitalWrite(outputswitch, HIGH); } else { digitalWrite(outputswitch, LOW); } valvestate = digitalRead(outputswitch); if (valvestate == HIGH) { ds = ("ON"); } else { ds = ("OFF"); } if (rpm >= 5000.0) { digitalWrite(shiftlight, HIGH); } else { digitalWrite(shiftlight, LOW); } if (rpm >= 500.0) { digitalWrite(engineok, HIGH); } else { digitalWrite(engineok, LOW); } lcd.clear(); lcd.print("RPM="); lcd.print(rpm); lcd.setCursor(0, 1); lcd.print ("ECON="); lcd.print(ds); attachInterrupt(P1_3, rpm_fun, FALLING); timeold = millis(); } }
  6. Whoa, pretty impressive. Is it functioning fine? Really interesting project. Isn't PWM stressing battery somehow? EDIT: I was reading code, probably it is just lack of my knowledge, but in code R7resistor - 4650, while in schematic 5600ohm. :? EDIT2: So, I managed to blow up my ATX three times in a row, but fixed that only twice. Luckily I got one more. Meanwhile I was checking LCD code, and Polish character stuff (commented one) was unclear for me. I wanted to add some Latvian chars, like ? {0x1F, 0x000, 0x1F, 0x11, 0x1F, 0x11, 0x11, 0x000};, but couldn't compile, got an error about "const char". So I changed it to just "char". Then it compiled fine. What else should I do to successfully print out these chars on LCD?
  7. Hello, I am usually dealing with hardware, so I have no idea what I am doing when it comes to software. Of course I've done Hello World, and other simple tasks, but now I need (ok, want) to build a IR controlled volume control. Currently I won't even try to think out about Infrared stuff, but about controlling digital potentiometer. I've soldered DS1802 based pot, with LME49720 buffer. Works fine with DS1802 push-button interface. Before jumping into IR receiver/transmitter stuff I would like to get it working in following way [pushbuttons->launchpad->ds1802], but the problem is that I have no idea where to start. DS1802 datasheet states that: "The interface consists of three input signals which include RST, CLK and D." So CLK is a clock from Launchpad, RST is signal which determines when D sends data to DS1802? So when I push a button on MSP, RST have to come high? If we presume that I know 3-wire basics, how do I "make launchpad send these magic 16-bits" to DS1802? Yeah, funny questions. I know, can't build anything with no knowledge, so would be good to receive some suggestions where should I start to dig. USI examples? Also about bit shifting.. In the end it should be like (MSP+IR transmitter) ~ (IR receiver + MSP+ DS1802) I hope that someone will understand at least a part of this mumbo-jumbo I just wrote.
  8. Arch_ETS

    CIR - Infrared remote decoder for NEC protocol

    Led is constantly on for me, no idea why.
  9. Arch_ETS

    Volt/Amp/Watt meter

    Just awesome. Thanks for sharing!
  10. Arch_ETS

    MSP430 PC GUI Eval Tool

    Nice to hear that project hasn't stopped Will wait for any updates. Thanks for effort made, Nate.
  11. Arch_ETS

    SD Media Player with FAT16

    I don't know why, but my microSD died, I used microSD to SD adapter, double checked everything, but no success. Then I removed it, and non of readers detect it anymore.
  12. Arch_ETS

    MSP430 PC GUI Eval Tool

    Username, it worked just great before this. I never had any problems with connection. I guess this is just not my day
  13. Arch_ETS

    MSP430 PC GUI Eval Tool

    Something strange happened with my Launchpad. EvalTool can't connect to it anymore, although it connect previously without any problems. Tried a lot of times, but only thing that happens - it throws out this -> "
  14. Arch_ETS

    MSP430 PC GUI Eval Tool

    That's great to hear I am facing a lot of problems to make my Launchpad do something I want (beginner in MCUs, used to analogue electronics), and your tool is great for me, to try some relay/mosfet controlling and etc. For example, now I hooked up my hybrid amplifier to Launchpad and I use digital outputs coupled to mosfets to a) switch on tube heaters HV supply for tube stage c) Power stage :geek: When I'll get temperature sensor, I might use it to see how hot it gets and then to switch on a fan which would be regulated by PWM tab
  15. Arch_ETS

    MSP430 PC GUI Eval Tool

    Hello, Well done! This is really useful project. I hope that your future developments will improve it. I was wondering, is it possible to create software kind-of-PWM (more like pulse) at digital output tab? Slider or textbox to adjust how many times it turns output on/off? Would be useful to test some motor drives or something like that. Anyway, good luck!
×