PDA

View Full Version : RX to PIC to rs232


Alex Talsma
Jun 11, 2004, 01:08 PM
Hi There,

A Nikon Coolpix can be controlled by a PC via a RS232 connection. There are serveral progs to do this (great work guys). Now I would like to send some strings from a PIC or other component that is controlled by an RX. So I can take my coolpix up in the sky and control it in flight without servo's. Has anyone got an idea or a place to start?

greetings,
Alex

vintage1
Jun 11, 2004, 01:21 PM
Yes. If you pick up the pulse train to the decoder chip, thats a sequence of spikes whose spacing is each servo channel position, (1-2ms typcally I think) and a long sync pause gap. (>10ms I think)

Its a fairly easy place to grab the signal from. You then need to use the spikes to control timers to decode each servo position into RAM memory locations, and identify the sync pause.

My instinct would be to have a free running timer somewhere, and use the spikes to generate high proiority interrupts which would identify the last channel and store the timer value in it, and reset the timer to null. If the timer was above a certain value, thats a sync pause, and reset the timer and go to channel one.

How you then take your 8 or so binary valued locations and shove then down an RS232 is up to you.

OmegaDot
Jun 16, 2004, 11:24 PM
First off, select a PIC that has a hardware USART to make the RS-232 serial output easier. I have used a 16F628 to send out strings (for data logging).

For your application, you only need to be concerned about the pulse width of the single Rx channel that you attach you module/camera to. You only need to go direct to the decoder chip if you want the whole pulse train with one input to the PIC. You can just go to the normal channel connection (ie: where you would plug a servo into)

Lets suppose this channel is controlled by a switch on the Tx (could be a stick or knob too). The pulse width will range from 1-2ms depending on the switch position. So, define 1.5ms as a test condition.

If your PIC has no other job but to wait for a camera trigger, then you can simply poll the input pin in a loop until the Rx pulse starts (about 50 times/sec). Measure the pulse width by counting the iterations of a timed loop until the pulse drops again. Compare the count to your limit and decide if you need to send a string.


Your text strings would be predefined and stored in character sequence. Where you store them depends on how long they are. If there only a few characters, copying them to ram during your init routine is convenient.

To write a string, you pop on character at a time into the USART write register and wait for a status flag to indicate the USART is ready for more. Then you increment the address where you get the char from and repeat until all chars are sent.



When done, go back and monitor the channel pulse width until it returns to the inactive state so you don't send repeated strings.

OmegaDot
Jun 16, 2004, 11:29 PM
Forgot to mention... The USART on the PIC will output the serial string at 0 to 4.8v levels (assuming you power it from your flight pack). You will need a line driver IC (such as a MAX232 or similar) to bring the signal voltages to +/-12v per RS-232 spec.

Alex Talsma
Jun 17, 2004, 09:53 AM
Hi OmegaDot,

Thanks for your detailed information. This is the way to go.... My problem is the programming. I don't have the skills to prog this ... yet. Maybe if there is a (JAL) example somewhere with some routines in it I can give it a try? Or would you make me an example?

CU,
Alex

Phildc
Jun 30, 2004, 07:35 AM
Hello Alex,
Merging external control channels could be included as an additional topic in this research project. But only in the future.
Anyway, and at a first glance, the bandwith for RS232 would be quite limited in PPM.
Do you have samples of the commands that your CoolPix is awaiting, and the "format and protocols" of the RS232 communication?
Thanks,
Philippe
Brussels

see the '(simple)PCM' project in 'Article' at:
My club's website (http://www.jdm-nivelles.be)

Alex Talsma
Jun 30, 2004, 01:23 PM
Wow your quite an expert :) Thanks for your help. If I could remote trigger the shutter of the camera and switch in flight from photo to video mode it would be perfect. Only controlling the shutter is good enough. Of course I can do this with a tiny servo, but this version is more fun...

Here you can find the protocol:

http://vyskocil.free.fr/coolcom/MC-EU1%20Protocol.txt

By the way: Very interesting PCM project with nice software.
I'm gonna read it right away.

CU,
Alex

Phildc
Jun 30, 2004, 04:30 PM
Alex,
Had a quick look to the protocol. Doesn't seem to bad.
Before going to a PIC controlled on a receiver channel, I'd like to
check by a small PC program sending and receiving on COMx.
So we can check that the simple protocol works and does what we expect
to do in the air. And we can finalize the design of the commands we want to
transmit.
When satisfied with the testing, we could export to a PIC solution.
As I do not have a CoolPix, I would ask you to do the testing and
report the results.
Please be prepared with a COM plug to your PC (if needed connected to
a serial to USB converter, in case you have no COM port) that fits your
CoolPix on the other side. I can tell you the PC wiring if you need (just transmit, receive and ground). Don't know the CoolPix wiring (for the test you can maybe just use the PC cable coming with the CoolPix IF IT IS A SERIAL COM CONNECTION !?!).
Later, you will anyway have to do a connection in the plane.

Please wait a few days for a PC prototype.
In case of success on the PIC, I would propose to make it available
as freeware on the web. Do you agree?

Other question: which type of transmitter are you going to use? With a sophisticated one, it could be easier to transmit multiple commands. Also interesting to know is the number of free channels on the receiver.

Philippe

Alex Talsma
Jun 30, 2004, 05:06 PM
Hi Phillippe,

Your proposal sounds great!

As far as I know is the Coolpix cable is a sort of duo cable with USB and SERIAL connection. Perhaps I"ll have to modify the Coolpix cable to connect it to a COM port but thats no problem. I'll do the test work and reports

I'll use a Multiplex Cockpit TX and a Schulze 840 as RX (8 channels). At this moment there are 4 channels available for controlling the PIC.

Making it freeware is a great idea!

CU,
Alex

Phildc
Jul 01, 2004, 04:32 AM
I propose the following:
I propose to exchange our mail adresses by PM to be able to send/receive exe's and log's.
On this forum, we will post a summary of the tests progresses.

Additional question: what is the command for zooming? How do you think it works? By steps or continuously by holding? Idea of the timing?
Also can you setup to infinity, so we do not have to half press for 1 second before we full press, 'cause the plane will change position!

Here a first view of what the test soft could look like...

Philippe

Alex Talsma
Jul 01, 2004, 11:58 AM
This interface looks cool, I've sent you a PM with more info and my e-mail adres . Zooming is described in Vyskocil his document. Did you see that?

Alex Talsma
Jul 01, 2004, 12:12 PM
I will fix this cable as soon I've received the camera.

http://delphys.net/d.holmes/photos/coolpix_e990/DSCN3959_diagram_6b_600x500q5.jpg

Phildc
Jul 01, 2004, 03:43 PM
Will just add zoom in press, zoom in release, zoom out press, zoom out release and you will determine by the tests what happens and what we need onboard, with which timing. Maybe just have 2 positions wide and tele.
Do you also want to take short videos?? Is the command present on the device?

Philippe

Alex Talsma
Jul 01, 2004, 05:08 PM
I would like to take video's, but I don't think there is a command available to set the camera in video mode. If there is it would be great. A shutter command will start recording, another shutter command will stop. I'll search for some information about this one...

mmormota
Jul 01, 2004, 05:59 PM
Forgot to mention... The USART on the PIC will output the serial string at 0 to 4.8v levels (assuming you power it from your flight pack). You will need a line driver IC (such as a MAX232 or similar) to bring the signal voltages to +/-12v per RS-232 spec.

I am pretty sure the driver is not necessary, the camera most probably works with logic levels too. (inverting is necessary, not sure if the pic usart can invert or needs external inverter)

PHaze
Jul 01, 2004, 08:48 PM
Which Coolpix are we talking about here? There are quite a few models.

Alex Talsma
Jul 02, 2004, 01:36 AM
Hi Phaze,

All coolpix cams that have the "duo" connector or a straight forward rs232 connector:

For example:

Coolpix 880
Coolpix 995
Coolpix 5000
Coolpix 5700
Coolpix 4500
...

greetings,
Alex

Phildc
Jul 02, 2004, 05:00 AM
I am pretty sure the driver is not necessary, the camera most probably works with logic levels too. (inverting is necessary, not sure if the pic usart can invert or needs external inverter)

You are probably right, we will check in the 2nd ("PIC") phase.
In my projects, the word "simple" means that I try to avoid all unnecessary stuff (additional transistors, MAX232 a.s.o. that modern PC technology and microcontrollers imbedded functions make unnecessary.

Projects in 'Articles' at JDM Nivelles (30km south of Brussels Belgium) website (http://www.jdm-nivelles.be)

(simple)PCM and simulators will be displayed at our 2004 Air Show:
Come see us, and win a 940Euros plane+radio+eqipmt

Alex Talsma
Jul 02, 2004, 07:56 AM
Okee new developments:

I just found out that only the more professional Coolpix models haven the serial AND usb connector with the MC-EU1 remote control protocol. The more compactsize camera only have an USB interface. Regarding this site:

http://aristarco.cjb.net/

limited remote control options are available via the USB connector.

That implies that "my" TX/RX switch has to be USB instead of Serial. Is this a problem Phillipe? I don't know how this protocol looks like. Maybe we need a "USB spy" to snoop the dataline. Can you control a USB port with your software?

Phildc
Jul 02, 2004, 08:11 AM
Bad news.
My experience is on serial RS232-like connections. This of course includes using a serial-to-USB converter which is the same to the software.
Real USB conn. is much more complex, especially for a simple control of camera functions.
About PIC I did not use USB till now because the existing USB pics are not flash models and the development is not easy for prototypes and small series.
But here you are speaking about real USB comm.
So we have a problem!
Anybody having a clue to continue this project?
Broadening the project can also be a way to go: which light cameras are RS232 compatible?
For info, my PC dev is Borland C++ 3.
Philippe

Phildc
Jul 02, 2004, 08:22 AM
Ok, this soft could be use to send some commands and spy the protocol.
Could give us an idea of how complex it is.
But sorry, I am not feeling confident to build an USB experience with such a first development.
Again, anybody willing to help?

Alex Talsma
Jul 02, 2004, 09:46 AM
Maybe we can try first with a simple device. I'll search for a DIY USB spy device.
In a way this project only becomes more interesting... Let's give it a try... If necessary I'll come over to Brussel ;-) I'am inspired.

CU,
Alex

Phildc
Jul 03, 2004, 05:45 AM
There are 2 PIC's supporting USB, but they are not flash. (I find UV lengthy for developing).
Anyone having USB support on 'normal' PIC's?
Thanks for any clue

PHaze
Jul 05, 2004, 01:57 PM
I found a few flash based PICs with USB support.

PIC18F2455 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010273)
PIC18F4455 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010293)
PIC18F2550 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010280)
PIC18F4550 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1335&dDocName=en010300)

Mr.RC-CAM
Jul 05, 2004, 02:24 PM
You won't be able to use the USB enabled microcontrollers to talk to your camera. You need a USB host controller, not a USB device/peripheral controller.

RC-CAM

Alex Talsma
Jul 05, 2004, 02:36 PM
Hi RC-CAM,

Thanks for your comment. Have you got any suggestions controling the Coolpix by USB without a PC. Or is that in your opinion impossible if even MicroChips won't do the job?

CU,
Alex

Mr.RC-CAM
Jul 05, 2004, 02:50 PM
You can use a microcontroller like a PIC. Just pair it up with the USB host controller. The task will be challenging.

RC-CAM

PHaze
Jul 05, 2004, 05:09 PM
Thanks RC-CAM. I don't know much about USB myself. Just trying to help.

So now, armed with this new tidbit about the type of USB controller required, I found 2 Atmel microcontrollers with USB host controllers built in.

AT43USB370 (http://www.atmel.com/dyn/products/product_card.asp?part_id=3046)
AT43USB380 (http://www.atmel.com/dyn/products/product_card.asp?part_id=3393)

Phildc
Jul 06, 2004, 04:58 AM
Thanks for all the info, still thinking to use USB some time for this type of developments related to RC.

For the time being, we (Alex Talsma and myself, it becomes an European international project :) !) are looking into a simpler solution that would work quickly.

Alex would open his camera and get to the zoom in and out plus shutter contacts.

A PIC 12F629/12F675 would output 4 voltages, based on the state of 2 RC channels that could be sticks, pots or switches. Using 3 positions on each channel: left, centre and right. Bad signals (spikes?) would be rejected.
Working with one channel only (hence shutter only) would also be supported.

I know this type of solution already exists, but doing our own lets us free to develop more.

This device could also be used for other functions.

A more complex project could be done later, involving max 16 on/off channels on 1 PPM channel, without changing the transmitter, just using the monitor/student connector (Hitec Eclipse 7 will be the first candidate).

Anyone else wanting to participate in the tests? You must be able to 'burn' a PIC, solder and look at some signals.

More news soon,

Philippe.

PC+RC projects: see 'Articles' at my club's website (http://www.jdm-nivelles.be)

vintage1
Jul 06, 2004, 07:26 AM
Hmm. I was thinking more on the lines of presetting the zoom, and using a servo to press the button to take pictures :)

Another servo could do duty for zoom control as well.

Hope to loft my Coolpix 775 aloft when I build a big enough plane.

Phildc
Jul 06, 2004, 11:50 AM
No servos in this design, pure electronics.
But will have to make connections into the camera. And the PIC will be
inside or close to the camera.

Using 2 channels.
2x2 wires (2 per channel: left on, right on, none if centre) will bring voltages to the switch contacts,
e.g. zoom in, zoom out by a 3-pos switch or pot on the transmitter
and press shutter (+ half-Press??) by another switch on the transmitter

Will probably need to take the camera voltage as PIC power, and lower
the RC servo signal from the receiver by a resistor + zener (3.3V ?)

Philippe

Phildc
Jul 07, 2004, 02:26 PM
Alex,
You can prepare your PIC programmer, a PIC 12F629, a test socket and 2 servo cables. Plus LED's and resistors to see output voltages when you play with the transmitter.
At startup, I will look at the voltage on the wire to know what the rest (centre signal received) voltage must be on the outputs. Will invert output when a left or right signal is received.
Your direct mail is apparently down.
Philippe.

Mr.RC-CAM
Jul 07, 2004, 02:44 PM
I will look at the voltage on the wire to know what the rest (centre signal received) voltage must be on the outputs.

Keep in mind that the servo signal is not based on voltage. It is a pulse width control method. Essentially, its absolute voltage is ignored, so you do not need to measure it. You could convert the PWM to a voltage, but that just adds more parts. Just measure the pulse timing.

RC-CAM

Alex Talsma
Jul 07, 2004, 04:27 PM
Great progress in Belgium ;-). Don't know what's wrong with my e-mail. Gonna fix it tommorow so I can receive your files!

Phildc
Jul 07, 2004, 05:39 PM
Keep in mind that the servo signal is not based on voltage. It is a pulse width control method. Essentially, its absolute voltage is ignored, so you do not need to measure it. You could convert the PWM to a voltage, but that just adds more parts. Just measure the pulse timing.

RC-CAM

Sorry, I was unclear. I mean that the PIC microcode will look at the logic voltage present on the camera switch at start-up. If a logic '0' is found, the microcode will assume that it must set a '0' on this wire at rest (PPM width around center value, I took -50% to +50%) , and a '1' when a command is received (either left or right, which varies the PPM width received).
If a '1' is found at startup, the logic will be reversed.
!! This automatic polarity feature must still be tested !!
There will be a separate wire for left and for right. Other applications are of course possible.
The proto already does the job, just some fine tuning to do. E.g. errors rejection a.s.o.

Based on the same design, I worked in parallel on an audio 'lost plane' beacon that detects the absence of signal, or a PPM out of limits. At power-on, and if absence of signal or corruption of signal is detected, it starts playing OBLADI OBLADA on a small piezo. Just a 12F629, a piezo and some wires, plus a ferrite coil to avoid interferences. This one is finished. It just plugs in a servo terminal or on a Y-harness if no terminal is free.

Philippe

Phildc
Jul 08, 2004, 06:51 AM
A neigbour project grew up and can be found in same forum in another thread 'Audio lost plane beacon - finder, locator'
It plugs as a servo, has only 2 components and plays 'Obladi-oblada'

Philippe
Brussels / Bruxelles / Brussel Belgium

Projects: see 'Articles' at My club's website (http://www.jdm-nivelles.be)
Keywords: RC model modelisme FMS cable PCM servo joystick trim expo avion perdu PC software logiciel simulator PIC

Phildc
Jul 10, 2004, 08:11 AM
Based on same routines, already tested by Alex.
See separate thread 'Audio lost plane beacon' on same forum.
You need to burn a PIC 12F629, and add a piezo transducer and servo cable.

Philippe

Look at 'Articles' at my club's website (http://www.jdm-nivelles.be)