Reading LiPo sensor FLVSS with Arduino Uno

General Help and support for the Taranis Radio.
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi,

Has anyone done the code on an Arduino Uno to read directly the FrSky Lipo sensor FLVSS without any receiver (No Tx, no Rx)?
Just sensor to Arduino.

I want to use this to measure the internal resistance of my LiPo batteries cells using the FLVSS and some math to compute the internal resistance of each cells. Knowing the internal resistance of batteries is very important for the health status of LiPos.
I have an Excel spreadsheet but I would like to automate the process.

Since I'm not informed about the smart port protocol, any Arduino code would help me and I will share the mathematical part to calculate the Rin of LiPos.

Thanks,
Ray

User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

You might look at: https://github.com/MikeBland/SportToHub ... tToHub.cpp
This reads SPort sensors and outputs the old hub protocol. It doesn't know about the FLVSS but it should poll it.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Thank you Mike,

I don't have the libraries of this code so it's difficult for me to know how the functions work.
Will this sketch work on an arduino UNO?
How is the wire of signal data of the smart port connected to the Arduino board? I guess it will take a diode to make it bidirectional?

Thanks again.
Ray
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

No libraries, I should have linked one level above: https://github.com/MikeBland/SportToHub/tree/master
This is the complete sketch, it may run on a UNO.
The readme says just connect the SPort to IO4 and the hub output is on IO5, both are direct connections. Both are "inverted" serial so the hub output connects to a "normal" serial port on a PC.
If you want the hub data non-inverted just swap the definitions of SET_HUB_TX_PIN( ) and CLEAR_HUB_TX_PIN( ).
The FLVSS sensor is included in both protocols, in the hub data it is ID 6. The value is 16 bits, the top 4 bits are the cell index (0-5 I think) and the lower 12 bits are the voltage in units of 0.01 volts.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Thank you very much MikeB.

I'm not familiar with C++, more familiar with C, so I will have to study this code for a while to find out where the equivalent of pin I/O 4 i on the Arduino UNO.
It might take me a while to make it work.

I have difficulty finding the low level function for the arduino board i.e. the digital in/out where the data of smart port is connected to.
I know in what directory they are stored but there is so many .H files, its hard to follow.

Thanks again,
Ray

User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

The code is actually C.
You don't need to look in any arduino files, all the code is already there. It doesn't use any library code, it even has its own version of millis() and micros(), needed to avoid any timing problems. These work without using interrupts.
I/O 4 is D4 on the UNO, I/O 5 is D5.
These are defined in Aserial.cpp:

Code: Select all

#define TX_PIN           4                //!< Transmit data pin
#define RX_PIN           4                //!< Receive data pin
#define TXHUB_PIN           5                //!< Transmit data pin
TX_PIN and RX_PIN are for SPort (yes they are the same pin), TXHUB_PIN is the serial output (at 9600 baud).

If you just compile the sketch and flash it to the UNO, I think it will work as is. Just connect D4 to the FLVSS SPort signal, and you should get hub data out of D5.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Many thanks Mike for this great help.

I will certainly try this.

Ray
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi MikeB,

I tried to compile the aserial.cpp and it does not compile since I don't have the arduino.h. Where can I get this file?

But also this aserial.cpp program code is too heavy for me to follow so I have a few more questions. I tried :-)
You said the data should be coming out from D5. So does this mean I need to add C code to get the serial data coming out into a text form myself?
If this is the case, is there any existing code for that purpose?
Either on the serial monitor or another way? The simplest for me would be the serial monitor.

Thank you,
Ray
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

How are you compiling, are you using the Arduino IDE (I am for this)? If so, arduino.h should automatically be there.
In Aserial.cpp, there is a function "sendHubPacket". This puts the data to be sent into the array TxHubPacket. This function needs to be changed to send the data you require. The serial monitor cannot be used as it will upset the SPort timing.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi MikeB,

Yes I'm using the Arduino IDE (UNO). I will retry a compilation. I think I made a mistake, it is the aserial.h that is not seen. Don't know exactly why because it was in the working directory.
I will investigate.
I will try to understand more the C code. Your last post will help.

Thanks,
Ray
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

MikeB,

These are the error messages I got just now in my last compilation.

wiring.c.o (symbol from plugin): In function `__vector_16':
(.text+0x0): multiple definition of `millis'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\63499F4BF97F76C5FF78FCC760617D29\sketch\Aserial_ray.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
wiring.c.o (symbol from plugin): In function `__vector_16':
(.text+0x0): multiple definition of `micros'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\63499F4BF97F76C5FF78FCC760617D29\sketch\Aserial_ray.ino.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\ccXauzoe.ltrans0.ltrans.o: In function `main':
C:\Users\Raymond\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:43: undefined reference to `setup'
C:\Users\Raymond\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:46: undefined reference to `loop'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

I just tested building using Arduino IDE 1.8.13 (the most recent I have installed).
The IDE has 4 files:
SportToHub.ino
SportToHub.cpp
Aserial.cpp
Aserial.h

I selected "Arduino Uno" as the board type, and this builds OK.
Please try building this first.
Then I suggest changing "sendHubPacket()" to:
void sendHubPacket()
{
HubInIndex = 0 ;
TxHubPacket[HubInIndex++] = 'H' ;
TxHubPacket[HubInIndex++] = 'e' ;
TxHubPacket[HubInIndex++] = 'l' ;
TxHubPacket[HubInIndex++] = 'l' ;
TxHubPacket[HubInIndex++] = 'o' ;
TxHubPacket[HubInIndex++] = 13 ;
TxHubPacket[HubInIndex++] = 10 ;

if ( HubInIndex )
{
TxHubPacket[HubInIndex++] = HUB_SEPARATOR ;
TxHubSize = HubInIndex ;
TxHubIndex = 0 ;
}
}

This should send "Hello" on IO5 every 0.25 seconds at 9600 baud.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

I'm sorry but I'm confused. I'm new with Arduino so I'm learning.

What do I need to do with these?
SportToHub.ino
SportToHub.cpp
Aserial.cpp
Aserial.h

This is what I did:
I used Aserial.cpp as the source file to compile and included header Aserial.h and Arduino.h in the Aserial.cpp file.
Then compiled and it gave the error messages.

Sorry to take of your time.
Ray
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

Lets start with just building SportToHub.
You should have an Arduino directory, so create a sub-directory in this called SportToHub. Put the four files in this.
Double click on SportToHub.ino and the Arduino IDE should open ready to build it. Make sure you have the UNO selected as the target device, then run the build.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by jhsa »

I didn't know you had done something like this Mike, very nice. Been using the oXs till now. Will have to have a look at this project of yours, I might learn something 8-)
if all we needed was to read 3 cells only, would this work on an ATtiny85? I think the problem is that the ATtiny does not have hardware serial support? Could software serial be used instead? Or is the Tiny85 too weak for this anyway?
Thanks

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

Thanks for your support and patience.

I did 100% what you said and still have the following error messages for the compiler below.
I also included my directory SportToHub (pdf file)

C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `init'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `setup'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `loop'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `LedMillis'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `LastMillis'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `SlotMillis'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `HubMillis'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `AnaCount'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `AnaAve'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `Analog'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.ino.cpp.o (symbol from plugin): In function `init':
(.text+0x0): multiple definition of `Xanalog'
C:\Users\Raymond\AppData\Local\Temp\arduino\sketches\BD9F3EFA0E150E620CEF1CFC82F5B6D4\sketch\SportToHub.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1
Attachments
SportToHub files.pdf
(58.78 KiB) Downloaded 122 times
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

Comment out the line in SportToHub.ino:
//#include "SportToHub.cpp
or:
delete the SportToHub.ino file and rename SportToHub.cpp to SportToHub.ino.

This is only done due to the way I work, I use an editor outside the Arduino IDE, and if I select a .cpp file it opens in the editor, while if I select a .ino file it opens in the Arduino IDE, so I want everything in a .cpp file.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

OK this last directive worked! No more compilation errors.

Now I have to find a way to read the character strings coming out from IO5.
At this time I don't know how to do this but I'll do some work to find a way.

So if I find a way to read IO5, will I be able to get the voltages from FLVSS?

Thank you
Raymond
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

In Aserial.cpp, try changing:
#define TXHUB_PIN 5 //!< Transmit data pin
to
#define TXHUB_PIN 1 //!< Transmit data pin

and swapping:
#define SET_HUB_TX_PIN( ) ( HUBPORT |= ( 1 << TXHUB_PIN ) )
#define CLEAR_HUB_TX_PIN( ) ( HUBPORT &= ~( 1 << TXHUB_PIN ) )
to
#define CLEAR_HUB_TX_PIN( ) ( HUBPORT |= ( 1 << TXHUB_PIN ) )
#define SET_HUB_TX_PIN( ) ( HUBPORT &= ~( 1 << TXHUB_PIN ) )

then the "hub" serial data should be sent to the USB serial on the UNO.

If you also change the function "sendHubPacket()" I detailed a few posts back, then the USB serial should send "HELLO" out at 9600 baud at regular intervals.
The Arduino IDE has a "serial monitor" facility, so if you set this up at 9600 baud, you should see the "HELLO" on this.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

This works. :D I see hello on my serial monitor. Great.

So now I have to connect the FLVSS and see it I can print on the serial monitor the voltage values. right?
If I can print them, then I will be able to apply my math equations to get the internal resistance of each cell.
Mike, the C code you made is pretty heavy for me as I'm not a programmer but I'll try to get the values out.

BTW the Rin values you read on your chargers are notoriously bad unfortunately.

Ray
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

OK, with a FLVSS connected, the array "FlvssCells" should get filled with the cell voltages.
The values are 0-420 representing 0.0 to 4.20 volts.

So if you change sendHubPacket() to:

Code: Select all

void sendHubPacket()
{
  uint16_t value ;
  HubInIndex = 0 ;
  value = FlvssCells[0] ;
  TxHubPacket[HubInIndex++] = (value/100) + '0' ;
  TxHubPacket[HubInIndex++] = '.' ;
  value %= 100 ;
  TxHubPacket[HubInIndex++] = (value/10) + '0' ;
  value %= 10 ;
  TxHubPacket[HubInIndex++] = value + '0' ;
  TxHubPacket[HubInIndex++] = 13 ;
  TxHubPacket[HubInIndex++] = 10 ;

  if ( HubInIndex )
  {
    TxHubPacket[HubInIndex++] = HUB_SEPARATOR ;
    TxHubSize = HubInIndex ;
    TxHubIndex = 0 ;
  }
}
you should get the voltage of the first cell showing on the IDE serial monitor.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

Thanks again for your great support.

It almost works.

When lipo is not connected and all cells are at 0 volt, I do see 0.00 on the monitor.
When lipo is connected to the FLVSS cell # 1 reads 3.83V and the monitor displays ^C.15 continuously.
Not sure how that happens, your code seems to be good.

Ray
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Mike,
Picture of my setup attached.
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Oups, here is the picture
Don't worry about the data pin, it is well inserted.

Ray
20230902_191027.jpg
(799.58 KiB) Not downloaded yet
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

OK, remove the line with "HUB_SEPARATOR " on it (this is the cause of the '^' in the display.
Change the line:
value = FlvssCells[0] ;
to:
value = FlvssCells[0] / 5 ;

You displayed value is actually 19.15, which is 3.83 * 5.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

Wow! this works great now Mike.
Thank you very much for your support and this great software.

I should be able to generate the rest of the C code to read all the cells individually and calculate their own Rin.

Thank you again,
Ray
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Mike,

Just one more question (I hope the last one) :D :

Can I use the Arduino Serial.print function in your loop() function to display my calculations after the reading the voltages?
I tried to debug with Serial.print(value); and nothing came out on the serial monitor.

Thanks,
Ray
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by MikeB »

With the TXHUB_PIN set to 1, this takes over the pin Serial.print would use.
Also, the timing for reading the SPort is critical, so the interrupts used for the Serial function will upset this.
The code is carefully setup so that the SPort is accessed, then up to 4 bytes are sent to the "HUB" pin before the next access to the SPort.
If you change the TXHUB_PIN (back to 5), then Serial.print might output something, but I would expect the SPort access to have trouble.

Mike
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

Got it.
I will try this:
1- With TX_HUB_PIN to 1, I will store the lipo cells values in global variables. Do two reads, one without load and one with load.
2- Put TX_HUB_PIN to 5.
3- Serial.print my Rin numbers after a few calculations.
4- Put back TX_HUB_PIN to 1.

I won't try to send data when TX_HUB_PIN = 1.

Thanks Mike.

Ray
Raythegreat
Posts: 284
Joined: Sat Apr 16, 2016 11:33 pm
Country: -

Re: Reading LiPo sensor FLVSS with Arduino Uno

Post by Raythegreat »

Hi Mike,

I tried to study your code but it's a little to complicated for me. :oops:
Please note I did not change TX_HUB_PIN to 5 yet. First I want to make sure I can read all the lipo individual cells from the balance cable.

I was able to display on the serial monitor my 3S lipo cells.
But there is something I don't understand.

My displayed voltages were cell1 = 3.74V, cell2 = 3.80V, cell3 = 3.79V. Yes I know my battery is not balanced so that's why I took it.
So that works pretty well.

However, when I disconnect the lipo balance cable from the FLVSS the values on the serial monitor continue to display the previous voltages in a loop.

This is what I get even when the battery is disconnected:
3.74
3.80
3.79
3.74
3.80
3.79
and so on.

to refresh the values, I need to connect/disconnect the balance cable to get new fresh values.
My conclusion: I don't have real time values displayed and don't understand the code to find out why.

But the overall values are GOOD.

Ray

Post Reply

Return to “General help (FrSky Taranis radio)”