Jump to content

Pebble App and Data Logger for King Song [RELEASED]


JumpMaster

Recommended Posts

22 hours ago, JumpMaster said:

HI @HEC

I'm really curious about the usefulness of this.  I've only had an over-current situation happen from a standing start and it happens almost instantly without any time for a warning.  Also from looking at my graphs (from memory) current spikes are very quick and not related to speed. For example hitting a pot hole or climbing a short but steep kerb so I don't think I would be able to usefully react to an alarm.

Adding a Power Alarm with current (up to 40A), speed, and battery isn't an issue.  With a different vibrate tone too.

What speed, current, and battery level would you set the alarm to? Would you want 1 or 3 different alarms like speed? (released in version 1.5.1 last night)

Kev

I did some analisys uploading in Excel and the KDanger I calculate takes out the spikes at low speed, as Height is proportional to speed^2, so as KDanger=f(Speed^2)/g(current margin) if due to a current spike the Amargin is low but the speed is low too the speed wins and the result is a low number for KDanger, while a low current margin at higher speed give a you Numbers more significative.

If you're interested I can attach the xlsm with the VBA , but tomorrow

EDIT:

Cattura.JPG

Cattura.JPG

 

WheelLogMaster.xlsm

Cattura.JPG

Link to comment
Share on other sites

  • Replies 236
  • Created
  • Last Reply
11 hours ago, JumpMaster said:

Are you using a KingSong wheel? If so both the distance and time are straight from the wheel.

Yes, Kingsong KS-16 680 Wh. I will try to compare more with native app, but it was looking like logging correctly before.

Link to comment
Share on other sites

@HEC

I've added an average battery calculation.  I took a very simple approach and it appears to be working well.  Here's this mornings journey.  It's a short journey down hill (2-3 minutes) followed by a kilometre up hill.  I stop shortly to cross a road (battery shows at 79% and average is very close), followed by some more up hill work.

https://docs.google.com/spreadsheets/d/1CKK1UiDgCmvbKp_hDO8f_Ff5Bbr0msd7JZwd5WYKhb8/pubhtml

There is such a wide swing in the live battery levels from 43% to 100% but the average is between 64% and 86% which is a big improvement.  I would not want it to replace the live battery level as it will give an accurate reading once the wheel is stationary where as the average could take 30 seconds to catch up.  My current average is based on the last 150 results which is 30 seconds of data.  KingSong and Gotway only update at 5Hz and not 10Hz as previously thought.

number_of_data_points = number_of_data_points + 1

if number_of_data_points > maximum_data_points
  number_of_data_points = maximum_data_points

average = average + ((new_result - average) / number_of_data_points)

 

@EricGhost

That is some amazing calculations. I look forward to running my morning commute though London on it and seeing my Danger K values :D

Link to comment
Share on other sites

36 minutes ago, JumpMaster said:

average = average + ((new_result - average) / number_of_data_points)

I'm a bit lost about above calculation / code line ... :unsure: Does it suppose to calculate new average based on previous + new momentary value?

In regards of the averaging some values (Battery Voltage / capacity percentage and current / Power mainly) I'd still prefer to have an option to set amount of samples from which is the average calculated so it can be tweaked up by user to meet his/her needs. The average value shall be used only for the purpose of the advanced / "power" alarms and all other values (stored in the logs or displayed) shall be momentarily ones as it's not problem to calculate anything you want from logs later on anyway. And to make it even simple for the lower amount of samples from which is the average calculated it doesn't need to calculate it and evaluate the alarm until the FIFO buffer is full as it will happen only for first few seconds after connection to the wheel is established.

Link to comment
Share on other sites

5 hours ago, HEC said:

I'm a bit lost about above calculation / code line ... :unsure: Does it suppose to calculate new average based on previous + new momentary value?

Yes it's a rolling average calculation.  Not as accurate as creating an array/FIFO object but more than accurate enough for it's purpose.

I agree this should only be used for the 3 speed alarms and not for any logged or presented data.  I'm looking into how to create an "Advanced Alarm" where a raw calculation can be typed in.

Link to comment
Share on other sites

7 minutes ago, JumpMaster said:

Yes it's a rolling average calculation.  Not as accurate as creating an array/FIFO object but more than accurate enough for it's purpose.

I'm not sure if that really suitable for your app though as the values can jump all over the place ... I'd assume it's more for situations where fluctuations between individual consequent momentarily values are within certain limits.

I'd expect there to be some ready-made library with FIFO buffer implementation so all it's needed is to fill up the FIFO with first N values after connecting (suspend the Power / Advanced alarms during that time) and as you push momentarily values to FIFO add them to Total and once they start getting out deduct them, Divide Total by N and you have pretty accurate average. I guess this could be tested first without any actual coding by simply taking data from Log file and calculating both Rolling as well as Normal average values for data set and compare ;) 

Link to comment
Share on other sites

17 minutes ago, JumpMaster said:

I'm looking into how to create an "Advanced Alarm" where a raw calculation can be typed in.

It would be nice to be able to type in some simple formulas with basic arithmetic operations with symbols for momentarily and average values like S for speed, CM / CA (PM / PA) for momentarily / average Current (or Power) and so on. Question is how much it would slow down the processing.

Link to comment
Share on other sites

3 hours ago, HEC said:

It would be nice to be able to type in some simple formulas with basic arithmetic operations with symbols for momentarily and average values like S for speed, CM / CA (PM / PA) for momentarily / average Current (or Power) and so on. Question is how much it would slow down the processing.

Hardly any slow down, if implemented properly. Tokenize the string, parse out operators and operands, turn the infix-statement into (for example) RPN by something like https://en.wikipedia.org/wiki/Shunting-yard_algorithm . From there, it's pretty straightforward to turn it into a kind of "intermediate language" and build a stack-based evaluator for the equations that spits out the result. I've had to implement such in the past for some work-related stuff (so certain things could be changed & controlled at runtime based on statements read from database, without the need to recompile the server software stack).

Link to comment
Share on other sites

Could it be possible that WheelLog and Kingsong app connected to the same wheel at the same time might cause a malfunction of the wheel? And if so, should one be allowed to connect only one app at the time to the same wheel?

What about a group of riders with the same wheels and apps? Would there be any danger of bluetooth interference, intentionally or not, e.g. spontaneous disconnect and reconnect to someone else's wheel?

Link to comment
Share on other sites

9 hours ago, RenaissanceMan said:

Could it be possible that WheelLog and Kingsong app connected to the same wheel at the same time might cause a malfunction of the wheel? And if so, should one be allowed to connect only one app at the time to the same wheel?

What about a group of riders with the same wheels and apps? Would there be any danger of bluetooth interference, intentionally or not, e.g. spontaneous disconnect and reconnect to someone else's wheel?

As far as I'm aware you can't connect more than one app at the time to the same wheel. Attempting so will not be able to make any damage to the wheel.

Unless the whole band get really saturated you're safe using multiply BT devices in the same location so that shouldn't be a problem either.

Link to comment
Share on other sites

9 hours ago, RenaissanceMan said:

Could it be possible that WheelLog and Kingsong app connected to the same wheel at the same time might cause a malfunction of the wheel? And if so, should one be allowed to connect only one app at the time to the same wheel?

What about a group of riders with the same wheels and apps? Would there be any danger of bluetooth interference, intentionally or not, e.g. spontaneous disconnect and reconnect to someone else's wheel?

As @HEC said the wheels can only host a single connection.  Once one app is connected the other will fail to connect.  I've done it many times switching back and fourth from WheelLog to the KingSong app.

I guess multiple devices could cause interference but it would only cause devices to disconnect and reconnect more often then expected.

None of the above would cause the wheel to break though.  If you look at the KS16 board you can see the green bluetooth module on the right hand side next to the fan.  It's a completely separate board so any issues with bluetooth would have no effect on the main board.

KS16-Control-board.jpg

Link to comment
Share on other sites

2 minutes ago, JumpMaster said:

If you look at the KS16 board you can see the green bluetooth module on the right hand side next to the fan.  It's a completely separate board so any issues with bluetooth would have no effect on the main board.

There are actually 2 separate BT modules - one normal BT for Audio and on LE for data - and if I'm not mistaken the "separate" one is the Audio one,

Link to comment
Share on other sites

1 hour ago, HEC said:

There are actually 2 separate BT modules - one normal BT for Audio and on LE for data - and if I'm not mistaken the "separate" one is the Audio one,

Oh yeah.  I can see an antennae on the main board slightly above the Bluetooth audio module. 

Link to comment
Share on other sites

10 hours ago, JumpMaster said:

As @HEC said the wheels can only host a single connection.  Once one app is connected the other will fail to connect.  I've done it many times switching back and fourth from WheelLog to the KingSong app.

I guess multiple devices could cause interference but it would only cause devices to disconnect and reconnect more often then expected.

None of the above would cause the wheel to break though.  If you look at the KS16 board you can see the green bluetooth module on the right hand side next to the fan.  It's a completely separate board so any issues with bluetooth would have no effect on the main board.

I have to disagree here. For one, I routinely used the Kingsong app and WheelLog simultaneously, WheelLog for recording the ride and Kingsong for settings of light, sound etc. I was even able to use WheelLog AND two different versions of the KIngsong app (the grey and the green one) simultaneously from my S5. (I have not tried that since the breakdown for fear of messing up the wheel again.) They also sometimes seemed to reconnect automatically, e.g. after the bluetooth connection was interrupted, even while riding the wheel.

Concerning writing data from WheelLog to the KS16: even if WheelLog cannot / does not write into the firmware's memory it is capable to send commands to the wheel, like blowing the horn, for example. So it looks to me that there is a potential risk of accidentally sending some weird, perhaps undocumented malicious commands to the wheel that might disturb normal operation. Or jamming the wheel just by sending a rapid sequence of commands with no or shorter pauses in between than required, which could easily happen when more than one app is talking to the wheel.

This is by no means criticism of your truly extraordinary efforts you put into WheelLog, no way! I am just worried that the KS16 might not be designed to interact with multiple apps / bluetooth connections simultaneously and attempting to do so might lead to serious problems.

Link to comment
Share on other sites

On 8.9.2016 at 10:24 PM, HEC said:

Amazingly - I've tried right now and - lo and behold - it worked! So I stand corrected. Funny part is that I've tried this many times before and was unable to connect with KS app while WheelLog was running or vice versa so I've end up shutting down the WheelLog to be able to change the light modes and restarting it again after leaving the KS app hence my firm believe it was not possible to have multiply apps talking to the wheel at the same time. Maybe it's down to specific FW versions? Even @JumpMaster have experienced the same behaviour ...

In regards of sending "harmful" commands to the wheel I see that quite unlikely to do any real damage to the wheel as only really dangerous would be to (attempt to) flash new firmware and that can't be done while wheel is on move. It's though recommended to (after downloading the firmware) switch off all the communication including mobile network on the mobile phone used to update the wheel apart of BT to avoid any possible interferences or interruptions during upgrade.

 

On 8.9.2016 at 10:30 AM, JumpMaster said:

As @HEC said the wheels can only host a single connection.  Once one app is connected the other will fail to connect.  I've done it many times switching back and fourth from WheelLog to the KingSong app.

I guess multiple devices could cause interference but it would only cause devices to disconnect and reconnect more often then expected.

None of the above would cause the wheel to break though.  If you look at the KS16 board you can see the green bluetooth module on the right hand side next to the fan.  It's a completely separate board so any issues with bluetooth would have no effect on the main board.

 

@JumpMaster

I don't want to be nuisance, but @HEC now was also able to connect to the Kingsong and WheelLog apps at the same time. (I have not tried it again on my KS16, FW 1.22 for fear of messing it up again.)

How exactly does your attempt to connect the two apps simultaneously fail? Which firmware version are you using?

I used WheelLog 1.6.0 yesterday on another test ride (with no other apps connecting to the KS16) and everything went fine, alarms, logging, GPS distance etc.It seems at least for this ride, that the distance inflation factor of KS is still around 0.8.

I also updated / extended my Gnuplot display command to do some energy and distance calculations with the help of a (very clumsy) Perl script, here only a MS Windows version.

plot_WheelLog_data.zip

 

Link to comment
Share on other sites

  • 2 weeks later...

Hi all,

 

Tomorrow I'll be releasing an update straight to production (1.7.0).  This update has a big effect on how the Pebble watch communicates so will require watch app version 1.3.  The fun part is watch app versions prior to 1.3 will not work with Android app 1.7, and watch version 1.3 will not work with Android apps prior to 1.7.  So both need to be updated at the same time.  I will post link to both install files in case the Play store or Pebble App store are not quick enough.

As there are now multiple speed alarms (and a new current alarm with a different vibrate tone) the watch will no longer check if the alarm should be triggered.  This will be handled by the phone which will tell the watch to vibrate.  All settings have also moved to the Android app and the watch app is no longer configurable.  Settings such as using MPH and setting the graph maximum speed already overlap with the Android app, so it makes sense to share these settings.

I've been testing these changes for the past few days and if my evening and morning commute goes well I'll release them tomorrow morning.

Kev

Link to comment
Share on other sites

32 minutes ago, JumpMaster said:

Tomorrow I'll be releasing an update straight to production (1.7.0).  

That's a great progress - thank you for your continuous development. I know that you're busy with tuning up the new features and alarms but would you please consider adding Inmotion support as well? With new V8's on it's way from @Jason McNeil I'm sure you'll make few more riders  happy ;) 

Link to comment
Share on other sites

36 minutes ago, HEC said:

That's a great progress - thank you for your continuous development. I know that you're busy with tuning up the new features and alarms but would you please consider adding Inmotion support as well? With new V8's on it's way from @Jason McNeil I'm sure you'll make few more riders  happy ;) 

The biggest issue is reverse engineering the code.  The KingSong and Gotway apps are so bad that reverse engineering them is pretty straight forward.  Ninebot on the other hand is pretty difficult.  From looking at the Inmotion (just installing it) it looks like a very well thought out app so I'd assume very well written.  This will usually mean reverse engineering it is very difficult or they may have put in protection to stop it.

Link to comment
Share on other sites

8 minutes ago, JumpMaster said:

The biggest issue is reverse engineering the code.  The KingSong and Gotway apps are so bad that reverse engineering them is pretty straight forward.  Ninebot on the other hand is pretty difficult.  From looking at the Inmotion (just installing it) it looks like a very well thought out app so I'd assume very well written.  This will usually mean reverse engineering it is very difficult or they may have put in protection to stop it.

Maybe start with KEVTEST to see what pops there and to see if some values can be read right away from there ... I know it takes time to develop something like this so indeed the priorities are being made though having Inmotion would then cover 3 out of 4 or 5 currently most popular brands of the wheels ;) 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...