News:

Registered a URL and setup a forum as the IPCam stuff really needed its own site vs my irregular blog posts about IPCam hacking at http://www.computersolutions.cn/blog

Author Topic: controlling stepper motors - solved  (Read 28763 times)

May 29, 2013, 09:50:39 am
Q: Is there any hope of using the led / light sensor / end switches as freely configurable IO? Would that just be a matter of changing things in kernel?

Thanks, I'll PM you shortly about being a guinea pig.

May 29, 2013, 04:20:12 pm

-Light sensor: Not possible, it's not connected to the digital part of camera electronics - light sensor + IR leds are implemented as analog circuit

-LED: yes, should be available for general purpose I/O (it's tied to PORT4 pin bitmask 0x400)

-Alarm connector: haven't checked that myself yet, I assume one input and one relay-controlled output should be possible.

-Camera edge/position sensors: in total, there are 4 GPIO pins (I'm using them to access sd/mmc card)

In ARM7/uClinux due to lack of MMU there is no memory protection, so each process can access the whole address space, including I/O mapped area. So you don't even need to modify the kernel, just need to be sure there's no conflict while accessing the same pin by different processes/threads.

May 29, 2013, 08:13:42 pm
even though it's trivial to access the camera LED from a user-space app, I still went ahead and built a simple driver for it...
This should help make accessing it a little more standard and simple.
you'll be able to do the following
Code: [Select]
; turn LED on
echo 1 > /dev/camLED

; turn LED off
echo 0 > /dev/camLED

; flash LED
; cmd format: f,[count],[on_delay_millisec],[off_delay_millisec]
; flash LED 10 times, on for 0.5 sec, off for 0.5 sec
echo f,10,500,500 > /dev/camLED


how does something like this sound? feedback is welcome...
« Last Edit: May 30, 2013, 03:20:48 am by changosurf »

May 30, 2013, 03:32:17 am
Here's a video of the ROV I built chasing a ball using openCV

http://www.youtube.com/watch?v=urZGj7wPN3w
« Last Edit: May 30, 2013, 03:54:51 am by Guzz »

May 30, 2013, 04:14:42 am
-Light sensor: Not possible, it's not connected to the digital part of camera electronics - light sensor + IR leds are implemented as analog circuit

But then how is this functionality enabled / disabled? It's a setting in the web interface.

EDIT: This appears to differ on different models /clones. I will put some research into this.
Further more, my model only has an audio output (that has no documentation) and no power / network leds (apart from the ones on the ethernet plug)

EDIT2: Would the audio output be able to drive pwm?

-Alarm connector: haven't checked that myself yet, I assume one input and one relay-controlled output should be possible.

Would it be possible to configure the input as an output? (non-relay of course)

What about pwm? I suppose this would have to be implemented in kernel?

I'm sorry to be bothering you with all these questions, but you're an invaluable source of information for me ;)
« Last Edit: May 30, 2013, 04:41:48 am by Guzz »

May 30, 2013, 10:45:12 am

You're right, different clones are not identical, perhaps in your case they used the "green" LED pin to control the IR Leds ?
Anyway, I'm sure that pin is available somewhere on the main PCB board (or on the 2nd smaller camera PCB).

Controlling anything external with the audio output would be a challenge, not straightforward, but possible as a kind of interesting "gymnastics". For example you could build a simple frequency-to-voltage converter ( LM2907 IC should do the job ) and then play/generate special waveforms :)

Quote
Would it be possible to configure the input as an output? (non-relay of course)

No, you would need to find the controlling signal and rewire the connector

Quote
What about pwm? I suppose this would have to be implemented in kernel?

To get any degree of precision and repeatability it must be done in the kernel. The stepper driver kindly created by changosurf is a good candidate for such a extension. 


May 30, 2013, 09:20:01 pm
ok, Im attaching an initial version of the ptz & LED drivers for testing.
decompress the archive into the 'linux*/drivers' directory in your uClinux build root
(in my case it was the 'linux-3.1/drivers' directory, since im building on the 3.1 kernel).

then, you'll need to modify two files at the root of the 'drivers' directory

Code: [Select]
;in drivers/Kconfig, add the following line toward the end
;before the last 'endmenu' entry

source "drivers/foscam/Kconfig"

;in drivers/Makefile, add the following line at the end

obj-${CONFIG_FOSCAM} += foscam/

re-compile, flash the camera, and see if it works.
the ptz driver should initialize and calibrate on startup.
check the comments within ptz.c/camLED.c source files for more info on how to use the drivers.
please let me know if you have any problems compiling or using the driver.
feedback/questions are welcome.

EDIT:
I just realized that the driver design needs to be modified.
It currently completely blocks the kernel while the motors are being used.
I apologize, this was my first attempt at writing a linux device driver.
Apparently, I should be using 'kernel_thread' or some similar method to spin off a thread within the driver in order to not completely block the kernel? advice is welcome...
Anyway, Im going to try to fix the blocking problem, but in the meantime, the first version of the 'blocking' driver is still available for anyone who would like to play with it.
« Last Edit: May 31, 2013, 07:34:00 pm by changosurf »