Remote inc coolant nozzle control program
Dependencies: mbed reScale USBDevice
Dependents: Nozzle_inputs Nozzle_display
Diff: main.cpp
- Revision:
- 22:a3ada529b264
- Parent:
- 21:db507362ca7a
- Child:
- 23:baedb9e32b6d
- Child:
- 24:55fafbb82a37
--- a/main.cpp Wed Apr 10 23:23:13 2019 +0000 +++ b/main.cpp Thu Apr 11 23:22:45 2019 +0000 @@ -25,7 +25,7 @@ int maxServo = 2500; int minServo = 500; -reScale servo1Scale(45,0,minServo,maxServo); //19850 is 1.0v from voltage divider at 10k. +reScale servo1Scale(90,-90,minServo,maxServo); //19850 is 1.0v from voltage divider at 10k. PwmOut servo1(P1_13); //display board @@ -42,7 +42,7 @@ int lastTwitchMove = 0; int maxTwitch = 0; int minTwitch = 0; - int tReadMs = 50; + int tReadMs = 10; int currentNozzle = 0; @@ -189,8 +189,9 @@ Hundreds = 0; index = 3; +} - } else if (c == '2') { //N2 + else if (c == '2') { //N2 currentNozzle = 1; Hundreds = 1; index = 3; @@ -356,26 +357,26 @@ lastTwitchMove = t.read_ms(); // store time of last nozzle movement minTwitch = servo1Pos; // store original servo postion for bottom of sweep if (twitch == 1) { - maxTwitch = servo1Pos + 150; // 11.11mS per degree of sweep, 55 = 5 degrees of sweep. This should be a viariable set on the display. + maxTwitch = servo1Pos - 100; // 11.11mS per degree of sweep, 55 = 5 degrees of sweep. This should be a viariable set on the display. } if (twitch == 2) { - maxTwitch = servo1Pos + 200; + maxTwitch = servo1Pos - 150; } if (twitch == 3) { - maxTwitch = servo1Pos + 250; + maxTwitch = servo1Pos - 200; } twitchStart = 1; } if ((twitchStart == 1) && (t.read_ms() > (lastTwitchMove + tReadMs))) { if (twitchDirection == 0) { //going up - servo1Pos = servo1Pos + 25; // add variable amount of uS to the servo signal + servo1Pos = servo1Pos - 10; // add variable amount of uS to the servo signal - if (servo1Pos > maxServo) { - servo1Pos = maxServo; + if (servo1Pos < minServo) { + servo1Pos = minServo; twitchDirection = 1; //reverse direction } - if (servo1Pos > maxTwitch) { + if (servo1Pos < maxTwitch) { servo1Pos = maxTwitch; twitchDirection = 1; //reverse direction } @@ -383,12 +384,12 @@ } if (twitchDirection == 1) { // going down - servo1Pos = servo1Pos - 25; // add variable amount of Ms to the servo signal - if (servo1Pos < minServo) { - servo1Pos = minServo; + servo1Pos = servo1Pos + 10; // add variable amount of Ms to the servo signal + if (servo1Pos > maxServo) { + servo1Pos = maxServo; twitchDirection = 0; //reverse direction } - if (servo1Pos < minTwitch) { + if (servo1Pos > minTwitch) { servo1Pos = minTwitch; twitchDirection = 0; //reverse direction }