Go Down

Topic: Reading/interpreting tach signals from treadmill (speed/incline) (Read 2 times) previous topic - next topic

drobe011

The MC-2100 has its own processor and software, which allows it to communicate with the console. This is done by a small digital signal carried by the GREEN tach wire. By entering calibration mode on the console, two alternate screens can be accessed which give information on the controller, including the status of the troubleshooting LED, motor voltage, and motor amperage. This greatly increases the amount of troubleshooting that can be done without removing the treadmill's motor hood.
Some MC-2100 controllers will have the transformer mounted on the circuit board as shown above. Other versions..........

The above is an excerpt from the 'datasheet' on page 1.  I found it crazy as well, and initially just thought it was motor noise.

Dave

Mod80

I've been working with a bag of old components and jumpers. I've got some basics on order now. Once I they are delivered I'll start trying to tap the signals sent to and from the console.

I'll keep you posted.

Attached is a pic of the mc2100.

Mod80

#7
Jan 28, 2013, 08:57 pm Last Edit: Jan 29, 2013, 03:23 am by Mod80 Reason: 1
I keep trying but I think I'm going down the wrong path.

New Speed Sketch [modified: corrected var types]
Code: [Select]
#include <TimerOne.h>

const int speedPin = 9;
const int maxDuty = 870;
const int minDuty = 164;
const int stpDuty = 0;
const int mphIntervals = 71; // guessing here
const int sensorPin = 3;
const int sensorInterruptNum = 1;
const int timeoutValue = 20;
/* variable delcorations and defaults - start */
int currentSpeed = 0;
int speedSetTo = 0;

volatile int time = 0;
volatile int time_last = 0;
volatile int timeoutCounter = 0;
volatile unsigned long rpm = 0;
volatile int pulseCount;

int currentCommand = 0;
int inputCommand = 0;
boolean newCommand = false;

void setup(){
 Timer1.initialize(50000); // initialize timer1, and set a 1/2 second period
 Timer1.pwm(speedPin, 0); // max 870 (85%)
 Timer1.attachInterrupt(callback);  // attaches callback() as a timer overflow interrupt
 
 pinMode(sensorPin, INPUT);  
 attachInterrupt(sensorInterruptNum, sensorInterrupt, RISING);
 
 Serial.begin(9600);
 pulseCount = 0;
 rpm = 0;
}

void callback(){
 
  if(newCommand){
    currentCommand = inputCommand;
    Serial.println(inputCommand);
    newCommand = false;
 
    if(currentCommand <= maxDuty){      
     
      switch(currentCommand){
        case maxDuty:
          speedSetTo = maxDuty;
          break;
        case 0:
          speedSetTo = stpDuty;
          break;
        default:
          // float newSpeed = currentCommand;
          speedSetTo = currentCommand;
          break;
      }      
      Timer1.setPwmDuty(speedPin, speedSetTo);
      Serial.print("Change speed to: ");
      Serial.println(speedSetTo);
    }      
  }
}

void sensorInterrupt(){
 time = (micros() - time_last);
 time_last = micros();  
 timeoutCounter = timeoutValue;
 rpm = 60*(1000000/time);
}

void loop(){
 if (timeoutCounter != 0){
   --timeoutCounter;
   Serial.print("RPM: ");
   Serial.println(rpm);
 }
 delay(100);
}


void serialEvent() {
 String content = "";
 char character;

 while(Serial.available()) {
     character = Serial.read();
     content.concat(character);
 }

 if (content != "") {
     inputCommand = content.toInt();
     newCommand = true;
 }
 
}



Serial output:
Code: [Select]
376
Change speed to: 376
RPM: -18218
RPM: -1803
RPM: -1803
RPM: 254
RPM: 254
RPM: 516
RPM: 516
RPM: 516
RPM: 516
RPM: 516
RPM: 516
RPM: 516
RPM: 516
RPM: 66
RPM: 66
RPM: 66
RPM: 66
RPM: 66
RPM: 66
RPM: 66
RPM: 5653
RPM: 604
RPM: 604
RPM: 604
RPM: 604
RPM: 604
RPM: 604
RPM: 604
RPM: 604
RPM: 604
RPM: 604
RPM: 60
RPM: 60
RPM: 60
RPM: 60
RPM: 60
RPM: 60
RPM: 60
RPM: 60
RPM: 60
RPM: 60
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 57
RPM: 41
RPM: 41
RPM: 41
RPM: 41
RPM: 41
RPM: 41
RPM: 41
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 80
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 25
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
RPM: 18
445
Change speed to: 445
RPM: 2
RPM: 2
RPM: 22321
RPM: -12905
RPM: -7907
RPM: -1977
RPM: 23749
RPM: 7816
RPM: 13829
RPM: 4188
RPM: -21026
RPM: -9121
RPM: 21157
RPM: 31267
RPM: 4886
RPM: -32388
RPM: 7993
RPM: 4789
RPM: 7816
RPM: -23930
RPM: 3765
RPM: 2028
RPM: 4082
RPM: -23930
RPM: 22852
RPM: 2645
RPM: 30617
RPM: 1840
RPM: 13229
RPM: -9121
RPM: 30364
RPM: -32054
RPM: -31904
RPM: 1699
RPM: -13885
RPM: 3358
RPM: 1213
RPM: -26269
RPM: -20778
RPM: 6542
RPM: 2645
RPM: 3859
RPM: 741
RPM: 1741
RPM: 1728
RPM: 1874
RPM: 13979
RPM: 1245
RPM: 5131
RPM: 1271
RPM: 716
RPM: 936
RPM: 14251
RPM: 1681
RPM: 3604
RPM: 3826
RPM: 22852
RPM: 4096
RPM: 4865
RPM: 8871
RPM: 30005
RPM: -12145
RPM: -24553
RPM: 2957
RPM: 513
RPM: -24886
RPM: -24886
RPM: 302
RPM: 29411
RPM: 410
RPM: 15608
RPM: 3357
RPM: -31904
RPM: -7907
RPM: 23474
RPM: 12647
RPM: 4043
RPM: 7816
RPM: 9114
RPM: 1780
RPM: 604
RPM: 20862
RPM: 603
RPM: 611
RPM: 1202
RPM: 1202
RPM: 401
RPM: 405
RPM: 3795
RPM: 1642
RPM: 1642
RPM: 1224
RPM: 1224
RPM: 1844
RPM: 1163
RPM: 4534
RPM: -881
RPM: 7816
RPM: 31380
RPM: 935
RPM: 935
RPM: 323
RPM: 323
RPM: 1202
RPM: 1186
RPM: 1186
RPM: 1234
RPM: 1159
RPM: 605
RPM: 1173
RPM: 1173
RPM: 1130
RPM: 1130
RPM: 1753
RPM: 522
RPM: 1731
RPM: 397
RPM: 397
RPM: 397
RPM: 397
RPM: -1977
RPM: 1955
RPM: 530
RPM: 500
RPM: 1804
RPM: 362
RPM: 362
RPM: 362
RPM: 362
RPM: 362
RPM: 362
RPM: 103
RPM: 103
RPM: 103
RPM: 199
RPM: 199
RPM: 355
RPM: 13158
RPM: 3309
RPM: 1829
RPM: 1829
RPM: 300
RPM: 607
RPM: 3661
RPM: 4059
RPM: 4059
RPM: 276
RPM: 605
RPM: 1134
RPM: 1134
RPM: 1134
RPM: 1210
RPM: 1210
RPM: -29305
RPM: -11072
RPM: 713
RPM: 902
RPM: 403
RPM: 1197
RPM: 1197
RPM: 1197
RPM: 1197
RPM: 1197
RPM: 1197
RPM: 1197
RPM: 1197
RPM: 1197
RPM: 66
RPM: 1205
RPM: 4342
RPM: 697
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 366
RPM: 42
RPM: 42
RPM: 258
RPM: 894
RPM: 894
RPM: 1205
RPM: 720
RPM: 514
RPM: 604
RPM: 604
RPM: 297
RPM: 297
RPM: 403
RPM: 403
RPM: 403
RPM: 403
RPM: 403
RPM: 403
RPM: 403
RPM: 403
RPM: 403
RPM: 403
RPM: 57
RPM: 1290
RPM: 1290
RPM: 1290
RPM: 1290
RPM: 1290
RPM: 1290
RPM: 1290
RPM: 1253
RPM: 1253
RPM: 1253
RPM: 1253
RPM: 149
RPM: 149
RPM: 149
RPM: 149
RPM: 149
RPM: 120
RPM: 120
RPM: 120
RPM: 120
RPM: 120
RPM: 120
RPM: 92
RPM: 92
RPM: 92
RPM: 200
RPM: 1129
RPM: 1129
RPM: 1129
RPM: 172
RPM: 172
RPM: 172
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 199
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 20
RPM: 51
RPM: 51
RPM: 51
RPM: 51
RPM: 51
RPM: 51
RPM: 51
RPM: 79
RPM: 79
RPM: 79
RPM: 79
RPM: 79
RPM: 79
RPM: 79
RPM: 79
RPM: 79
RPM: 79
RPM: 59
RPM: 59
RPM: 59
RPM: 59
RPM: 59
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 26132
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
RPM: 30
0
Change speed to: 0

PaulS

Code: [Select]
  rpm = 60*(1000000/time);
Constants are treated as ints, unless you specify otherwise. 1000000 doesn't look like it will fit in an int, does it?

1000000UL, on the other hand, will easily fit in an unsigned long.

Code: [Select]
  time = (micros() - time_last);
  time_last = micros(); 

Why the hell are thse floats? Time is integral.

Mod80

Code: [Select]
  rpm = 60*(1000000/time);

Had rpm set as float in one of my last test when converting. Decided print the full value but forgot to change the type.

Code: [Select]

  time = (micros() - time_last);
  time_last = micros();


Bad copy/paste job from: http://www.pyroelectro.com/tutorials/tachometer_rpm_arduino/software.html

Good catches both but even with those changes I seem to get some crazy readings. For instance, sensorInterrupt isn't even called until I push to what I'm assuming is close to 4 mph.

- thanks

Go Up