laberning / openrowingmonitor

A free and open source performance monitor for rowing machines
https://laberning.github.io/openrowingmonitor
GNU General Public License v3.0
98 stars 19 forks source link

What is the profile for Concept2 and/or way to view raw electrical data for debugging purposes? #77

Closed JoelMahon closed 1 year ago

JoelMahon commented 1 year ago

My father and I are trying to get this working to save £140 on a PM for a Concept2 model C, apologises if there's a better place to put our questions but as far as I know github no longer has private messaging.

We have followed the installation docs right up until the end and it went fairly smoothly, as far as we can tell all we are lacking is the correct rower profile. Many of the docs reference typical values for a Concept2 (e.g. 220 for drag factor on 10 resistance) but not for every config setting.

It's worth noting we're testing this on a working Concept2 Model B that has a working PM3.

We have wired up gpio17 and gnd to the rower, then drive activity and what follows doesn't impact the web interface at all. However if we drive a few times to get rotation going and then tap the gpio17 against the Concept2's output then we can impact the web interface.

We actually have an oscilloscope and are trying to get it working but with driver issues etc. and not even sure if after we get a visual representation of the C2 output that we can turn it into settings.

In short, where possible please assist with these three things:

  1. A ready made C2 Model C resistance level 10 setting profile (I don't expect more specificity than C2 but a guy can dream right?)
  2. Is there a debug mode and how to use it? One that will let as see the gpio17 activity (it's not impossible we're connecting poorly even if we get something when tapping gpio17 and C2 out manually)
  3. How to interpret either oscilloscope data or data from bullet point 2 above. Armed with that I'd be happy to figure out and commit a Concept2 settings profile

Really just being to get anything to show up whilst actually rowing not fake tapping would be great, from there could fiddle with to improve the values, or if you can just confirm that no data at all is a sign of bad wiring or something.

Cheers again and sorry this isn't the ideal place for such a wide request.

JaapvanEkris commented 1 year ago

My father and I are trying to get this working to save £140 on a PM for a Concept2 model C, apologises if there's a better place to put our questions but as far as I know github no longer has private messaging.

I'm currently testing the new RowingEngine that is better equiped to handle the Model D, but a Model C should work with the current version of OpenRowingMonitor.

We have wired up gpio17 and gnd to the rower, then drive activity and what follows doesn't impact the web interface at all. However if we drive a few times to get rotation going and then tap the gpio17 against the Concept2's output then we can impact the web interface.

We actually have an oscilloscope and are trying to get it working but with driver issues etc. and not even sure if after we get a visual representation of the C2 output that we can turn it into settings.

As you have an oscilloscope and you aren't afraid to use it: please check the maximum voltage the Model C produces. A Model D generates 15 Volts (i.e. way more than the 3.3V a Raspberry can handle, see https://raspberrypi.stackexchange.com/questions/3209/what-are-the-min-max-voltage-current-values-the-gpio-pins-can-handle), so some simple electronics are needed to prevent the Raspberry to get hurt (for example, this circuit for an Arduino that maxes out at 5V: https://www.instructables.com/ARDUINO-MONITOR-FOR-CONCEPT2-MODEL-B-C-D/). I know that a Model C has a different sensor, but I haven't got any detailed information about the electric connection.

If you have additional information, or even a schematic, please share it with us. For the Model D, I used a small optocoupler (see https://github.com/JaapvanEkris/openrowingmonitor/blob/Backend_Redesign/docs/img/Concept2_Optocoupler.jpg)

  1. A ready made C2 Model C resistance level 10 setting profile (I don't expect more specificity than C2 but a guy can dream right?)

I am testing OpenRowingMonitor against a Model D myself. I use the following settings:

  rowerSettings: {
    numOfImpulsesPerRevolution: 6,
    maximumStrokeTimeBeforePause: 6.0,
    minimumTimeBetweenImpulses: 0.005,
    maximumTimeBetweenImpulses: 0.022,
    smoothing: 6,
    maximumDownwardChange: 0.971,
    maximumUpwardChange: 1.040,
    flankLength: 10,
    numberOfErrorsAllowed: 2,
    naturalDeceleration: 0,
    minimumDriveTime: 0.28,
    minimumRecoveryTime: 0.90,
    dragFactor: 120,
    flywheelInertia: 0.1001,
    magicConstant: 2.8
}

A model C has three magnets instead of the Model D's 6, so you probably need to set numOfImpulsesPerRevolution to 3 and change maximumTimeBetweenImpulses to 0.044 and minimumTimeBetweenImpulses to 0.010

You could set the autoAdjustDragFactor to true here as well, which is doable for the Concept2. Then it will behave pretty similar to a PM5 (and you get Bluetooth to connect to all kind of games).

  1. Is there a debug mode and how to use it? One that will let as see the gpio17 activity (it's not impossible we're connecting poorly even if we get something when tapping gpio17 and C2 out manually)

There is a debug logging. To set the debug level, go to the config.js and modify the debug level:

// Available log levels: trace, debug, info, warn, error, silent
loglevel: {
    // The default log level
    default: 'info',
    // The log level of of the rowing engine (stroke detection and physics model)
    RowingEngine: 'debug'
  },

in the same file, you can even set createRawDataFiles to true, which outputs the timings between the signals on GPIO17

You can use these commands on the command line to restart and retrieve the logs after changing the config:

restart after config changes: sudo systemctl restart openrowingmonitor

Get the status of a service: sudo systemctl status openrowingmonitor

Show the log output of a service: sudo journalctl -u openrowingmonitor

  1. How to interpret either oscilloscope data or data from bullet point 2 above. Armed with that I'd be happy to figure out and commit a Concept2 settings profile

The osciloscope generates a sinoid (at least on a PM5 and Model D). We measure the time between the peaks, which are recorded in the raw file.

Really just being to get anything to show up whilst actually rowing not fake tapping would be great, from there could fiddle with to improve the values, or if you can just confirm that no data at all is a sign of bad wiring or something.

Hope this helps...

JoelMahon commented 1 year ago

Thank you for such a thorough response. A couple amendments to my comment before I reply. I got the models mixed up and in fact we were testing a Model C but I have still my Model C as well to try in a bit (I was visiting for unrelated reasons so we gave it a go).

We were testing directly without anything to protect the Pi from the voltage 😭, I'll commit something for the readme later to add a disclaimer because there must be many folks like me with very little Pi/circuitry experience trying this. But I think we're safe because looking at the oscilloscope data it never reached a volt so maybe the C and D differ greatly in that respect? I think the spikes capped out at around 0.2v afaik. Here's data from dampening 1: concept 2 model c damper level 01 oscilloscope data.txt and 10: concept 2 model c damper level 10 oscilloscope data.txt for the Model C.

Here's footage of the oscilloscope on model C dampening 10 since the data.txts are only for a very small period of time:

https://user-images.githubusercontent.com/22608149/184608663-9b60ba52-51a3-46a5-a4d7-280282a12c19.mp4

Once I know the Model C max voltage is safe I will try your setting recommendations and report back.

JaapvanEkris commented 1 year ago

Joel,

Please report back. Please measure the voltage when you are really rowing. The Model D has some uptake issues in its generator: the first x pulses are very weak, but when the flywheel gains momentum, it will peak at 15V. Don't know if that is the case with the Model C, but I'd error on the side of caution (especially when Raspberries are a scarce device at the moment).

Abasz commented 1 year ago

I've read it here that the Model C has a coil around a metal pin that has a specific resistance value and it definitely does not have a power generator that produces the high voltages in the Model D (https://www.c2forum.com/viewtopic.php?t=106825). On the Model C sensor, I am not fully sure how it works, but I believe that when the magnet passes the coil it slightly increases the resistance that changes the voltage that change is registered by the PM.

Anyway based on the attached txt it seems that the voltage spike is not sufficient for the Rpi to register the logical high for the pin (it has a practical logical high voltage of above 1.6-1.8v but according to the specs 2.5v is where 100% that high is registered). If this is the case (i.e. voltage spike is not sufficient) you would need a logic level shifter. However, for such a low voltage I do not think a ready made board is available. So you would probably have to look for a transistor that is capable of operating under such a low voltage and build the circuit (MOSFETs are used for logic level shifting in general but npn transistors could work too, the latter is more likely to be able to operate under such a low voltage) - here are a couple of options for a level shifting: https://electronics.stackexchange.com/questions/587063/logic-level-shifter-24-12-v-to-3-3-v.

Alternatively you could try to replace the sensor with a simple reed switch (in my Chinese C2 clone machine I used something like this: https://www.conrad.com/p/pic-ms-214-3-cylindrical-reed-sensor-na-506961). I added 3 magnets and it works fine. One thing you need to look out for is that the magnets in the flywheel should have strong enough magnetic field to consistently trigger the switch.

JoelMahon commented 1 year ago

Thanks @Abasz, I think the Pi not reading analogue or being able to get a high from a low voltage was the missing piece of the puzzle to me (I'm that much of a Pi novice). My own investigations also thankfully found the Model D is 15V due to its generator that the C does not have so I think we used the oscilloscope correctly and can trust the values (and I didn't fry my Pi!).

After reading these responses I am now exploring the solutions you suggested and more, but I'm very happy to find out the main problem! I will close this issue as any further problems are not directly related and the main problem has been figured out.

thread tl;dr for future readers: the problem was that a Concept2 Model C output peaks at ~20mV when rowing at moderate intensity, even if it peaked at 50mV when rowed by an Olympian that is still far too low for the desired 2.5V to consistently read high on a RPi GPIO. So I will explore hardware solutions and report back once it is working and I will MR a C2 Model C settings profile too once I settle on those (we do have a PM at my dad's to loosely calibrate against at least.

JoelMahon commented 1 year ago

I know I closed this already but if anyone wanted a more complete conclusion: In the end I bought a restored PM3. Electronics were never my strong suit and whilst I didn't ask around very diligently, I was not able to find an expert willing to advise me on what circuit to use. And even if I got that all working, I'd need to go through the hassle of sending it to my dad and back to tweak it so that it reported the same distance/kcal as his PM3.

I think it's perfectly doable and it would have been nice to have the more Open UI I could connect to games or other, but it just wasn't worth the £100.

JaapvanEkris commented 1 year ago

Nice of you to report back and good to hear you could help your father with a restored PM3. I recognize the hurdle of electronics, it is a tough one, especial when distance is a factor, so it is a wise decission to just invest in proven equipment.

Keep on rowing!