Skip to content

blekenbleu/Direct-Drive-harness-tension-tester

Repository files navigation

other content

clone this in SimHub\PluginSdk\:

SimHub plugin for Direct Drive harness tension control

with Arduino STM32 Plue pill sketch and SimHub Custom Serial profile for scooter motor PWM torque control:

...these employ an evolved Fake8 SimHUb plugin to send 8-bit commands to an Arduino sketch.

Several Sim racing harness tensioners use either stepper motors or hobby/robot servo motors,
either choice being IMO suboptimal:

  • gears generate noise and kill responsiveness
  • neither directly applies tension; they instead simply move some amount.

A few tensioners already use PWM control of DC motors, where PWM % directly relates to stall torque (tension).
A stalled electric motor generates no back EMF, consequently needing much lower than rated motor Voltage.
Electric scooter motors seemingly deliver appropriate torque for direct drive harness tensioning, as discussed here.
Lebois Racing also has a scooter motor tensioner for SimHub and video


... driven by BTS7960 43A Motor Drivers:

Since scooter motors are NOT designed for use as traction motors,

      (data for 350W motor;  rescale for 250W (5/7))

... some information is lacking to use mostly stalled:

  • What PWM frequency minimizes coil whine while not compromising torque control?
  • What range of PWM values is safe and useful?
  • How responsively can tension (motor torque) slew?
    Substantial changes will involve appreciable shaft rotation, generating back EMF.
  • Is predistortion/preemphasis wanted for more responsive torque application and release?

Testing will employ this waveform, sampled at SimHub 60Hz rate:

At least 9 controls are wanted for testing:

  • test period (60 = 1 second)
  • rise time (0 to period/3)
  • hold time (0 to period/3)
  • fall time (0 to period/3)
  • max signal magnitude
  • min signal magniitude

Up to 5 signals to Blue Pill:

  • Testing sample values driving PWM %

  • PWM frequency   ( ~ 20kHz?)

  • predistortion amplitude (% of sample value changes) to compensate slew rate limits:

         

  • predistortion duration (Blue Pill Arduino loop() cycle count)
    worst case, scooter motor may want brief negative predistortion to relax tension,
    consuming both sides of an "H" PWM driver per motor:

  • optional reference measurements to echo, along with sample values,
    for capture from SimHub "Incoming serial data" e.g. to plot, where reference tension measurements may be captured from a sim brake pedal load cell.

This wants multi-byte control for SimHub Custom serial devices to handle that many variables.

Fake8 SimHub plugin drives PWM_FullConfiguration

16 Mar 2023 A derivative plugin will add test waveform by Bresenham Line Generation, minimizing discontinuity:

  • changes increasing amplitude will start in ramp-up section
  • changes decreasing amplitude start in ramp-down section
  • receipt of a control change from Custom Serial profile will cause Parse() to set a Change flag
  • true == Change will cause interval and slope recalculations at the next DataUpdate() invocation.

Fake8 migration

20 Mar 2023:  begin scheming for Bresenham PWM modulation
21 Mar 2023:  copied source files:

  • .gitignore
  • Fake7.cs
  • Fake8.cs
  • Fake8.csproj
  • NCalcScripts/F8.ini
  • Bresenham.md
    New, to modulate Arduino PWM:
  • Test.cs   compiled, but not tested

Visual Studio: project.assets.json not found

  • cmd.exe shell:  > dotnet restore
  • VS 2019 will not debug builds until a .cs file is displayed.

23 Mar 2023 "full function" plugin debugging

  • stepping thru code seems (mostly) OK...
  • many Custom Serial setting changes get ignored while Test runs
    • Custom Serial messages eventually get handled, but it may take minutes.
    • unplugging Arduino USB posts error, then Custom Serial messages get handled
    • posted Arduino I/O operation abort message to Custom Serial...
      • post in AndroidDataReceived() exception hung SimHub in while(ongoing) ReadExisting() loop
      • post in Recover(), during DataUpdate(), is OK...
  • speculation:  extra (serial port receive) threads running in plugin confound SimHub
    • adding Thread.Sleep(8) in ReadExisting() loops did not help.
    • alternative: read once per invocation on main thread, buffer until message end characters...?
  • Moving Arduino.ReadExisting() to the DataUpdate() thread provokes CustomSerial.Write() timeouts
  • also changing CustomSerial.ReadExisting() to that thread made both serial ports robust.

24 Mar 2023 single branch

For debugging, Test will execute a single extended cycle,

  • starting count at climb+hold+fall, continuing thru period and climb and ending at the next period
  • this will e.g. simplify capturing results for gnuplot
  • prototyping preemphasis filtering will be faster and easier in Test class of the plugin than in Arduino.
  • two controls (amplitude, time constant) by 3 sliders:  rational values <= 1.
    • one for positive integer numerator
    • one for each denominator non-negative integer added to numerator

About

Arduino sketch and SimHub plugin for PWM scooter motor torque

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages