OpenSourceEBike / TSDZ2_wireless

TSDZ2_wireless
35 stars 11 forks source link

Motor state control, error states, SOC indicator , and merged repository changes #34

Closed rananna closed 3 years ago

rananna commented 3 years ago

@casainho ,

I had no end of problems with the merged directory and the SDK located in the common folder. I was having random resets of the remote caused by an unknown issue. I think it may have something to do with PWM LED control, and the SDK , but you cannot debug the sdk functions in the new repository due to VS code not knowing where include files are located. VS Code cannot find the SDK functions during debugging and I do not know how to fix this issue. After a couple of days of beating my head against the wall trying to get it working, I finally gave up and copied the entire directory from the old repository to the new one. This adds the SDK back into the firmware directory. Maybe later we can go back to see what the issue was, but for now it is working.

So, This PR has the following changes:

  1. SDK put back into the firmware directory and makefile modified to work.

  2. motor state control implemented. A long press of the STANDBY key will turn the motor on/off. When the motor is initialising, the R &B LEDS will slowly flash together creating an off-white color. When the motor is finally on, the off-white led will rapidly flash, followed 2 seconds later by a display of the motor battery state. If the motor is turning off, the battery state will also be displayed. Battery state is indicated by flashing the GREEN LED. The number of flashes will indicate battery charge state from from 1 flash (10% charge) to 10 flashes (100% charge).

  3. When the motor is on, a short press of the STANDBY key will also display the battery state.

  4. Motor error states are indicated by the green power LED on the other side of the Nordic board. there are 3 error states: a- motor initialization errors are indicated by a slowly flashing LED, b -firmware mismatch errors are indicated by a fast flashing LED, c- and configuration errors are indicated by a steady on LED.

All are tested and working fine.

casainho commented 3 years ago

Good solution!! We need to find a way to share the code between the projects. I will do that.

rananna commented 3 years ago

@casainho Thanks! I need to update the ANT code on TSDZ2 wireless to properly send the correct battery SOC and the speed. These are currently fixed at the default values of 50% and 25k/hr, and do not reflect the actuals.

rananna commented 3 years ago

Just to save some time, can you pls tell me where are the actuals are stored in the code?

casainho commented 3 years ago

Just to save some time, can you pls tell me where are the actuals are stored in the code?

That is not easy looking at current code, I do not know where the 25km/h is stored.

But I can tell you that I did follow the SDK structure when I implemented the ANT LEV pages, so go to SDK and try to understand.

For what I remember, the speed is sent in a few different pages, and that pages are sent periodically automatically(??), so, you will need to use some timer to send each sequence of pages periodically and previously had update each page structure variables with the information you want.

I can´t help more now... I am busy, sorry.

rananna commented 3 years ago

@casainho, Sorry, you misunderstood the question. I know where the data is stored in the ANT pages. What I wanted to know is what variables have the real-time actual data for speed and soc?

casainho commented 3 years ago

That is very easy as is the same data that is sent to the mobile app on ble_send_periodic_data(). For instance:

At anytime, you can access to the ui_vars. The idea of UI was a structure of data used on User Interface (on the display).

rananna commented 3 years ago

Great! Thanks.

rananna commented 3 years ago

@casainho just checking again. looked at the code and it seems to me that the battery charge is stored in ui8_g_battery_soc, not ui_vars.ui16_battery_voltage_filtered_x10 is that correct?

casainho commented 3 years ago

Yes.