Closed michael-blue2 closed 7 years ago
You want access your cam's osd control signal from FC? Similar function has been brought up couples of times in the past. What is your cam? And how did you know it's uart?
As far as I know, most cameras use I2C or SPI to control their setup.
@Arakon I've never seen such a beast! Pointers?
Most popular cameras (such as hs1117,runcam, foxeer) are use analog control signal for camera menu. OSD board for my foxeer XAT600M/XAT1200M cam hasn't any chip, but have 5 buttons and array of resistors.
i know its analog signal, and all the cameras that i know are using that 5 button or the nob that moves up/down/left/right. As you have already mentioned most cameras are using I2C which gathers the analog signal from the osd board. So by that you mean that there is no any way of this to work?
You may be able to do with PWM coupled with a RC filter 🤔
with pwm? maybe its the only way doing it as our cameras are analog yet and getting a pupse signal from the osd control cable
It would be great to maybe provide a standard that could be sent to the cam manufacturers. They could provide options in one way and the FC provide the settings in the other :)
@michael-blue2 Use 1 PWM output with a RC filter. The RC filter rectifies the PWM wave form into voltage level that reflects duty ratio of the wave form. Anyone willing to do some experiment? :)
@jflyper, @michael-blue2: Or use one of the DACs present on the STM32 chips.
Wasn't DAC hard to use? I thought it's kind of fixed pin-wise...
Yes, they seem to be shared with SPI1 SCK / NSS for both F3 and F4. :-( Why, STM, why?
Just an observation guys, believe this functionality is already implemented in tbs core pro, whilst that doesn't help particularly, it does at least indicate is isn't rocket science
What about a digital potentiometer in rheostat mode that mimics the resistances from the osd cable? The potentiometer could be connected to the FC via I2C, SPI, or similar.
@marcroe We can do dozens of things if we can add a circuit.
I'm currently working on a way of controlling HS1177-style OSD via a spare GPIO, it'll require user to build a simple RC filter like the ones used for PWM RSSI concersion to analog voltage. I hope to create a PR soon.
UI !?
A sneak peek, currently using Arduino, going to port to STM32 tonight or tomorrow :-) https://youtu.be/mtNUbYJ27TU
Check out the related PRs
Will this be able only from an extra motor output? Most fcs have 4 motor outputs as the bf fc aswell
Feature is in master for a while and works for many people. There's more to be done, e.g. rework software PWM version to hone it for F4/F7 and also allow hardware PWM timer sharing, but it'll take some time.
I am not sure if asking in a right place, but... For foxeer it looks to be working fine, but runcam cameras require bit higher voltage on control pin. For entering menu it requires 1.5 volts on OSD pin, I tried changing camera_control_ref_voltage, but that gives 0.6-1 volt range, can it be rised ? Or maybe adding runcam as option with different PWM values ? If required I can measure required voltages for all buttons...
I have implemented and tested this functionality using RunCam cameras.
They use 3.2-3.4V reference with resistor values of 45k/27k/15k/6.8k/0 vs 47k inside the camera, just like every other camera on the market (I have asked lots of people to measure their OSD joystick resistance values and they never deviated by more than 5% allowed by resistor tolerances). That gives 3.3 * 45/(45+47) ~= 1.6V
for the enter
keypress. Something is wrong with your setup.
but that gives 0.6-1 volt range
I don't understand what you intend by this phrase, please elaborate.
I use 470 Ohm between FC and camera. I see PWM output on oscilloscope and there is about 30% duty cycle, that matches to voltage I get after resistor. Actually to get 1.6 volt there should be 50% duty cycle. FC : Airbot F4 Special Edition (9250), RC4. Running @8kHz
At which point are you scoping into the signal, before the resistor (FC side) or after the resistor (Camera side)? If you have an analog scope, watch the DC value on the camera side as well.
Which FC you're using, how did you set up the camera_control
feature and which camera is it?
@GrishaLutsenko firmware outputs PWM with duty cycle of cameraRefVoltage / adcRefVoltage * 45K / (45K + 47K)
for enter
, which is roughtly 49%
. If it outputs something else then there is an issue elsewhere, there should be 49% duty cycle at camera_control
designated pin.
Which target your FC uses, which resource did you select for camera_control
, is it software_pwm
or hardware_pwm
?
Hm... About feature I am trying now but it don't shows me it at all. But definitely I have output on assigned pin and it is different according to camera.
So what I see is when throttle in MID and I press roll left - I get 1.6 v (and 50% duty cycle) but duration is not enough to enter OSD. If I enter OSD with joystick I can navigate down in list, nothing else works.
When throttle is LOW and I push pitch UP, then I get about 30% duty and see 1 volt after resistor.
Camera is Runcam Swift 1
Setup now is
camera_control_mode = HARDWARE_PWM Allowed values: HARDWARE_PWM, SOFTWARE_PWM, DAC
camera_control_ref_voltage = 400 Allowed range: 200 - 400
camera_control_key_delay = 500 Allowed range: 100 - 500
You still didn't tell me how you set it up in software and at which point you're scoping it. This matters greatly. RunCam Swift was one of the cameras I used to develop this feature. P.S. The stick command to enter menu is "yaw right, everything else mid".
I set resource CAMERA_CONTROL 1 A08 (of course before that I cleaned resource, there was motor 6)
After that I started to get PWM output on that pin depending on stick positions.
Please show resource list
command output as well.
Entering CLI Mode, type 'exit' to return, or 'help'
resource BEEPER 1 B04 resource MOTOR 1 B00 resource MOTOR 2 B01 resource MOTOR 3 A03 resource MOTOR 4 A02 resource MOTOR 5 A01 resource PPM 1 B14 resource PWM 1 B14 resource PWM 2 B15 resource PWM 3 C06 resource PWM 4 C07 resource PWM 5 C08 resource PWM 6 C09 resource LED_STRIP 1 A01 resource SERIAL_TX 1 A09 resource SERIAL_TX 3 B10 resource SERIAL_TX 4 A00 resource SERIAL_TX 6 C06 resource SERIAL_RX 1 A10 resource SERIAL_RX 3 B11 resource SERIAL_RX 4 A01 resource SERIAL_RX 6 C07 resource INVERTER 1 C00 resource LED 1 B05 resource SPI_SCK 1 A05 resource SPI_SCK 3 C10 resource SPI_MISO 1 A06 resource SPI_MISO 3 C11 resource SPI_MOSI 1 A07 resource SPI_MOSI 3 C12 resource ESCSERIAL 1 B14 resource CAMERA_CONTROL 1 A08 resource ADC_BATT 1 C02 resource ADC_CURR 1 C01
A00: FREE A01: LED_STRIP A02: MOTOR 4 A03: MOTOR 3 A04: MPU_CS A05: SPI_SCK 1 A06: SPI_MISO 1 A07: SPI_MOSI 1 A08: CAMERA_CONTROL A09: FREE A10: SERIAL_RX 1 A11: USB A12: USB A13: FREE A14: FREE A15: FREE B00: MOTOR 1 B01: MOTOR 2 B02: FREE B03: FLASH_CS B04: BEEPER B05: LED 1 B06: FREE B07: FREE B08: FREE B09: FREE B10: SERIAL_TX 3 B11: FREE B12: FREE B13: FREE B14: FREE B15: FREE C00: INVERTER 1 C01: FREE C02: ADC_BATT C03: FREE C04: MPU_EXTI C05: FREE C06: SERIAL_TX 6 C07: FREE C08: FREE C09: FREE C10: SPI_SCK 3 C11: SPI_MISO 3 C12: SPI_MOSI 3 C13: FREE C14: FREE C15: FREE D02: FREE
DMA1 Stream 0: FREE DMA1 Stream 1: FREE DMA1 Stream 2: FREE DMA1 Stream 3: FREE DMA1 Stream 4: LED_STRIP DMA1 Stream 5: FREE DMA1 Stream 6: FREE DMA1 Stream 7: FREE DMA2 Stream 0: FREE DMA2 Stream 1: FREE DMA2 Stream 2: FREE DMA2 Stream 3: FREE DMA2 Stream 4: ADC DMA2 Stream 5: FREE DMA2 Stream 6: FREE DMA2 Stream 7: FREE
Use: 'resource' to see how to change resources.
I will send you oscilloscope screen now too (for Vref=330, pressing enter)
RunCam cameras register clicks after 125ms, so including settling time you shouldn't need more than 150-180ms.
Vref
should be set to the value measured between camera OSD and GND pins when nothing is connected to them, it's not a tuning parameter to be set arbitrarily.
Is this picture taken by scoping FC side of the resistor or Camera side? Let's revisit your stick commands, please list which you're using for each key.
FC side of course. On camera side is stable voltage. For vref=315 for this graph is 0.8 volts...
What FC you tested with rancam ? Maybe there is issue around F4 board ?
Different FCs, BlueJayF4, CLRacing F4, Matek F405, some F7s.
Hm. So you see graph. Actually now UP and DOWN work correct. Right and left also make change in menu. But for enter I get 30% duty cycle and that is wrong. Btw, have you checked RC4 or some other build ? Maybe in RC4 there is bug around that ? As now almost all works, just wrong value for enter (it matches with UP now)
Yes I have. Please check this infographic and make sure you're using correct stick command for ENTER
.
It's highly unlikely that everything but ENTER
works unless you're on SOFTWARE_PWM
which has issues with duty cycle close to 50%.
Oh, you made me feel idiot, looks I used older infographic where throttle was down and then pitch up for enter.... this way works amazing, thanks you very much.
Btw, why it sends UP when throttle is at 0 and pitch UP ? Not fully removed older variant ? It definitely does it with enter duration, but with UP value
Some weirdness in Stick Commands implementation I presume. I plan on reworking them to minimize delay with modern protocols like SBUS, I'll look into this issue as well. Glad it works for you now!
Thanks again. This is amazing feature as otherwise that was a pain to setup camera correctly. I think I also made my BF fly similar to RF, hard play around settings, pids and TPA.... A bit more and think I will achieve same level of control. And if it will fly same + all benefits in BF that will be amazing... Sorry for offtop :)
I have started working on a wiki page, hopefully soon everyone will be able to enjoy it :-) https://github.com/betaflight/betaflight/wiki/FPV-Camera-Control-(Joystick-Emulation)
P.S. Russian ever-changing weather calls for an ability to change camera exposure, that's part of the reason I started working on it :)
got this working on foxeer arrow v3. had to drop camera_control_key_delay = to 125 to get enter to work reliably. working perfect now though. thanks. awesom feature to have in OSD.
working like a charm with the kakutef4 3.2RC4. Foxeer hs1177standard. resource motor output 6 with camera_control_ref_voltage = 321 with hardware_pwm and 380ohm resistor in series with the 1 cable of the osd. The lua script on the Q X7 is working aswell and the scrolling wheel makes it very easy and fast to use :)
No success. Setup: foxeer arrow v3 330 ohm resistor Motor 5 pin on omnibus f3 fc (pin B07)
Cli parameter camera_control_mode = hardware_pwm camera_control_ref_voltage = 330 camera_control_key_delay = 125 camera_control_internal_resisitance = 470
Sure you released B07 first from motor output ?
@GrishaLutsenko: Releasing the pin is not necessary, motor 5 will not be used if the mixer for a quad is selected. (But releasing the pin won't hurt either.)
But have you done resource camera_control b7
, @iceberg101?
@mikeller I checked on mine F4 board and until I released pin from motor 6 output I had no output for camera there. But for LED strip that works without releasing(used motor 5 out for it). Not sure why, just observed that.
Is it possible to make a feuture that we will connect the osd cable from our camera to a uart port, and change the settings of the camera using Taranis or betaflight osd, without having to take apart each time our quads to connect the osd cable and change the settings of our cameras