RPM resolution?

Development & General Chat for the superb openxvario project.

Moderator: rainer

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

Re: RPM resolution?

Post by mstrens »

I will have to leave for a few hours (probably 6 hours).
We can continue later on if you want.

I presume it is very late for you. If so, sleep wel.
I am in Europe ant it is about 13:00

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: RPM resolution?

Post by jhsa »

No, not code error, that means that you haven't been doing the right thing.. :) Nothing wrong with the openXsensor code :) :)
As you say, you are learning.. :) We all are :mrgreen:

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
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Are you sure that the value on the TX is 6000?
I expected it would be 60000 because the value that is sent is supposed to be in Hz (so 1/sec) and the value on Tx in tour/min (so X 60).

What is the value that you get for Temp1. Is it 20 or 2?

Anyway, the values does not matter a lot. What is important, is that it shows that you can compile/flash and that the communication with RX/TX is ok.

Without changing anything to the program your oXs, you can try to connect it to the PC (using USB) just like when you flash the code.
For this test, there is no need to connect oXs to the Rx.
When oXs is connected to the PC, you can start the Arduino IDE.
It does not matter is a sketch is displayed or not.
Then, you can start up the serial terminal provided with the Arduino IDE. To do so, you have to press simultanously CTRL+SHIFT+M
This will open a new window.
Then check that the baudrate is set on 115200 (below right). If required change it.

Normally the windows should then displays some line of text.
Each line gives a set of data that oXs sent to the RX.

If this works, I kan make a new set of files in order to measure the RPM and display the RPM on the PC screen.
So, you would be able to check that you sensor can (or not) capture the RPM without using the link with RX/TX.
This would show if there is a problem with the hardware you are using to capture the RPM.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Ok, Michael, I've done that.
I do see some constantly repeated text on the display screen after following the above procedure.
I will attach a screenshot.

Jim.

I have to go out this morning. Back at about midday, AEST.

Thanks for sticking with this for me. There is now a light at the end of the tunnel.
Attachments
Arduino display.png
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

jhsa wrote: Wed Feb 19, 2020 12:24 pm No, not code error, that means that you haven't been doing the right thing.. :) Nothing wrong with the openXsensor code :) :)
.......................João
Joao,

If you say so; I have little reason to doubt your obvious wisdom here. Thanks for continuing to read this ongoing saga!
After all, if the code works for one, it will/should work for all, right?
However, I would dearly like to know just what is the "right thing" that I should have been doing!
With a bit of more perseverance and lost sleep, we all might find out soon.
I don't want to lay bets, but....................... :mrgreen:

Jim.

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

Re: RPM resolution?

Post by mstrens »

Here a new set of files.
You can just use it like the previous set of files.

The purpose of this one is to let you make a test where oXs is connected to the PC (via USB) and not connected to the Rx.
You should get continously a line of text. At the end of the line, you have Rpm=xxx where xxx is the Rpm in Hz (=1/sec)

If oXs does not get pulse on the D8 pin , you will get Rpm=0.
In order to get pulses, you must have some hardware and connect Ground to Ground and positive pulses signal (in range 0-5 Volt) to D8.
Best is to use a scope to see if you hardware is good.
If you are not sure that your pulses are in the range 0V - 5V, it is at least safe to put a resistor of about 10K in serie on the pulse signal between your hardware and the D8 pin.
I hope I am clear enough.
Attachments
openXsensor.zip
(305.49 KiB) Downloaded 312 times
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

mstrens wrote: Wed Feb 19, 2020 7:56 pm ..........................
If oXs does not get pulse on the D8 pin , you will get Rpm=0...............................
That is what I am seeing now: RPM = zero.
Is that what we want?
Best is to use a scope to see if you hardware is good.
If you are not sure that your pulses are in the range 0V - 5V, it is at least safe to put a resistor of about 10K in serie on the pulse signal between your hardware and the D8 pin.
...............
Do I now need to do that? What am I looking for? An output signal on pin D4 on the arduino?
Make sure the pulses are within the range you specify?
Is that what I need to do now?
I do have a scope.
Attachments
RPM zero.png
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

So, the new sketch is uploaded in a correct way.

Now you must test if the hardware module you build to capture pulses is working as expected.

Which kind of hardware module did you build?

Best is to test you hardware module without connecting it to the openXsensor.
So connect you hardware module to your motor.
Connect the scope between grnd and the output of your module; let the motor run and check if:
- you have pulses?
- the frequency of the pulse is about the expected one?
- does the pulses have nice rising and failing front (or is it very noisy)?
- what is the voltage of the lowest level?
- what is the voltage of the highest level?
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: RE: Re: RPM resolution?

Post by jhsa »

Endorphin wrote:
jhsa wrote: Wed Feb 19, 2020 12:24 pm No, not code error, that means that you haven't been doing the right thing.. :) Nothing wrong with the openXsensor code :) :)
.......................João
Joao,

If you say so; I have little reason to doubt your obvious wisdom here. Thanks for continuing to read this ongoing saga!
After all, if the code works for one, it will/should work for all, right?
However, I would dearly like to know just what is the "right thing" that I should have been doing!
With a bit of more perseverance and lost sleep, we all might find out soon.
I don't want to lay bets, but....................... :mrgreen:

Jim.
What I meant is that there is nothing wrong with the openXsensor code.. :)
We are always learning.. just hang on, you will get it.
There is no one better than Michel to help here. After all he writes the code. :)
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
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Hardware module?

Post by Endorphin »

mstrens wrote: Wed Feb 19, 2020 8:54 pm .......................the hardware module you build to capture pulses is working as expected.

Which kind of hardware module did you build?
.........................
What do you mean by this term please Michael?
If could be folly for me to guess.
Can you explain further please?
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RE: Re: RPM resolution?

Post by Endorphin »

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

Re: RPM resolution?

Post by mstrens »

In order to get RPM, oXs needs to get a pulse each time your motor makes one revolution.

So you need some hardware to generate those pulses.
You can't just connect a wire on the plug because it is a high voltage that would just distroy your arduino (that does not accept more than 5 V on his input).
What I named "hardware module" is the equipment you use to get the pulses within the right voltage (0-5V).
There are several way to get it.
Perhaps you have already an ignition unit that let you access such a signal.
Some use a hall effect sensor that generates a pulse each time an magnet goes close to the sensor.
Some use an optical sensor and some electronic to amplify the variation
I presume that it is also possible to use other ways.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

In a previous post you said "I can use the pulse signal from the CDI to provide an input to pin #8 on the Arduino nana via an electrolytic capacitor".

Do you know the voltage that the CDI provide?
If it is a high voltage, you need a capacitor that support such a high voltage.
If it is more than 5 V, it is safe to add a resistor and also 2 diodes (one conducting over voltage to 5V vcc and one negative voltage to ground).
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

Ok. Understood now, thanks.
In my desktop proof of concept set up, on my computer desk here in the house in front of me, I have simply wired in a hall sensor and connected the output pin of the hall sensor to pin #8 on the arduino.
When, and if, I ever get this unit functional, the hall sensor will be removed and replaced with the CDI output, after I check the signal voltage out. I have read that the tacho output of the CDI is of a suitable voltage, but I will be confirming that.
If the voltage is too high, I will process it with a voltage divider as you describe, or in a similar way to ensure it does not exceed 5 volts.

To do all these multiple uploads with the sensor installed in the model (lost count of the number of times), then to run out to my shed, test the telemetry with the Taranis and the full model powered up, run back and reload, etc. etc. would have been hopelessly inefficient.

This way, I have everything necessary to check a trial upload right in front of me.

I hope I have answered your question regarding what you refer to as "my hardware module".
Please advise if I should supply any more information.

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

Re: RPM resolution?

Post by Endorphin »

I plan to connect my little scope to the arduino pin# 8 tonight and rotate a magnet in front of the hall sensor.
I just happen to have made a little magnetic stirrer last week, so I can use that to simulate a rotating magnet in an engine hub.
Like Karl did, described at the top of page # 3.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Endorphin wrote: Thu Feb 20, 2020 9:36 am I plan to connect my little scope to the arduino pin# 8 tonight and rotate a magnet in front of the hall sensor.
I just happen to have made a little magnetic stirrer last week, so I can use that to simulate a rotating magnet in an engine hub.
Like Karl did, described at the top of page # 3.
It is fine.
An alternative, if you have it, is to use a little transformer that you connect on the AC network and that provides about 3V AC (so about 5V max). Adding a diode would avoid getting negative voltage.
If you transformer gives more than 5V peak, you can add a voltage divider with 2 resistors after (or before) the diode.
Such a transformer + diode would give you a 50Hz (or 60 Hz depending the regio) signal.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

I have looked at the arduino output @ pin #8 on my little portable scope.
It is noisy, just a lot of low level hash.
Zero response detectable when the hall sensor is excited by the rotating magnet.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Endorphin wrote: Thu Feb 20, 2020 11:06 am I have looked at the arduino output 2 pin #8 on my little portable scope.
It is noisy, just a lot of low level hash.
Zero response from the hall sensor when it is excited by the rotating magnet.
What do you mean by arduino output 2 pin #8

Do you mean digital pin 8 (=D8).
Note: It is an input and not an output.
So the signal on this pin should be exactly the same as what is generated by your hall sensor.

Perhaps your magnet is not strong enough for your sensor?

If you have a small transformer, you could try with if. The frequency would be fixed but it allows you to test outside the plane.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

My apologies Michael, I meant pin number D4.
The output pin.
Last edited by Endorphin on Thu Feb 20, 2020 11:29 am, edited 1 time in total.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

The magnets (2 of them, stacked) are much stronger than the ones that are fitted to the internal combustion 40 cc two stroke engine hub that is powering my plane. These are 6 mm x 2mm. A 3mm x 2 mm magnet (much smaller) runs the CDI on the engine flawlessly.
If these magnets do not trigger the hall sensor and so the arduino openXsensor, then it is totally unsuitable for my application.
Besides, Karl has already shown that a small magnet will make the unit function.

I think we a starting to clutch at straws, as the saying goes.
Something is fundamentally wrong.
Last edited by Endorphin on Thu Feb 20, 2020 11:43 am, edited 2 times in total.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

I just edited my post above.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

did you check with the scope the signal on the input pin D8 when you move the magnet?

When you connect oXs to the PC (via USB) and open the arduino serial terminal (CTRL+SHIFT+M), you get Rpm = 0.
Does this Rpm value change when you move the magnet fast enough?
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

More success!

Post by Endorphin »

mstrens wrote: Thu Feb 20, 2020 12:12 pm did you check with the scope the signal on the input pin D8 when you move the magnet?............
Yes I did check with the scope. I am not sure I did this correctly, will try again.
When you connect oXs to the PC (via USB) and open the arduino serial terminal (CTRL+SHIFT+M), you get Rpm = 0.
Does this Rpm value change when you move the magnet fast enough?
Yes!
Screenshot attached.
Attachments
RPM indicated ok.png
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

So, it seems to work.
You can see in the screenshot that when RMP is not 0, some values being sent change. Eg. when Rpm = 17 (decimal), you find a "11" before (which is a hexadecimal representation of 17 decimal = (1x16)+1 = 11 hexa.

It is not abnormal that you do not get really a signal on the scope if you look at the output pin D4 because the data are sent only a few time per sec and there is no easy way to trigger the signal on the scope.

I expect that if you connect now you oXs to the RX and to you hall sensor, you will get some data on the Tx screen.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Re: RPM resolution?

Post by Endorphin »

mstrens wrote: Thu Feb 20, 2020 5:16 pm .........................

I expect that if you connect now you oXs to the RX and to you hall sensor, you will get some data on the Tx screen.
I tried that, at 2 am this morning.
Still does not work.
The tx. does not "discover" the sensor.
Please don't waste anymore time on trying to sort this for me Michael; we are getting nowhere with it.
I don't like the idea that you are spending all this time when you will already have a life, as do I.
I can get by perfectly well enough without it.

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

Re: RPM resolution?

Post by Endorphin »

mstrens wrote: Thu Feb 20, 2020 5:16 pm ..........................................
It is not abnormal that you do not get really a signal on the scope if you look at the output pin D4 because the data are sent only a few time per sec and there is no easy way to trigger the signal on the scope.
...............................
That makes sense now, I had not considered this.
However, Karls example pictures earlier show a clear square wave after he removed the cap. I guess he must have been looking at the Hall sensor output and not the arduino pin number 4 output.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: RPM resolution?

Post by mstrens »

Endorphin wrote: Thu Feb 20, 2020 11:20 pm
mstrens wrote: Thu Feb 20, 2020 5:16 pm ..........................................
It is not abnormal that you do not get really a signal on the scope if you look at the output pin D4 because the data are sent only a few time per sec and there is no easy way to trigger the signal on the scope.
...............................
That makes sense now, I had not considered this.
However, Karls example pictures earlier show a clear square wave after he removed the cap. I guess he must have been looking at the Hall sensor output and not the arduino pin number 4 output.
Indeed, the square wave is the output of the hall sensor.

I really can't understand why your Tx does not discover the sensor because the last code is just the same as the previous one. I just added the fact that it had to fill the Rpm value in the message and that it had to print the Rpm value on the PC display.
It is not normal that with the previous version, you got 2 fix values on the TX and with this last version no one.
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

Serial monitor port USB parallel with D4 output?

Post by Endorphin »

What we know and have proved or disproved:
mstrens wrote: Fri Feb 21, 2020 6:14 am .....................................
It is not normal that with the previous version, you got 2 fix values on the TX and with this last version no one.
1. Yes. To put it in another way, Opentx / Taranis X9D Plus did discover the sensor with your previous fixed RPM parameter version of the file. Then with the activated dynamic parameter (recent) version (for want of a better description), the Taranis did not discover any new sensors.

2. After uploading the later (most recent) sketch to the arduino nano, with read value added in the normal fully functional way, I could see an output via the arduino serial monitor port displayed on the computer screen when the hall sensor was triggered or energised.
To my mind and limited understanding, this verifies that the Hall sensor is providing a pulse to the sensor and that the sensor is working and providing a signal at the USB port.

3. I have confirmed that I am using the correct pin connections on the side of the D8 rx. by swapping the sensor over and testing the same connections with a commercial FrSky vario. All works as designed.
So I can therefore conclude that I am using the correct receiver input pins.

However, does this serial monitor output verify that we have an output at pin number D4? (the default output pin selected in the sketch and connected to the rx pin on the side of the FrSky D8R-11 Plus).
Is the serial output signal at the USB port in parallel with pin D4?

If in fact, it is not, we have a likely reason for the tx. not finding the sensor; because it is getting no signal from pin D4.
The result of my test explained at point #3 above would support this conclusion.

Summing up:

Put simply: no signal is arriving at the "rx" telemetry pin on the side of the D8 receiver. when the arduino nano loaded with the recent sketch is connected to the "rx" pin and ground of the telemetry pins on the tx..
&
A signal was arriving at the "rx" telemetry pin on the side of the D8 receiver when the arduino nano was loaded with the first static parameter sketch.

I am confident you would have thought of all this, but I am trying to figure what is going on and now I am clutching at straws.

Thanks again Michael.

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

Re: RPM resolution?

Post by mstrens »

I understand what you explain.
It is strange.
I checked once more the differences between the 2 versions.
I found a tipo fout in the latest version (a "," instead of a ";").
It is very strange that the compiler did not detect it.
Furthermore, the generated code has exactly the same length with or without this error.
Furthermore, it seemed to work because it displayed "Rpm= xxxx" on the serial monitor (and the bug was on this line).
Perhaps that your compiler does not react like mine. Really strange.

Anyway, I fix the bug and make a new version (see attachment).
Except the correction of the bug, this version works like the previous one:
- it should measure RPM and report the rpm value in the serial monitor (just after a list of code that represent the message put on the D4 pin.
- it should send to the TX (on D4 pin) the values for RPM (based on the input on D8) and for a dummy fix temperature (=20)
The messages sent to the Tx and to the serial monitor are different (not the same content, not the same speed, ...) but are generated (nearly) simultaneously in the code.
Furthermore, I uploaded this last version on an arduino nano (should be the same with an Uno or a pro mini) and I checked with
- the serial monitor : I get the expected messages
- a digital scope put on D4. This digital scope can decode the signal and it is exactly the expected one ( the 7 Hex characters that are also displayed on the serial monitor).

If it still does not work on you side I do not understand anymore.
You can then also check that:
- you have good common ground between your components
- you compile in Arduino selecting a board with the right clock frequency/voltage. Usually 5V arduino runs at 16Mhz while 3.3V runs at 8Mz. Normally oXs supports both but you have to select the rigth board in the arduino drop list

In order to confirm that there is a signal on D4, you can put you scope on it but you will not see a nice repetitive signal because it is a digital signal at 9600 bauds that is generated only a few time per sec (about 18 times per sec). So you have to use a low frequency on you scope to see something but at least the scope should trigger on the signal.
Note: both messages are generated even if there is no input signal on D8 (just that Rpm will be 0 in this case).
Attachments
openXsensor.zip
(305.49 KiB) Downloaded 228 times
Endorphin
Posts: 167
Joined: Tue Jan 26, 2016 7:46 pm
Country: Australia

It is working!

Post by Endorphin »

Congratulations Michael, you have got it sorted and working fine.
Wow, that has been a lot of work for you.

I have the uploaded "hardware module" plugged into my D8 receiver on the desk in front of me. Taranis tx. tuned on, rx. turned on. Discovered the new RPM sensor.
Then I ran my little magnetic stirrer and taped the hall sensor on top of the plastic plate, over the rotating magnets.
I then see a figure of 780 RPM on the tx. Rising to 1040 when I power my mixer with a higher voltage battery.

I don't yet know if I should wire in a resistor in the signal lead from the CDI unit. Possibly not, but I will add a 10 k resistor to be sure. If it does not work, I can remove it.

I will install it in the plane and tie it down tomorrow, start up the engine and see how it works in practice.
Report in again after that!

Happy days!

Many thanks.

Jim.
Last edited by Endorphin on Sat Feb 22, 2020 10:58 am, edited 1 time in total.

Post Reply

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