casainho
10 GW
- Joined
- Feb 14, 2011
- Messages
- 6,058
Wish list of improvements:
- send motor/battery current to LCD
- send the pedal cadence
With LCD3, I started to develop the firmware for it and I then can measure battery voltage, with battery current we can see on LCD battery power being used.
With pedal cadence and torque, we can see on LCD human/user power.
Here is the original firmware after being disassembled with out comments:
https://docs.google.com/spreadsheets/d/1Zuv3ELZCQJf2eksGHNJ1gKZ7Hxlrk2OHaV0mXiXQ5Hs
Some notes of what will be our working:
Here is a function that is called to set ADC start read bit and waits for the end of reading:
0xb983: c7 54 00 ld $5400,A cycles=1
0xb986: 72 10 54 01 bset $5401, #0 cycles=1
0xb98a: 72 0f 54 00 fb btjf $5400, #7, $b98a (offset=-5) cycles=2-3
0xb98f: 81 ret cycles=4
And here the function that reads ADC 5, battery/motor current:
0x85bd: a6 12 ld A, #$12 cycles=1
0x85bf: b7 31 ld $31,A cycles=1
0x85c1: cd b9 90 call $b990 cycles=4
0x85c4: a6 05 ld A, #$05 cycles=1
0x85c6: cd b9 83 call $b983 cycles=4
0x85c9: c6 54 04 ld A, $5404 cycles=1
0x85cc: a1 3f cp A, #$3f cycles=1
0x85ce: 24 07 jrnc $85d7 (offset=7) cycles=1-2
0x85d0: 48 sll A cycles=1
0x85d1: 48 sll A cycles=1
0x85d2: ca 54 05 or A, $5405 cycles=1
0x85d5: 20 02 jra $85d9 (offset=2) cycles=2
0x85d7: a6 ff ld A, #$ff cycles=1
0x85d9: 97 ld XL, A cycles=1
0x85da: b6 31 ld A, $31 cycles=1
0x85dc: a1 12 cp A, #$12 cycles=1
0x85de: 26 dd jrne $85bd (offset=-35) cycles=1-2
0x85e0: 9f ld A, XL cycles=1
0x85e1: b7 d0 ld $d0,A cycles=1
0x85e3: b7 d1 ld $d1,A cycles=1
0x85e5: 81 ret cycles=4
Maybe we just need on our UART send code, to read that ADC motor current channel, get the value and send it to us
- send motor/battery current to LCD
- send the pedal cadence
With LCD3, I started to develop the firmware for it and I then can measure battery voltage, with battery current we can see on LCD battery power being used.
With pedal cadence and torque, we can see on LCD human/user power.
Here is the original firmware after being disassembled with out comments:
https://docs.google.com/spreadsheets/d/1Zuv3ELZCQJf2eksGHNJ1gKZ7Hxlrk2OHaV0mXiXQ5Hs
Some notes of what will be our working:
Here is a function that is called to set ADC start read bit and waits for the end of reading:
0xb983: c7 54 00 ld $5400,A cycles=1
0xb986: 72 10 54 01 bset $5401, #0 cycles=1
0xb98a: 72 0f 54 00 fb btjf $5400, #7, $b98a (offset=-5) cycles=2-3
0xb98f: 81 ret cycles=4
And here the function that reads ADC 5, battery/motor current:
0x85bd: a6 12 ld A, #$12 cycles=1
0x85bf: b7 31 ld $31,A cycles=1
0x85c1: cd b9 90 call $b990 cycles=4
0x85c4: a6 05 ld A, #$05 cycles=1
0x85c6: cd b9 83 call $b983 cycles=4
0x85c9: c6 54 04 ld A, $5404 cycles=1
0x85cc: a1 3f cp A, #$3f cycles=1
0x85ce: 24 07 jrnc $85d7 (offset=7) cycles=1-2
0x85d0: 48 sll A cycles=1
0x85d1: 48 sll A cycles=1
0x85d2: ca 54 05 or A, $5405 cycles=1
0x85d5: 20 02 jra $85d9 (offset=2) cycles=2
0x85d7: a6 ff ld A, #$ff cycles=1
0x85d9: 97 ld XL, A cycles=1
0x85da: b6 31 ld A, $31 cycles=1
0x85dc: a1 12 cp A, #$12 cycles=1
0x85de: 26 dd jrne $85bd (offset=-35) cycles=1-2
0x85e0: 9f ld A, XL cycles=1
0x85e1: b7 d0 ld $d0,A cycles=1
0x85e3: b7 d1 ld $d1,A cycles=1
0x85e5: 81 ret cycles=4
Maybe we just need on our UART send code, to read that ADC motor current channel, get the value and send it to us