Battery third (temp) terminal as multipurpose analogue input - page 9 - Hotwire! Hardware Mods, Accessories and Insights - CHDK Forum

Battery third (temp) terminal as multipurpose analogue input

  • 199 Replies
  • 87184 Views
Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #80 on: 23 / January / 2014, 09:34:18 »
Advertisements
But what I don't understand at all is your question why I am using such at all.  I mean I have to have switches somewhere,  no?
Well,  not really.  Switch devices like PhotoMos are used for electrical isolation.   However, you could also simply drive the A/D5 channel directly from one of the output of pins of your Arduino - you don't need a switching device in between.  That's what Recyclojunk64 was trying to tell you when he pointed out that use of USB hubs means that everything shares the same ground.

Typically, there are a couple of ways to do this (all connected to the A/D input pin via your 1K resistor - the on/off  threshold value in the software might need to be tweaked too) :

  • If the Arduino is a 3.3V model then you can probably safely just hook up a digital output to the A/D input pin.
  • If the Arduino outputs can be configured "open collector" then you can also hook directly to the A/D input pin
  • You can uses a simple resistor / npn transistor circuit to create an "open collector" drive
  • You should even be able to use a cheap Si diode to create an "open collector drive.

Does that help? I can draw circuit diagrams but they are pretty elementary.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #81 on: 23 / January / 2014, 09:51:18 »
Wooooohooo! Million thanks to you, guys, especially ahull and waterwingz! Got it working here for the first time. I have "remote" enabled and also the sync option. I changed the 10k resistor to 2.2k, now the GetAdChValue(5) shows a value ~100. Tomorrow I'll start building ten dummies and then will do some sync testing.

But there is one thing. Until now when having the camera  to USB I switched it on and some autostart.lua ran. Know the camera stucks in the ALT-Mode, the autostart script does not run anymore. I suppose the camera is in the play mode?

Changing this back to the original mode - before dealing with both PTP and Remote at the same time - makes it work as expected.
Okay - I've done some more testing and I now see the problem.

With my latest patch,  the camera USB port can communicate via PTP without interference from the Remote functionality.  And A/D channel 5 is used for all the shooting & sync stuff.

However normal USB communications (CHDK loaded or not) puts the camera into playback mode when the USB cable is connected.  This means the A/D channel 5 code performs the default USB remote playback action (photo advance) and does not take a picture.   If you are using CHDKPTP or a CHDK script, you can issue a switch_mode_usb(1) command to go into shooting mode and the A/D channel 5 code should work at that point.  But if you want to do this without a script or ptp message (i.e. camera buttons only) then the usual method of pressing the half pressing the shutter button to switch to shooting mode will not work.

In Karmaschinkens' case,  he is using a startup script and so should be able to add a switch_mode_usb(1) statement to the script and be in business.  As long as his USB hubs are powered before he turns on his cameras.   However,  a better solution for this is needed. I have some crude ideas about adding switch_mode_usb(1) to a remote input device mode that supports A/D triggering (added to the existing  OnePush, TwoPush, CA-1 modes)  but I hope other will have better ideas?
« Last Edit: 23 / January / 2014, 10:30:12 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #82 on: 23 / January / 2014, 12:09:43 »
Karmaschinken - here is a quick diagram of how it could be connected if you choose to connect the cameras up to the 5v Arduino mega without isolation. If you would rather save one resistor per camera (the one connecting to ground) by preventing the arduino from pulling the outputs high (option 2 in reply #80), that is possible, however it does have the danger that if somehow the code goes wrong and the outputs do go to 5v instead of just floating, the ADC inputs may possibly be damaged on the cameras.
I picked the values based on trial and error with my Ixus 65 (I also have plans to hook up a micro to my camera). YMMV, but they gave me temperatures of 10 and 51, AD inputs of 518 and 151, and voltages of 1.4 and 0.43 with the arduino output high and low respectively; all within the acceptable range.


There is another possible problem I just realised, is it possible to switch all the outputs high (or low) at the same time, for normal synced shots? Just a thought really, I have no idea how long it takes for an arduino to switch an output, or if they can be switched simultaneously (or even what sort of sync you want to achieve).


Waterwingz - When the patch eventually goes to SVN, is it going to be using GetAdChValue or is it going to be reading the MMIOs directly? Do you think there could be any delay with GetAdChValue? Has it been measured before? (if not I could compare it against the last test I did on my D20 when it read the values directly)

*

Offline ahull

  • *****
  • 634
Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #83 on: 23 / January / 2014, 12:30:09 »
If you would rather save one resistor per camera (the one connecting to ground) by preventing the arduino from pulling the outputs high (option 2 in reply #80), that is possible, however it does have the danger that if somehow the code goes wrong and the outputs do go to 5v instead of just floating, the ADC inputs may possibly be damaged on the cameras.

Resistors are a lot cheaper
than cameras (assorted selections are even cheaper),  besides I'm sure you need the soldering practice  ;) I would use the level shifter as per the diagram.

One other point, you can pick up an Arduino Nano clone (or pro mini) for a couple of dollars/pounds/flanian pobble beads form ebay these days, so if needs be, you could do some pretty smart timing dances with multiple microcontrollers.

The Nano is a no brainer  to program with built in usb, and the pro mini can be hacked to work from a lipo with very little effort, for 3v3 logic compatibility (but you do need a separate programmer for these).

NOTE: It is the Chinese New year at the moment, so some of these guys may take longer than usual to deliver.
EDIT: I just read the Introductions: section of the 400 Pcs 1/4W 1% 20 kinds ebay advert..  :blink: What the.... have I just ordered?
« Last Edit: 23 / January / 2014, 13:09:11 by ahull »

Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #84 on: 23 / January / 2014, 12:49:08 »
Hello ww, thanks for your post.

Unfortunately this does not work like this here. I already have a switch_mode_usb(1) in the autostart script, because I never want the cameras to be in playback mode, so they are forced to be in rec mode when being turned on.

But they can't! The script stops there, and also connecting via PTP is not possible, I get the error "a script is already running".

Sorry for that, but I did not dig into CHDK sources enough to have an overview where to turn the screws. Help is very much appreciated! Thanks!

Hello Recyclojunk64 and ahull. Thank you too.

Well I'd prefer not to put the cameras to any danger at all. So feeding a direct voltage into the camera threatens me a little.

I have no problem to solder +2000 soldering points, if I get the whole system only a little saver. I have no problem to work much more and also a few bucks for switches or resistors is not the problem.

It is also true that maybe using some Nanos could be smart, but at the moment I am considering to have a Mega 2560 connected to the PC. That one has 54 channels, and the advantage of being connected directly to a PC is that I can configure the complete delays via that serial connection. Of course that would be possible with Nanos too, maybe even wireless. But that's another field for now.

Now I don't understand you wiring diagram really. What resistors are the ones in the camera? Are they already inside of them? If it comes to put resistors into the camera myself I would resign. That's beyond of what I am able to do.

Just to make sure I was able to describe what I was thinking of but now with all the switches and resistors in the dummy I attached a revised diagram which shows what I meant.
« Last Edit: 23 / January / 2014, 13:23:30 by Karmaschinken »

Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #85 on: 23 / January / 2014, 14:06:22 »
Hello ww, thanks for your post. Unfortunately this does not work like this here. I already have a switch_mode_usb(1) in the autostart script, because I never want the cameras to be in playback mode, so they are forced to be in rec mode when being turned on. But they can't! The script stops there, and also connecting via PTP is not possible, I get the error "a script is already running". Sorry for that, but I did not dig into CHDK sources enough to have an overview where to turn the screws. Help is very much appreciated! Thanks!
I don't know what else you are doing in your startup script so its hard to comment.

If you use this as your startup script,  does it work ?  ( i.e. wake up the camera after 4 seconds,  switch to shooting mode,  take a shot,  and exit).

Code: [Select]
--[[
@title Startup Test
--]]
sleep(4000)
switch_mode_usb(1)
sleep(2000)
shoot()
exit_alt()
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #86 on: 23 / January / 2014, 14:28:17 »
Sorry for that, my fault!

I had this in the script:

Code: [Select]
if not get_mode() then
  set_record(1)
  while not get_mode() do
    sleep(100)
  end
end

That worked until now. I replaced it with switch_usb_mode(1) and now it works like charm. Sorry, I was so sure it was working until now that I did not have the idea that some working code might have become invalid. Don't know why it did, but it did. So however, it is doing fine.  :)

waterwingz, may I have your opinion to my wiring diagram and the one that has been posted here? I would like to start building ten dummies this night and if possible I would like to do it the way the following 40 will be done. Since I got my bulky sync tester ready I could come up with some first speed tests tomorrow.

Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #87 on: 23 / January / 2014, 14:54:07 »
waterwingz, may I have your opinion to my wiring diagram and the one that has been posted here? I would like to start building ten dummies this night and if possible I would like to do it the way the following 40 will be done. Since I got my bulky sync tester ready I could come up with some first speed tests tomorrow.
Well, if I was only going to hookup one or two camera,  I'd probably use the circuit Recyclojunk64 posted because of its simplicity.

However, with 50 cameras and multiple power supplies and USB hubs, the opportunity for ground induced noise and serious ground loop problems magnifies.  So if you have already purchased the PhotoMOS Solid State Relays then you are safer to go with that.

Where did you get your circuit from ?   It looks like you are missing a current limiting series resistor on the Arduino side of the circuit?  Have you built and tested one circuit ? 

Ported :   A1200    SD940   G10    Powershot N    G16

Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #88 on: 23 / January / 2014, 15:08:50 »
No i did not.  The circuit is more or less the one that was developed here in the thread but with the switch replaced with the photomos driven by the Arduino.

I have not yet purchased the photomos but three of them. It was a proposal to use them for opening and closing the usb-cable when I was about to build the CHDKPTP-remote solution. I read they are almost ideal switches. So I'd buy the rest as soon as the circuit is fixed in theory.

But you say I am missing a resistor? I suppose it should be in the + cable of the Arduino? Which resistance should it have? And where should it be located? In the dummy too?

Thanks! Martin

*

Offline ahull

  • *****
  • 634
Re: Battery third (temp) terminal as multipurpose analogue input
« Reply #89 on: 23 / January / 2014, 15:14:01 »
If we are worried about ground loops, mains hum and so forth, you could drive an led from the microcontroller with a suitable current limiting resistor and point it at a suitable photo-resistor (aka a Light Dependant Resistor or LDR). Something like this. or this...

A photo resistor optocoupler in efect. It also eliminates the level shifting entirely.
Another plus point is that they are as "cheap as chips"... if not cheaper.

Simply connect the LDR in place of the original thermistor, and point the LED at it, seal it from daylight and the job is done. You could also signal different things with different lengths of LED flash....shoot, half shoot, focus, zoom in out etc, but maybe I'm over egging the pudding here.

« Last Edit: 23 / January / 2014, 15:23:30 by ahull »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal