Solution: Sync Flash to GS Camera with use of the XVS PIN and an Pico or Arduino
@lucyhattersley is already working on this.
Since Oct 2, 2026.
Assessment
This issue has not been assessed yet.
Description
I was working on that for 2 days and finally found a perfect solution that is not in the docs. I don't know how to make a Pull Request correctly, but maybe someone else will use my information.
I Used a BC547 transistor
XVS--1k--BASE
PicoPIN--1k--COLLECTOR
GND--EMITTER
GND has to be connected between Pico and Camera.
I am collecting the picture with an C++ Code in StillCapure Mode and fixed FrameDurationTime to 1ms. If you change this, you should change the FLASH_TIMER_DURATION too. This could also be done with serial commands directly to the Pico to match the values (not in the code).
I am always starting and stopping the camera in the code, because I don't want to flash all the time.
cam_device->start();
wait till captured...
cam_device->stop();
The XVS Pin triggers twice for every pic.
HIGH - 20us - LOW - 32384us - (takes picture for FrameDurationTime (e.g. 1000us)) - HIGH - 20us - LOW
The picture is taken before(!!!) the second HIGH signal.
So the timing is important!
I am triggering the flash 32384us after the first HIGH signal.
Arduino Code:
#define TriggerPIN 3 //D03 (Uno, Nano, Mini)
#define StatusLED 13 //D13
// to find the perfect timing window set FLASH_TIMER_DURATION=2 and then change the FLASH_TIMER_DELAY up and down to find the limits (point the camera on the Status LED and watch the brightness change)
// 502 off
// 503 weak
// 504 better
// 505 full
// .
// .
// .
// 518 full
// 519 better
// 520 weak
// 521 off
`
#define FLASH_TIMER_DELAY 505 // (16 MHz / 1024) * 0.032384 - 1 ≈ 505 für 32,384ms Interrupt
#define FLASH_TIMER_DURATION 15 // (16 MHz / 1024) * 0.001024 - 1 ≈ 15 für 1,024ms Interrupt
unsigned long starttime, endtime, duration, pause;
unsigned int triggered=0, status=0, i=0, FLASH_ON=0;
void setup() {
pinMode(StatusLED,OUTPUT); // set PIN to OUTPUT
digitalWrite(StatusLED,LOW); // set PIN to LOW (StatusLED OFF)
pinMode(TriggerPIN,INPUT_PULLUP); // set PIN to INPUT
attachInterrupt(digitalPinToInterrupt(TriggerPIN),TriggerISR,CHANGE); // SET InterruptPIN, ISR and Mode
// Timer
TCCR1A = 0;
TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10); // CTC Modus, Prescaler 1024
OCR1A = FLASH_TIMER_DELAY;
TIMSK1 = (1 << OCIE1A); // Timer1 Compare Match Interrupt aktivieren
interrupts(); // enable Interrupts
Serial.begin(115200); // initialize serial
}
void loop() {
if (triggered==0) {
TCNT1 = 0; // Timer reset
}
if (status==1) {
status=0;
Serial.println(i);
Serial.print("pause:");
Serial.print(pause/1000);
Serial.println("ms");
Serial.print("duration:");
Serial.print(duration);
Serial.println("us");
Serial.println("-------------------------");
i++;
}
}
void TriggerISR() { // ISR function excutes when PIN is triggered
if (digitalRead(TriggerPIN)==HIGH) { // check if PIN is high or low and set Flash PIN
if (triggered==0) {
triggered=1;
TCNT1 = 0; // Timer reset
}
starttime = micros();
pause=(starttime-endtime);
}
else {
endtime = micros();
duration=endtime-starttime;
status=1; // allow posting new Timings
}
}
ISR(TIMER1_COMPA_vect) { // Timer
if (FLASH_ON==0) {
digitalWrite(StatusLED,HIGH);
TCNT1 = FLASH_TIMER_DELAY - FLASH_TIMER_DURATION; // Timer reset to 1ms
FLASH_ON=1;
}
else {
digitalWrite(StatusLED,LOW);
FLASH_ON=0;
triggered=0;
}
}
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from raspberrypi/documentation
-
One Time Programmable memory map incorrectMay be free again @timg236 claimed this 85 days ago, and no pull request is open. Openwhite paper
raspberrypi/documentation#4319 · 2 comments · 2 assignees ·
-
Pico-SDK use of Red Text on Pure Black Background Strains EyesMay be free again @katshann-raspberry claimed this 100 days ago, and no pull request is open. Openbacklog doxygen
raspberrypi/documentation#4156 · 6 comments · 1 assignee ·
-
GPIO and the 40-pin header: legend embedded in associated image is outdatedMay be free again @stevedavies-rp claimed this 100 days ago, and no pull request is open. Openbacklog diagram
raspberrypi/documentation#4124 · 3 comments · 1 assignee ·
-
Update needed to "Raspberry Pi Debug Probe" for PICO 2May be free again @katshann-raspberry claimed this 100 days ago, and no pull request is open. Openbacklog restructure rp2040
raspberrypi/documentation#4003 · 10 comments · 1 assignee ·
-
How to change the primary UART of a Raspberry PiMay be free again @katshann-raspberry claimed this 99 days ago, and no pull request is open. Openbacklog documentation troubleshooting
raspberrypi/documentation#3938 · 1 comment · 1 assignee ·
All issues in raspberrypi/documentation
Similar issues
-
integration: media_player
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
home-assistant/core#193344 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
daniel-ospina/tortoise#13607 ·
Maintainers usually reply within 1 day
-
documentation priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day