Do While Loop issue


Licensed User
Serial Port RS232/USB timing control

Hi All,

New user to Basic4ppc

I'm designing an app for Windows Mobile to Control via RS232/USB
The shutter speed for a digital camera DSLR through the Bulb port

Problem I'm having is with in the loop to for shots I'm
1) only getting one shot
2) every shot is for 1 second only.

I need it to do each shot with in the loop and have
the shutter stay open for the selected time.

Any ideas what might be the problem?

Many thanks


See code below

' ***Do Suhtter Routine Below***
Begin_Exposure_Speed = 125 '***1/125 of a second***
Total_Exposures = 5 ' *** 5 shots to be done***
This_Exposure = Begin_Exposure_Speed
dly = 1 '***shutter delay between shot time in seconds***

Shot_Count = 1

Computed_Time = 1/This_Exposure

Do While Shot_Count =< Total_Exposures

serial.PortOpen = True '***open shutter***

serial.Output("F") '***fire***

Sleep(Computed_Time * 1000) '***keep shutter open for selected time***

serial.PortOpen = False '***close shutter***

Sleep((dly * 1000)) '***delay between shots***

This_Exposure = This_Exposure * 2
'*** compute next shutter speed***

Computed_Time = 1/This_Exposure

Shot_Count = Shot_Count + 1

Last edited:


Licensed User
We need more information on the hardware setup. By what means does opening and closing the the Serial Port in software actually open and close the shutter on the camera :confused: If you are using the DTR or RTS pin to control it there is a better way. Similarly how does sending "F" actually fire the flash?

Also you won't achieve your required exposure time with any accuracy using software. 1/125 second is 8 mS. For various reasons such short sleep times may vary wildly, in the longer direction, from what you request.


Licensed User
The idea is to use the DTR line of the serial port to actuate the camera. DTR is high (about +6V) whenever the serial port is open for communication, and low (-6V) at all other times.

On RS232 Serial connect Pin 7 Ground, Pin 5 RTS

Connector : One end to bulb input on Camera, to RS 232 port, RS232 adaptor to USB to hook to windows mobile devise.

I was using the Output fuction in an attempt to open port for shutter release.
It has nothing to do with the flash on the camera.

Only thing I'm after is control of shutter.

Any help would be great.

Thank you from the noob :sign0104:


Licensed User
IIt has nothing to do with the flash on the camera. Only thing I'm after is control of shutter.
OK I assumed that sending the "F" fired a flashgun. Why send the "F" at all when you only want to waggle the RTS line?

I personally would open the serial port at the start of the program and close it on exit then set the state of the DTR using the Serial.DTREnable property. Opening and closing the port is expensive in time.

Apart from the exposure time inaccuracy I previously mentioned I can't immediately see why what you wrote doesn't work.

EDIT :- Just noticed your comparison operator is invalid, it should be >=, I don't know if that is your problem. The compiler can be a bit lax at times.
Last edited: