Hello, I was building the nRF24 Remote Controller by Solidgeek. But then, I realized that VESC was not receiving the PPM signal correctly. It was lagging by about 0.2[ms]. So when I hooked up a oscilloscope, I saw this.
Period = 1 millisecond
Pulse Width = 516 microsecond.
So… you would Expect to see a value of around 0.5 ms at VESC Right???
This was seen from the VESC side.
0.721 milliseconds. That, was clearly wrong, as I verified the width to be around 0.5 ms beforehand…
So what is going on??? I was eager to investigate this problem further.
I hooked up the ‘hobby RX’ to the VESC, which has been working flawlessly for the past 6 months. I gave a Middle Signal and MAX signal as an Example.
Stick position : Middle
solid 1500 microseconds pulse as Expected.
Stick position : MAX
solid 2000 microseconds pulse also.
AND, when seen from the VESC, it is also correctly perceived.
Stick position : Middle Stick position : MAX
So I got confused here. It can’t be true that VESC looks at the same pulse, then perceives it differently…
And I wondered Maybe it is because analogWrite( ) doesn’t have long enough period(ex.20 ms) between two pulses. If you look at two pulses, they definitely have different period as you can see.
I thought, that MUST be the problem! And tried another code.
Arduino has a library called ‘Servo’, and it is able to output EXACTLY the same pulse as commercial hobby receiver does.
Let me show you the two pulses side by side.
Top is hobby Receiver, Bottom is Arduino
They look exactly the same! Same period(20 millisecond) & same pulse Width(1.5 ms)…
With my hopes high, I hooked the Arduino to the VESC And… drum roll please…
Using Arduino Servo Library
Nope, VESC says it is ‘1.7 milliseconds’…
At this point I was very much confused. This time, VESC actually is saying two Same-looking pulses are different…
I have tried another Method using Timer2 of Arduino, and it did produce somewhat legit pulse.
Using my own Timer2 code
It does have a shorter period, but the pulse is almost spot-on the 1500 microseconds. Yet, VESC reads it as…
Timer2 code pulse, read by VESC
And the above result(1.7 ms) is very similar to the value I got from Servo Library test(1.7 ms).
And I think there exists a reason to it. But can’t figure out what it is…
So conclusion from my own investigation is
- VESC perceives same-looking pulse from hobby Receiver and Arduino differently.
- VESC is able to pick up 1[kHz] signal(analogWrite), but reads it off by 0.2 millliseconds.
- VESC reads both 15ms period & 20ms period Servo signal with width of 1500 us, but reads it off by 0.2 milliseconds. So VESC doesn’t really care about the PERIOD of the signal.
So I am asking for help. If this issue is familiar with you, or if you have Any suggestions, ideas or thoughts, I would really appreciate the comments. Thank you for reading my Topic
p.s.) I actually have done further tests and found out that analogWrite(x) is not read properly by VESC if x is more than or equal to 182. If I go higher, VESC just gives up, and PPM value doesn’t get updated… I have no Idea why that doesn’t work.
analogWrite(182) viewed from Oscilloscope
=> It has about 732 microseconds of width.
analogWrite(182) as read by VESC
=> Tops out at about 1 milliseconds. Which is the period of the signal, actually.