RPM resolution?

Development & General Chat for the superb openxvario project.

Moderator: rainer

Post Reply
chimchim
Posts: 2
Joined: Thu Aug 29, 2019 3:24 am
Country: -

RPM resolution?

Post by chimchim »

Well, I've been lurking here for a couple weeks studying up on how to create an RPM and Temp sensor unit. I have successfully created a working module using a 5V pro mini and some left over 3D printer heat bed 100k NTC Thermistors. I also picked up a hall sensor that will mount to the hub on my DA170.
All sensors are functioning as expected and I can see readings on my FrSky X9D+ running OpenTx2.?. I also have the new(er) glider 6 channel Rx with the built in altimeter, and a 40A FrSky current sensor. All sensors are playing nice together and all available on the menu telemetry page.
Now, my question of the day is.....how can I get more granular RPM display than in units of 60? It appears that the Hz value being sent from the sensor module to the Rx is only in integer format rather than decimal.

Thanks for any help you can provide in addressing that question.
Regards,
Steve

chimchim
Posts: 2
Joined: Thu Aug 29, 2019 3:24 am
Country: -

Re: RPM resolution?

Post by chimchim »

Well, I might have resolved this myself. I edited the oXs_general.cpp file and altered the line that calculates the RpmValue. I added in a multiply by 60 there to switch from Hz to cycles per minute. That should get rid of the coarse RPM steps and still have rapid sampling. One strange thing I noticed, both before and after my code change is that the OpenTx display of RPM bounces from zero to some value regardless of how well I manually swing a magnet in front of the hall sensor. Perhaps that will go away with actual use on the engine, so not too concerned about it yet.

-Steve
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Hi Chimchim,

I am looking for instructions and preferably code for utilising an Arduino nano to make a RPM sensor for my 40 cc CDI spark ignition engine (on a tug plane fitted with a "D" series FrSky receiver).
I find the GitHub sites just about incomprehensible with description of what "can be done", but little to guide the novice. Such as this one:
https://github.com/openXsensor/openXsensor

Can you assist by directing me to a site that contains starting information for the relative novice please?
I have made up Arduino based projects before, but only with full instructions.
Thanks,
Jim.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

You can use openXsensor with an arduino pro mini (or nano)
Dowload the project from github.
In the folder openXsensor of the project you can find a file oXs_config_description.h that provides many instructions.
In practice, you open the openXsensor.ino file in the Arduino IDE and you basicaly have just to edit the files oXs_config_basic.h to
- select the FRSKY_HUB protocol.
- deactivate all options for sensors (like vario, voltage, current) except RPM ( so having #define CALCULATE_RPM YES)

The in file oXs_config_advanced.h edit this line
#define PULSES_PER_ROTATION 2
to
#define PULSES_PER_ROTATION 1

That is all for the arduino side.

For a RPM sensor, you need to find some hardware component that can provide pulses (in the range 0/5V to avoid to destroy the arduino chip) when you engine runs.
I presume that such a signal can be extracted in some way from your ignition system.
This signal has to be connected to the arduino digital pin 8.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Thanks for the reply mstrens. I can use the pulse signal from the CDI to provide an input to pin #8 on the Arduino nana via an electrolytic capacitor.
I am now trying to find the correct files.
More later.............

Edit: I think I have found the correct file!

Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Is this the correct page?

oXs_config_advanced.h
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

You have to change mainly oXs_config_basic.h.
I think you have also 1 parameter to change in oXs_config_advanced.h

Please read first the file oXs_config_description.h
This one contains the documentation.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

You have to change mainly oXs_config_basic.h.
I think you have also 1 parameter to change in oXs_config_advanced.h

Please read first the file oXs_config_description.h
This one contains the documentation.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

mstrens wrote: Thu Jan 16, 2020 8:43 pm ...........................
Please read first the file oXs_config_description.h
This one contains the documentation.
Ok.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Cut and paste arduino sketch?

Post by Endorphin »

mstrens wrote: Thu Jan 16, 2020 8:43 pm ...........................
Please read first the file oXs_config_description.h
This one contains the documentation.
Am I right in assuming I can cut and paste selected paragraphs from the above description.h to compile a sketch for flashing in an arduino nano for the desired functions?
I have stalled completely on the task of "compile from source" of your Configurator for Linux Mint. Sorry.........my incompetence showing!
Do I have to use Configurator to make up and flash an openXsensor?

Jim.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Yo do not need to use the configurator.
You can just edit manually the 2 files oXs_config.basic.h and oXs_config_advanced.h.
Just change the YES/NO options and some parameters according to your need.

All the lines needed for the setup already exist in those 2 files. So no need to copy/paste from oXs_config_description.h. This file is only to provide explanation.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Got it, thanks for the confirmation mstrens.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Basic question.

Post by Endorphin »

I have now edited down the two files compile a sketch in the Arduino IDE.
Where do I find the connection diagram for the Arduino nano please?
When I find them, I can flash my board.

I found this one: https://components101.com/sites/default ... Pinout.png

Is A4 the correct pin for sensor(s) in? I selected pin 4 in the sketch.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Here you define the pin connected to the Rx
// ****** 1.1 - Pin connected to Rx ********
#define PIN_SERIALTX 4 // The pin which transmits the serial data to the telemetry receiver, Usually pin 4 (otherwise pin 2)

Then you have also to connect the signal with the pulses for RPM. This signal must switch between 0V and 5V (not more).
It has to be connected to pin 8 (= D8)
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Ok got that. I assume that pin 4 (which I selected in the sketch) is D4 and not A4 when using the hub protocol...........correct?

Edit: I think I can answer my own question; in the description it states that one digital pin has to be connected to the receiver.

Thanks for the warning about signal voltage maximum. I will check the output of the CDI signal on an oscilloscope before connecting it to the nano.
I will connect it to the arduino nano in series with an electrolytic capacitor, and if necessary, a voltage divider. An opto coupler might be better?
I might be able to decide better after looking at the signal output of the CDI.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Indeed 4 means D4.

An opto coupler would be good but I do not know if your pulse have enough power to drive it. An opto coupler needs usually about 5/10 mA at the input side.
To protect the arduino pin, you can also add a diode between the divider (if any) and the 5V vcc in order to limit the voltage.
If you do not use a divider you can also insert a resistor (e.g. 10k) between the signal and the pin to limit the current (normally arduino has diode to protect the input but those diodes does not support high current.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Very good.
Thanks for sticking with me on these minor beginners questions.
I am now ready to go...............more when I get it working or strike an unforeseen problem.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Good luck.

Do not forget also to change
#define PULSES_PER_ROTATION 2
to
#define PULSES_PER_ROTATION 1
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

mstrens wrote: Sun Jan 19, 2020 2:25 pm Good luck.

Do not forget also to change
#define PULSES_PER_ROTATION 2
to
#define PULSES_PER_ROTATION 1
Yes!
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Upload failed.

Post by Endorphin »

My first attempt at uploading the edited sketch to an arduino nano failed.
I got this error notification:

Arduino: 1.8.10 (Linux), Board: "Arduino/Genuino Uno"

/tmp/ccMamgfG.ltrans0.ltrans.o: In function `main':
/home/jim/Downloads/arduino-1.8.10/hardware/arduino/avr/cores/arduino/main.cpp:43: undefined reference to `setup'
/home/jim/Downloads/arduino-1.8.10/hardware/arduino/avr/cores/arduino/main.cpp:46: undefined reference to `loop'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I obviously edited something out that I should not have.
What does the error notification tell me? Can you explain please?

JIm.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

In arduino IDE, you have to select the type of board you are using.
You have to select Arduino Nano (in tool menu)

It seems you currently have Board: "Arduino/Genuino Uno"
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Aaahh!
That will be it.
Thanks for the prompt reply. I will change that and see how I go.
More later.

Jim.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

I changed the board entry in my Arduino IDE to nano and tried to flash again.
I received the same error notification.
Should I have a port selected in the IDE?
I have non checked now.
User avatar
kalle123
Posts: 905
Joined: Sat Mar 29, 2014 10:59 am
Country: -
Location: Moenchengladbach

Re: RPM resolution?

Post by kalle123 »

Before trying to get a oXs sketch on the nano, maybe you should try to get the basics with Arduino and the IDE.

Please try DATA - EXAMPLES - BASICS and use BLINK.

Here you find some YT videos

https://www.youtube.com/results?search_ ... +IDE+BLINK

br KH
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Ok. Thanks kalle.
I will give that a go later today.
ReSt
Posts: 1581
Joined: Tue Dec 27, 2011 11:34 pm
Country: -

Re: RPM resolution?

Post by ReSt »

regarding to intermittend compile errors with the Arduino IDE

There is/ or was? a problem with the linker (at least until the version 1.8.0 that I still use).
I had the problem that least modifications of a file, e.g. adding a line of code or even deleting a commentline could lead to a "load error 1" or "load error 5".

That was caused by a problem with the two files "ld.exe" and "ld.bfd.exe" that were updated around IDE version 1.7 or 1.8

The circumvention that I found in an Arduino forum and that works for me since more than two years, is, to replace those two files with the older versions of 1.6

The size of my failing versions is 1.116.672 bytes and the old, working version is 975.360 bytes

Reinhard
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

I am consistently receiving the error notice that indicates that a reference to "set up" and also a reference to "loop" is missing.
The answer I received over on the arduino forums suggested this.
However, I am unable to find any reference to such files in both the basic and the advanced OpenTXsensor files.

What am I missing?
Attachments
Set up and loop missing..png
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: RPM resolution?

Post by Kilrah »

Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Kilrah:
Is your post an answer to my question?
If so, I read the link you provided, but could not find anything even remotely relating to the probem I am experiencing. Or at least, not that I recognised.
What am I missing that I need ...............Please?

My apologies up front if the answer is hidden "in plain sight" within one of the fifty or so posts in that thread.

(If there is a beginner thread for this, I might have to go over to it?).
User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: RPM resolution?

Post by Kilrah »

EDIT: It seems I've answered my own question - the idea is to Open the openXsensor.ino file in Arduino IDE and this populates the entire project [...] and then Upload

Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”