sn-lab / MouseGoggles

A dual-SPI display mouse VR headset, powered by Raspberry Pi and the Godot game engine

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Arduino malfunctioning

monrky opened this issue · comments

hi @misaacson01 hope you are doing well!

The setup I made over the summer uses an Arduino Due to get info from the sensor and pass it to the pi -- we also paired it with miniscope calcium imaging, so we had to figure out a way to synchronize the behavioral data with the neural data. I landed on having the miniscope's DAQ box send out a TTL pulse when the recording started, then send the pulse to the Arduino, which converts it to a keypress using a keyboard emulator. Then I had Godot pick up the keypress and put it in the log file, which seemed to work okay...

However, I noticed that sometimes the Arduino would either shut off or stop sending information midway through the experiments. For instance, I'd notice on the Pi monitor that the Godot scene would just stop updating from the mouse locomotion -- later, we saw this on the Godot logs an absence of TTL pulses/keypresses in certain chunks of the experiment.

I was wondering if you had a similar problem with the Arduino, or maybe it's a problem with bandwidth arising from the continuous TTL pulse input?

Thank you in advance!!!

From what you describe it does sound like it's just on the Arduino side, and I don't think we've seen Arduino issues before. If you're using some custom Arduino code maybe there's some simple issue there, though your general synchronization strategy sounds good!

What's the frequency of TTL pulses? Are you using interrupts or something to catch the pulses? You could post the Arduino code if you like and I could take a look.

TTL pulses are being sent out every frame. Here's my sketch!
VRheadset_TTLsketch_emi.txt

Do you know how what the frequency and pulse width of these TTL pulses are? I'm assuming they're well below 60 Hz and have pulse widths longer than ~15 ms, otherwise I think this code will miss some. Other than that, I don't see any obvious problems, but I also admit that I don't know exactly what happens when the key is pressed and held for a long time. If it keeps sending data this entire time, then I could see it causing issues. Might be worth trying "Keyboard.write()" instead? That would also make it simpler since you wouldn't need to "release".