Closed twistedwings closed 3 years ago
Are you using an Arduino 8mhz (3.3v) or 16mhz (5v)?
16mhz (5v)
Ok. Better with 16mhz
In escCastle.h I've added in line 21 #define FIXED_CALIB
and #define DEBUG_CALIB
Please make the following tests:
Test 1: Uncomment #define FIXED_CALIB
and check the telemetry log again. This fixes the telemetry calibration. Values should be more stable
Test 2: Uncomment #define DEBUG_CALIB
and connect TX to TTL RX and open a serial monitor at 115200 baud. Connect Arduino and heli GNDs (do not connect ttl vcc to the arduino) and post the output
I will give it a try. Should #define FIXED_CALIB be uncommented for Test 2 too ?
It doesn't matter for Test 2
Test 1: I don't see an improvement https://drive.google.com/file/d/1QFCHxxZyTn3DXSFlbpYtlt01Juk3M-wP/view?usp=sharing
Test 2: https://drive.google.com/file/d/1YpEXI038_ywlZ04W7kG70JUPnYJa2uek/view?usp=sharing
I addition to the esc, do you have enabled other sensors in the Arduino config?
no, castle esc is the only sensor.
Castle telemetry involves measuring time very precisely. Atmega328 has only one 16-bit timer with one timer interrupt (already used to measure the pwm signal from the receiver) which forced me to measure the telemetry with a pin interrupt (less precise as to when it happened as it maybe delayed by other interrupts) rather than the precise timer interrupt and Test 1 confirms that telemetry readings are sometimes delayed by other interrupts (software serial for smartport makes an intensive use of them). The deviations in Test 1 are only to one side (increasing the values, not also decreasing as before the test). The difference is that the calibration scaler (based on telemetry) is fixed rather than adjusted every 10 frames, and a bigger (delayed) scaler means lower telemetry values. Unfortunately until next month or so I won't be able to test with my castle esc to compare the deviations, but I doubt if something can be improved in this regard. So all in all castle telemetry is on the limit (or a bit beyond) of what atmega328 can do
I suggest the following:
#define FIXED_CALIB
uncommented as it produces less errors given that 1 of 2 variables are fixed. I will probably make this the default behaviour (also comment again #define DEBUG_CALIB
as is increasing the chip load)Possible solutions:
I had a quick look at the code and have the following suggestion: Why not simply "pass thru" the RC input and use the 16-bit timer for castle telemetry ?
Pass thru is not possible, because castle esc requires an inverted pwm signal when activating the telemetry
To invert the pwm signal from the RX it is needed:
I don't think there is another way without using the 16-bit time, but suggestions are very welcome
IMHO there is no need to measure the pulse length or to generate a pwm signal. The rc output (to esc) should be the same as the rc input (from receiver) but inverted. If the rc input goes high you'll get an interrupt and can switch the rc output to low. If the rc input goes low you'll get an interrupt and can switch the rc output to high. So for this "rc pass thru" no timer is needed at all and latency would be almost zero.
That has the same issue as the telemetry (I tried that time ago), it relies on a pin interrupt, that fires and interrupt routine which can be delayed in the same way by other interrupts, resulting in a unstable signal increasing for small periods the motor throttle. Timer interrupt is needed as it saves the time when it was fired despite when the routine will be processed. Pwm is needed as is the only way that guarantees the length of the pulse, otherwise same delay may occur. It's not latency the issue (indeed current latency is up to 20ms, but not an issue), is the accuracy of the signal. The delays producing this issue are around 0.1ms (100μs)
OK, I see. Then I hope to see a STM32F103 port someday. An alternative solution might be a hardware inverter for the rc input.
Maybe the SBUS solution is worth thinking about since many FrSky receivers have an inverted SBUS signal.
Support for ATMega328PB and ATMega2560 has been added. Those boards solves the issue of the erratic reading for Castle ESC. Pololu ATMega328PB recommended
I have made a telemetry log with my heli on the bench. RPM=0, lipo voltage 23.0V all the time. The telemetry values look strange.
Here is the log: https://drive.google.com/file/d/1Tes9JJHe6Kpq8qTiYFw9zbXp99co7ER8/view?usp=sharing
Talon 90 Radiomaster TX16S OpenTX 2.3.10