Note de ce sujet :
  • Moyenne : 0 (0 vote(s))
  • 1
  • 2
  • 3
  • 4
  • 5
Attempt at cheap homemade version of Harmony
#71
Turns out there was a problem with the calculations. Very useful to be able to transmit values to my phone via Bluetooth for live monitoring will riding. This equation for the multiplier ((sin(((Power+powerPrev)/2)/-560))*7)+17 wasn’t working correctly without being fed a float. The change in cadence was due to cadence correction as only the cadence setting equation was working.
With that fixed I then had to fine tune the cadence correction equation to work more smoothly with the ever changing cadence setting. This is where my experiments with PID came in useful. By reducing the amount of proportional and adding the right amount of integral I got rid if the oscillations. These graphs below show the difference between having cadence correction and not.

[Image: bunyA6.jpg] [Image: bwj0bO.jpg]
 
Example of some data recorded, the blue and purple stay pretty close together which makes for an amazing ride experience. Because I’ve become very sensitive to my cadence I can actually estimate my power out by the rpm of my legs.
[Image: yoajca.jpg] [Image: FoHx5N.jpg]
 
I’ve also used what I’ve learnt from this to improve the cadence correction for the constant cadence, no power meter, mode. Always had problems with oscillations at high cadences and sometimes if I changed the cadence setting. Also because the relationship between cadence and multiplier isn’t linear it made sence to have the proportional part of the PID change depending on the multiplier. The result is much smoother operation and no more oscillations. How much better can I make the code. Of course if I get a new hub I’ll probably have to reconfigure everything.
- Oran
Répondre
#72
PID Tuning
Whilst I’ve been doing a more in depth review of Harmony I have switched between different hubs. Each hub has a different amount of slack, shift range and multipliers used. This got me thinking about the values used in the PID of the cadence correction or in my case just the P and I. Maybe it was time I learnt more about PID tuning so I can get it the work as smoothly with the newer N360 as the worn N380.
The basics of PID tuning are to increase P until oscillations occur, half it, then add in as much I and or D without making things become unstable again.  I set off on a ride and had a go at improving the values used with the N380. Here are some screenshots I captured during the process.

Red – cadence, Green – cadence setting, Blue – speed, Orange – battery % (affected by current), Light blue – P + I, Grey  - P and Black – I.
Just P but to much
[Image: GMww6R.png]
Too much I
[Image: Q5fihT.png] 
Too much of both
[Image: Ef2bf3.png]
Just about right
[Image: MubIaq.png] 
The result was that I ended up with the same values as I started with.

Loop speed
Ever since early on in the project I have used half a second for the loop delay and never tried increasing it. After some experimenting it turns out it really doesn’t make any noticeable difference increasing it. The accuracy of the shifting is mostly limited by the servos speed and ability to shift under load. The natural oscillation of my legs and the auto shifter due to too much gain remained similar, 3 seconds +- ½ a sec. So at the end of this turns out things were about optimum but have learnt a lot about setting it up for different hubs.
- Oran
Répondre


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)