My project is to take over control of a cheap digital security camera with a PIC (12F629 or any) chip rather than use the Joysticks (5 button menu) cable. I want to push 1 button and have it do a pre-defined series of button pushing..
Here we go..
It has Enter/Left/ Right/Up/Down on the menu cable. There are 3.2 or so volts present on all 5 inputs.
When a button is pressed..it triggers when taken to ground. There are no resistors (non short) resistors on the menu cable, but they run down to the cable to the camera, I assume there are non-short resistors (is pull down the term) on the camera mother board itself, as well as some kind of microcontroller that handles the info.
All I need to do is take a line to ground for 100ms or so to push a menu button, I don't need to ever send Vcc.
12F629/12c508,509 8pin chips 5 I/O's..1 input for button..perfect.
This should be the same as turning on/off a few leds.
Here is what does a few keys
All gpio set to in
WT= 100
..
Sub DOWN
Dir GPIO.4 out : Set GPIO.4 = 0 : Wait WT ms : Dir GPIO.4 in : Wait WT ms
End sub ' ///////// DOWN pin 3
Sub ENTER
Dir GPIO.5 out : Set GPIO.5 = 0 : Wait WT ms : Dir GPIO.5 in : Wait WT ms
End sub ' ////////// ENTER pin 2
Sub LEF
Dir GPIO.0 out : Set GPIO.0 = 0 : Wait WT ms : Dir GPIO.0 in : Wait WT ms
End sub ' ////////// LEFT pin 7
Sub UP
Dir GPIO.1 out : Set GPIO.1 = 0 : Wait WT ms : Dir GPIO.1 in : Wait WT ms
End sub ' ////////// UP pin 6
The above works fine 9 out of 10 times
On that 10th time something goes wrong, it presses a wrong key,it throws the whole series out of sinc and presses the wrong botton. I'm at a loss, I have tried putting delays as long as 1 sec, between every gpio opening..
ex.
Dir GPIO.4 out : Wait 1 s : Set GPIO.4 = 0: Wait 1s : Dir GPIO.4 in : Wait 1 s
I have tried everything I can think of. It might be as simple as adding a cap to every line, I just don't know
Ideas/ Help ??
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your description of the configuration and problem is very short and unclear. This is all we know:
My project is to take over control of a cheap digital security camera with a PIC (12F629 or any) chip rather than use the Joysticks (5 button menu) cable. I want to push 1 button and have it do a pre-defined series of button pushing..
Questions:
1) What does this mean:"Joysticks (5 button menu) cable". Does it mean the camera has a joystick and a 5-button keyboard that correspond to wires in a cable?
2) If the answer to 1 above is 'Yes', are you monitoring the state of a voltage on a wire in the cable in order to infer that a button was pressed?
3) if the answer to 2 above is 'Yes' are you sure nothing in the camera is also driving the wire?
4) Have you examined the wire with a scope to see what's actually happening when you push a button?
5) Or am I completely mis-understanding the situation?
Joe
Last edit: joe rocci 2017-12-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
2) They are 5 lines all at 3.3v all the time, except for the 6th line being ground.
3) I'm sure something is in there, just waiting for a real keypress.
Its all hard for me to explain, as I barely know what I'm doing and don't know the correct terminolagy. I have not done any basic programming for 30 years.
I'll try all of the things mentioned so far, then If I don't get it working, I'll hook it up to the recorder and make a vid of it in action.
Thanks for trying to help.
Thanks and Happy New Years
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Shared Vcc between micro and camera? If not, what is the micro voltage supply?
Shared common ground between camera and micro?
How is the micro input button configured? Mechanical or software debounce? Explain.
I suspect the micro input button, but who knows?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(Shared Vcc between micro and camera? If not, what is the micro voltage supply?)
Tried with 12F629 getting vcc + from external 18650 battery
Tried with tap out of a 7805 on the camera motherboard.( Camera is 12V)
( Shared common ground between camera and micro?)
Yes, one of the lines is ground on the real joystick cable, tested with a DVM to battery -.
( How is the micro input button configured? Mechanical or software debounce? Explain.)
' GPIO.3 ; pin 4 with 10k to ground then switch to pin 1 +Vcc
Triggers on Wait untill GPIO.3 = 1
No debounce to speak of, but I have tried a few things.
1) A stupid long delay between every GPIO in or out command
2) a little routine like below between every OUT/IN command
ex..Dir GPIO.4 out : Gosub : Set GPIO.4 = 0: Gosub DOUT: Wait 100ms : Dir GPIO.4 in Gosub DIN : Wait 100ms
Sub DOUT
Wait Untill GPIO.4 = 0
Wait 30ms ' Most debouce routines just cyle around 10ms a few times..long delay
End sub
I suspect the micro input button, but who knows?
Not me, thats why I'm here.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
(Why gpio.4 in ? Tried setting set gpio.4=1. Tried pull up resistors?
edit- 3.3V logic on 5V logic pic? It only goes low so don't let float maybe.)
Yes, its confussing for me to.
Why send a logic 1 down the GPIO line, all the lines are already at 3.2 volts, I just need to take them to Ground.
If I did I would be sending +5 instead of 3.3v.
Yes I tried it with no ill effect on the camera, but still had the same effect, works 9 out of 10 times.
Pulsout 500 ms would be the easy way to do it
Manufactures specs on the 12F629 is 2v-5.5
I think there is something more going on here.
Remember, this 12F629 is going down a menu cable with 3.3v on all lines except Gnd.
There must be another pic or controller chip on the camera to do something with the keypress.
While I may be able to clean up and bounce on my pic 12F629, that same bounce is going down the line to the cameras onboard pic .. I can't touch that one
I think its an interfacing problem between 2 pics, or just plain static.
I'm willing to try pull up resistors, or pull down resistors, or caps, or whatever it takes.
But, pull up resistors is a good idea but don't need them as I'm never going high.
However the 12f629 does have internal pull ups or pull down. I think
So I will try something like this on all inputs
Dir GPIO.4 in : Set to high or low pullup: wait 30ms : continue......
I don't know how to set internals on or off...but I'll go figure it out and try it
thanks a good idea
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You could set gpio as out and set it high, then use a diode on each line. As when the pin is high 5V is > than 3.2V so diode will not conduct but when pin low it will and act as switch pressed.
I think long cable runs and decoupling is the prob. ie "static"
edit As mentioned-is there de bounce built in?
Last edit: stan cartwright 2017-12-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) Since the output of of the menu wire inputs are 3.2V, I am inclined to think that the internal camera micro is being run at 3.3V. Is a Pickit 2 or Pickit 3 being used for programming? In lieu of a 18650 or 7805 try using the Pickit to supply the 12f629 at 3.3V. If you have a 3.3V MCP1702, that would be a great low quiescent, low drop out solution along with the 18650.
2) Try adding a 0.1uf cap from GPIO.3 to Vdd, that would give some mechanical debounce.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Moving on, I would reverse the pulldown on the GPIO.3 (MCLR) pin to a 10k "pullup" resistor and put a 0.1uf cap across the switch. This orientation is less likely to interfere with programmer. This program has been tested with leds, and no problems encountered whatsoever.
'try to use digital outputs to bring camera menu inputs low
#chip 12f609,4
#config _INTRC_OSC_NOCLKOUT
#define led0 GPIO.0
#define led1 GPIO.1
#define led2 GPIO.2
#define button GPIO.3
#define led3 GPIO.4
#define led4 GPIO.5
dir GPIO In 'TRISIO = b'111111' 'Hi Z all pins
'The internal pullups are meant to simulate the voltages present
'on the camera menu cable inputs, and would not use pullup code
'in digital camera setup.
Set Not_GPPU Off 'enable individual pullups from OPTION reg
WPU = b'110111' 'enable weak pullups so GPIO are in defined states
#define pause wait 250 ms
Start:
if button = 0 Then '10k pullup on MCLR
Call Menu
end if
Goto Start
sub Menu
dir led0 Out 'make digital output and pull pin low
nop
Set led0 Off
pause
dir led0 In 'make input again and Hi Z pin
Set WPU0 On 'enable port pin pullup to define state
dir led1 Out
Set led1 Off
pause
dir led1 In
Set WPU1 On
dir led2 Out
Set led2 Off
pause
dir led2 In
Set WPU2 On
dir led3 Out
Set led3 Off
pause
dir led3 In
Set WPU4 On
dir led4 Out
Set led4 Off
pause
dir led4 In
Set WPU5 On
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Ken,
Why does you code look so much cleaner than mine? Because you know wht you are doing.
This is the actual zoom section of my code, took the switch out of the picture, instead a wait to start.
;Chip Setting
;Chip Settings
#chip 12F629, 4
#config OSC=INTRC_OSC_NOCLKOUT, WDTE=OFF, PWRTE=OFF, MCLRE=OFF, BOREN=OFF, CP=OFF, CPD=OFF
' Don't know where the big font came from
Dir GPIO.0 in ; LEFT pin 7
Dir GPIO.1 in ; UP pin 6
' GPIO.3 ; pin 4 to ground with 10K then to switch to pin 1 +V
Dir GPIO.2 in ; RIGHT pin 5
Dir GPIO.4 in ; DOWN pin 3
Dir GPIO.5 in ; ENTER pin 2
WT = 254
'
Do Forever
Wait 10 s
' Zoom this only uses GPIO.5, GPIO.4
Gosub ENTER : Gosub ENTER
Repeat 3 : Gosub DOWN : End Repeat
Gosub LEF
Repeat 5 : Gosub DOWN : End Repeat
Gosub ENTER
Wait WT ms ' Screen change, let camera catch up
Gosub DOWN
Gosub ENTER
Loop
Sub DOWN
Dir GPIO.4 out : Set GPIO.4 = 0 : Wait WT ms : Dir GPIO.4 in : Gosub PULLUP : Wait WT ms
End sub ' ///////// DOWN pin 3
Sub ENTER
Dir GPIO.5 out : Set GPIO.5 = 0 : Wait WT ms : Dir GPIO.5 in : Gosub PULLUP : Wait WT ms
End sub ' ////////// ENTER pin 2
Sub LEF
Dir GPIO.0 out : Set GPIO.0 = 0 : Wait WT ms : Dir GPIO.0 in : Gosub PULLUP : Wait WT ms
End sub ' ////////// LEFT pin 7
Sub UP
Dir GPIO.1 out : Set GPIO.1 = 0 : Wait WT ms : Dir GPIO.1 in : Gosub PULLUP : Wait WT ms
End sub ' ////////// UP pin 6
Sub RI
Dir GPIO.2 out : Set GPIO.2 = 0 : Wait WT ms : Dir GPIO.2 in : Gosub PULLUP : Wait WT ms
End sub ' /////////// RIGHT pin 5
Sub PULLUP
' I tried this in an attempt to keep the io ports from floating
'Wait 30 ms
'OPTION_REG.7 = 0
'WPU = b 00110111
' It did not work it messed thing up, but it makes sense to me, if its set to an input,
' is it floating or is it reading the 3.3v present on all the lines from the camera
End sub
Ok, I have tried another 2 alterations (wow that came out of me?)
2) 1) code with internal pull up stuff in it.
2) Code with internal pull out taken out
2 wins... internal pullups screw things up.
Here are both..simplified code subs from Ken
Sub NOTWORK1
dir led4 Out ' Ok led4 = GPIO.5 = the ENTER key, should get us to menu
Set led4 Off ' chip burned..did not work..nothing
pause
dir led4 In
Set WPU5 On
End sub ' DID NOT WORK
Sub THATDIDWORK
dir led4 Out ' Ok led4= GPIO.5 = the ENTER key, should get us to menu
Set led4 Off
pause
dir led4 In
End Sub ' This WORKED got to the menu
There is much I don't understand.
Why are we pulling it it up in the first place
When a Gpio is in IN mode, does it not read whats comming in..which is 3.2 Volts. Its 3.2 volts all the time!! How can it be floating. If I hooked up a DVM to any line it reads 3.2 V
Why are we trying to pull it up...its already at 3.2
There is 3.2 Volts on EVERY line EXCEPT grnd.. PERIOD..because of some intenal IC in the camera
All that we can do is ..set gpio to out and take it to gound
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Agreed, glad you got it working. The supplied code was meant to simulate the conditions of the camera menu cable with led outputs when GPIO's were toggled low.
Sorry for the miscommunication, I did specifiy not to use the internal pullups with the camera, for the very reason you have stated! Here is the code WARNING in the previous "unedited" post.
'The internal pullups are meant to simulate the voltages present
'on the camera menu cable inputs, and would not use pullup code
'in digital camera setup.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm sorry its my fault not yours, I just did not understand and I still don't!
If :
'The internal pullups are meant to simulate the voltages present
'on the camera menu cable inputs, and would not use pullup code
'in digital camera setup.
This:
is a warning not to use the pull up...So what do I need to do?
not use the WPU1 on ...
'Moving on, I would reverse the pulldown on the GPIO.3 (MCLR) pin to a 10k "pullup" resistor and put a 0.1uf cap across the switch. This orientation is less likely to interfere with programmer. This program has been tested with leds, and no problems encountered whatsoever.
define LE GPIO.0
define UP GPIO.1
define RI GPIO.2
define BUTTON GPIO.3
define DWN GPIO.4
define ENT GPIO.5
dir GPIO In 'TRISIO = b'111111' 'Hi Z all pins
'Set Not_GPPU Off 'enable individual pullups from OPTION reg
WPU = b'110111' 'enable weak pullups so GPIO are in defined states
define pause wait 250 ms
Do forever
' No button..delay instead.....
Wait 6 s
' if button = 0 Then '10k pullup on MCLR
Gosub ZOOM
' end if
loop
sub ZOOM
Gosub ENTER : Gosub ENTER
Repeat 3 : Gosub DOWN : End Repeat
Gosub LEF
Repeat 5 : Gosub DOWN : End Repeat
Gosub ENTER
pause ' Screen change, let camera catch up
Gosub DOWN
Gosub ENTER
end sub
Sub ENTER
Dir ENT Out
Set ENT Off
pause
dir ENT In
Set WPU5 On
pause
End sub
Sub DOWN
dir DWN Out
Set DWN Off
pause
dir DWN In
Set WPU4 On
pause
End sub
Sub LEF
dir LE Out
Set LE Off
pause
dir LE In
Set WPU0 On
pause
End sub
When I enable this
'Set Not_GPPU Off 'enable individual pullups from OPTION reg
The code does not run.. With it off like above the camera works
Still has the same problem.. runs 9 out of 10.
Thanks, I will flip 10K around and go find a Cap
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please understand I do not have a camera menu button tore apart to play with. Also, that example code isn't necessarily going to be the exact solution to an OP (original poster) problem. Code examples are provided in the hope of providing the OP an insight into reaching the solution.
If you are experiencing the same problem as in the original post then I fear that I have failed to help, and have not a clue why the 9 of 10 success rate.
To preserve code formatting in posts, need to click on the menu icon, and then copy/paste code between the tildes ~~~. Here is your latest code without the WPU's. Can double check code format by clicking on the far right eyeball icon of the menu.
#chip 12F629, 4
#config OSC=INTRC_OSC_NOCLKOUT, WDTE=OFF, PWRTE=OFF, MCLRE=OFF, BOREN=OFF, CP=OFF, CPD=OFF
#define LE GPIO.0
#define UP GPIO.1
#define RI GPIO.2
#define BUTTON GPIO.3
#define DWN GPIO.4
#define ENT GPIO.5
dir GPIO In 'TRISIO = b'111111' 'Hi Z all pins
#define pause wait 250 ms
Do forever
' No button..delay instead.....
Wait 6 s
' if button = 0 Then '10k pullup on MCLR
Gosub ZOOM
' end if
loop
sub ZOOM
Gosub ENTER
Gosub ENTER
Repeat 3
Gosub DOWN
End Repeat
Gosub LEF
Repeat 5
Gosub DOWN
End Repeat
Gosub ENTER
pause ' Screen change, let camera catch up
Gosub DOWN
Gosub ENTER
end sub
Sub ENTER
Dir ENT Out
Set ENT Off
pause
dir ENT In
pause
End sub
Sub DOWN
dir DWN Out
Set DWN Off
pause
dir DWN In
pause
End sub
Sub LEF
dir LE Out
Set LE Off
pause
dir LE In
pause
End sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Switched the GPIO.3 10K pulldown from - to a + pullup.No noticeable difference.
Tried lm 111 ?? 7, reg, don't remeber 3.3V
No noticeable difference.
(stan cartwright - 2 days ago
You could set gpio as out and set it high, then use a diode on each line. As when the pin is high 5V is > than 3.2V so diode will not conduct but when pin low it will and act as switch pressed.
I think long cable runs and decoupling is the prob. ie "static"
edit As mentioned-is there de bounce built in?)
Tried Stan's idea,
Tried to toggle the ENTER key, not positive how to use diode as switch or if a 1N4001 was ok to use. For an hour I could get nothing, then it worked 1 time, no PIC, just jumpering by hand.
(I think I just touched the wrong pin)
ENTER to the menu is special..I had forgotten. Thats why it needed 2 ENTER routines at the very start of the code. Once in the menu..1 press of the ENTER will work.
Anyhow, by hand, getting into the menu, then setting any other gpio high, then low with diode worked, well at least a jumper io worked.
Kent had mentioned, a cap across the switch to debounce.
The ENTER key, got to me I wanted to ck into it a little more
Well there is no switch right now, but a CAP accross the ENTER key Gpio.2, .MAYBE?
All I could find was a 10uf, tried it accross ENTER.
No difference, still works 9 out of 10 times.
Why not filter them all, put cap across + to -.
Still 9 out of 10 times.
Done for now, will try diodes across all I/O pins next.(maybe not ENTER)
Last edit: Brian Vargo 2018-01-01
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Stan, thanks for the ideas.
I have a question, in regards to the diodes
I asume 3.3v goes to the anode (+) and the 5V from pic pin goes to the (-), and when switched to ground allows the 3.3 to go to ground.
Why is it better to Send the GPIO pin high, than just switch it IN or OUT to ground?
The diode would still act as a filter and not let stray bumps go down to the Camera's internal.
Anyhow, In messing around with IC sockets and aligator clips, its driving me nuts, bad connections..
Ordered a Ziff socket and a small breadboard
I'm on hold till they come in.
Food for thought.
I think my prgm and the led prgm are just about the same, its a proven program that can turn on led's all day. The only diff, is we have to wait here and there for the camera to go redraw the screen and come back in time to see the next keypress
I have a sneaking suspision, that the bumps are comming from the camera end of things.
Maybe the camera goes off and ck's light levels, or performs some other task once ever 10 sec.
Last edit: Brian Vargo 2018-01-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am late to the party here, and have not read all of the posts in the
thread, but have you tried using a transistor as a switch?
What you are trying to do is not the same as flashing an LED.
To drive an LED you supply a constant current, but to emulate a switch you
need to sink a voltage.
The PIC you are using may have open collector pins that you can use, have a
look in the datasheet.
Alternatively you can drive a transistor base via a resistor and use the
transistor to pull the signal too ground.
If you need a circuit diagram I will try and put something together
tomorrow, it is a bit late here now, but you will need the breadboard to
build the circuit on anyway.
Hello Stan, thanks for the ideas.
I have a question, in regaurds to the diodes
I asume 3.3v goese to the anode (+) and the 5V from pic pin goes to the
(-), and when switched to ground allows the 3.3 to go to ground.
Why is it better to Send the GPIO pin high, than just switch it IN or OUT
to ground?
The diode would still act as a filter and not let stray bumps go down to
the Camera's internal.
Anyhow, In messing around with IC sockets and aligator clips, its driving
me nuts, bad connections..
Ordered a Ziff socket and a small breadboard
I'm on hold till they come in.
Food for thought.
I think my prgm and the led prgm are just about the same, its a proven
program that can turn on led's all day. The only diff, is we have to wait
here and there for the camera to go redraw the screen and come back in time
to see the next keypress
I have a sneaking suspision, that the bumps are comming from the camera
end of things.
Maybe the camera goes off and ck's light levels, or performs some other
task once ever 10 sec.
Forget diodes. My thought is why does it work most times ???
I can imagine the frustration..part of the fun Ha
If the camera zooms that's current loads so decoupling supplies comes to mind.
Intriguing
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Brian,
In Nuts and Volts magazine October 2012 Andy Sullivan used reed relays to interface between the controller and the cellphone pushbuttons. "Remote data logger& surveillancer Cam". http://www.nutsvolts.com/magazine/downloads/2012
I have also used reed relays on an old MP3 player for game calling (only needed 3) for remote control.
Relays take away any grounds and voltage differences. Isolationism!
BR
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Breadboard and Ziff came in, but now I don't have any idea what to do with them :)
I was going to try the diodes..then go from there.
This really should be as easy as sending 5 momentary contact switches to ground at a speed the camera's internal menu can handle.
The pic is within 4 inches of the camera. It is a cheap board camera and it does throw off a lot of rf, in fact it effects the video of other cameras if in the same room.
I think I'll just wrap the camera and pic all up in aluminum foil and see if it makes things better.
That looks like a raspi camera. I thought you had a normal digital camera.
I thought you were replacing accessory joypad control on proper camera.
Can you provide a link to the camara data sheet please?
How does it's rf affect other cameras in the room? Same cameras?
The diode idea is just for 3.3v and 5v logic difference but all needed should be drag line low and diodes have 0.6v drop so would 3,2 grounded through diode would still be 0.6v above ground. just a thought idea.
It's the working most times. Why not all the time?
Last edit: stan cartwright 2018-01-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello all,
My project is to take over control of a cheap digital security camera with a PIC (12F629 or any) chip rather than use the Joysticks (5 button menu) cable. I want to push 1 button and have it do a pre-defined series of button pushing..
Here we go..
It has Enter/Left/ Right/Up/Down on the menu cable. There are 3.2 or so volts present on all 5 inputs.
When a button is pressed..it triggers when taken to ground. There are no resistors (non short) resistors on the menu cable, but they run down to the cable to the camera, I assume there are non-short resistors (is pull down the term) on the camera mother board itself, as well as some kind of microcontroller that handles the info.
All I need to do is take a line to ground for 100ms or so to push a menu button, I don't need to ever send Vcc.
12F629/12c508,509 8pin chips 5 I/O's..1 input for button..perfect.
This should be the same as turning on/off a few leds.
Here is what does a few keys
All gpio set to in
WT= 100
..
Sub DOWN
Dir GPIO.4 out : Set GPIO.4 = 0 : Wait WT ms : Dir GPIO.4 in : Wait WT ms
End sub ' ///////// DOWN pin 3
Sub ENTER
Dir GPIO.5 out : Set GPIO.5 = 0 : Wait WT ms : Dir GPIO.5 in : Wait WT ms
End sub ' ////////// ENTER pin 2
Sub LEF
Dir GPIO.0 out : Set GPIO.0 = 0 : Wait WT ms : Dir GPIO.0 in : Wait WT ms
End sub ' ////////// LEFT pin 7
Sub UP
Dir GPIO.1 out : Set GPIO.1 = 0 : Wait WT ms : Dir GPIO.1 in : Wait WT ms
End sub ' ////////// UP pin 6
The above works fine 9 out of 10 times
On that 10th time something goes wrong, it presses a wrong key,it throws the whole series out of sinc and presses the wrong botton. I'm at a loss, I have tried putting delays as long as 1 sec, between every gpio opening..
ex.
Dir GPIO.4 out : Wait 1 s : Set GPIO.4 = 0: Wait 1s : Dir GPIO.4 in : Wait 1 s
I have tried everything I can think of. It might be as simple as adding a cap to every line, I just don't know
Ideas/ Help ??
Your description of the configuration and problem is very short and unclear. This is all we know:
My project is to take over control of a cheap digital security camera with a PIC (12F629 or any) chip rather than use the Joysticks (5 button menu) cable. I want to push 1 button and have it do a pre-defined series of button pushing..
Questions:
1) What does this mean:"Joysticks (5 button menu) cable". Does it mean the camera has a joystick and a 5-button keyboard that correspond to wires in a cable?
2) If the answer to 1 above is 'Yes', are you monitoring the state of a voltage on a wire in the cable in order to infer that a button was pressed?
3) if the answer to 2 above is 'Yes' are you sure nothing in the camera is also driving the wire?
4) Have you examined the wire with a scope to see what's actually happening when you push a button?
5) Or am I completely mis-understanding the situation?
Joe
Last edit: joe rocci 2017-12-29
1) its a little joystick that controls 5 momentary contact switches inside..no pot inside.
like this one
http://www.securitycamera2000.com/products/Effio%252dE-DSP-SONY-CCD-Mini-Camera-Multilingual-OSD-2.8mm-Pinhole-Lens.html
2) They are 5 lines all at 3.3v all the time, except for the 6th line being ground.
3) I'm sure something is in there, just waiting for a real keypress.
Its all hard for me to explain, as I barely know what I'm doing and don't know the correct terminolagy. I have not done any basic programming for 30 years.
I'll try all of the things mentioned so far, then If I don't get it working, I'll hook it up to the recorder and make a vid of it in action.
Thanks for trying to help.
Thanks and Happy New Years
Shared Vcc between micro and camera? If not, what is the micro voltage supply?
Shared common ground between camera and micro?
How is the micro input button configured? Mechanical or software debounce? Explain.
I suspect the micro input button, but who knows?
Why gpio.4 in ? Tried setting set gpio.4=1. Tried pull up resistors?
edit- 3.3V logic on 5V logic pic? It only goes low so don't let float maybe.
Last edit: stan cartwright 2017-12-29
(Shared Vcc between micro and camera? If not, what is the micro voltage supply?)
Tried with 12F629 getting vcc + from external 18650 battery
Tried with tap out of a 7805 on the camera motherboard.( Camera is 12V)
( Shared common ground between camera and micro?)
Yes, one of the lines is ground on the real joystick cable, tested with a DVM to battery -.
( How is the micro input button configured? Mechanical or software debounce? Explain.)
' GPIO.3 ; pin 4 with 10k to ground then switch to pin 1 +Vcc
Triggers on Wait untill GPIO.3 = 1
No debounce to speak of, but I have tried a few things.
1) A stupid long delay between every GPIO in or out command
2) a little routine like below between every OUT/IN command
ex..Dir GPIO.4 out : Gosub : Set GPIO.4 = 0: Gosub DOUT: Wait 100ms : Dir GPIO.4 in Gosub DIN : Wait 100ms
Sub DOUT
Wait Untill GPIO.4 = 0
Wait 30ms ' Most debouce routines just cyle around 10ms a few times..long delay
End sub
I suspect the micro input button, but who knows?
Not me, thats why I'm here.
(Why gpio.4 in ? Tried setting set gpio.4=1. Tried pull up resistors?
edit- 3.3V logic on 5V logic pic? It only goes low so don't let float maybe.)
Yes, its confussing for me to.
Why send a logic 1 down the GPIO line, all the lines are already at 3.2 volts, I just need to take them to Ground.
If I did I would be sending +5 instead of 3.3v.
Yes I tried it with no ill effect on the camera, but still had the same effect, works 9 out of 10 times.
Pulsout 500 ms would be the easy way to do it
Manufactures specs on the 12F629 is 2v-5.5
I think there is something more going on here.
Remember, this 12F629 is going down a menu cable with 3.3v on all lines except Gnd.
There must be another pic or controller chip on the camera to do something with the keypress.
While I may be able to clean up and bounce on my pic 12F629, that same bounce is going down the line to the cameras onboard pic .. I can't touch that one
I think its an interfacing problem between 2 pics, or just plain static.
I'm willing to try pull up resistors, or pull down resistors, or caps, or whatever it takes.
But, pull up resistors is a good idea but don't need them as I'm never going high.
However the 12f629 does have internal pull ups or pull down. I think
So I will try something like this on all inputs
Dir GPIO.4 in : Set to high or low pullup: wait 30ms : continue......
I don't know how to set internals on or off...but I'll go figure it out and try it
thanks a good idea
You could set gpio as out and set it high, then use a diode on each line. As when the pin is high 5V is > than 3.2V so diode will not conduct but when pin low it will and act as switch pressed.
I think long cable runs and decoupling is the prob. ie "static"
edit As mentioned-is there de bounce built in?
Last edit: stan cartwright 2017-12-29
A couple of things to try.
1) Since the output of of the menu wire inputs are 3.2V, I am inclined to think that the internal camera micro is being run at 3.3V. Is a Pickit 2 or Pickit 3 being used for programming? In lieu of a 18650 or 7805 try using the Pickit to supply the 12f629 at 3.3V. If you have a 3.3V MCP1702, that would be a great low quiescent, low drop out solution along with the 18650.
2) Try adding a 0.1uf cap from GPIO.3 to Vdd, that would give some mechanical debounce.
So I setup a 12f609 which is closest thing I have to a 12f629.
One thing I noticed is the 12f609 does not set the defaualt INTOSC in config properly
Moving on, I would reverse the pulldown on the GPIO.3 (MCLR) pin to a 10k "pullup" resistor and put a 0.1uf cap across the switch. This orientation is less likely to interfere with programmer. This program has been tested with leds, and no problems encountered whatsoever.
Thanks Ken,
Why does you code look so much cleaner than mine? Because you know wht you are doing.
This is the actual zoom section of my code, took the switch out of the picture, instead a wait to start.
The vid output
https://youtu.be/nyM2gGK_4KU
Goes out of sync after about 1 minute
Your code is much cleaner, I did not use the WPU correct, will redo it following your example.
thank you very much
Edited to format Code: WR
Last edit: William Roth 2017-12-31
Ok, I have tried another 2 alterations (wow that came out of me?)
2) 1) code with internal pull up stuff in it.
2) Code with internal pull out taken out
2 wins... internal pullups screw things up.
Here are both..simplified code subs from Ken
Sub NOTWORK1
dir led4 Out ' Ok led4 = GPIO.5 = the ENTER key, should get us to menu
Set led4 Off ' chip burned..did not work..nothing
pause
dir led4 In
Set WPU5 On
End sub ' DID NOT WORK
Sub THATDIDWORK
dir led4 Out ' Ok led4= GPIO.5 = the ENTER key, should get us to menu
Set led4 Off
pause
dir led4 In
End Sub ' This WORKED got to the menu
There is much I don't understand.
Why are we pulling it it up in the first place
When a Gpio is in IN mode, does it not read whats comming in..which is 3.2 Volts. Its 3.2 volts all the time!! How can it be floating. If I hooked up a DVM to any line it reads 3.2 V
Why are we trying to pull it up...its already at 3.2
There is 3.2 Volts on EVERY line EXCEPT grnd.. PERIOD..because of some intenal IC in the camera
All that we can do is ..set gpio to out and take it to gound
Agreed, glad you got it working. The supplied code was meant to simulate the conditions of the camera menu cable with led outputs when GPIO's were toggled low.
Sorry for the miscommunication, I did specifiy not to use the internal pullups with the camera, for the very reason you have stated! Here is the code WARNING in the previous "unedited" post.
I'm sorry its my fault not yours, I just did not understand and I still don't!
If :
'The internal pullups are meant to simulate the voltages present
'on the camera menu cable inputs, and would not use pullup code
'in digital camera setup.
This:
is a warning not to use the pull up...So what do I need to do?
not use the WPU1 on ...
Then:
why is it in the example code
I'm slow but learning
I did this.
chip 12F629, 4
config OSC=INTRC_OSC_NOCLKOUT, WDTE=OFF, PWRTE=OFF, MCLRE=OFF, BOREN=OFF, CP=OFF, CPD=OFF
'Moving on, I would reverse the pulldown on the GPIO.3 (MCLR) pin to a 10k "pullup" resistor and put a 0.1uf cap across the switch. This orientation is less likely to interfere with programmer. This program has been tested with leds, and no problems encountered whatsoever.
define LE GPIO.0
define UP GPIO.1
define RI GPIO.2
define BUTTON GPIO.3
define DWN GPIO.4
define ENT GPIO.5
dir GPIO In 'TRISIO = b'111111' 'Hi Z all pins
'Set Not_GPPU Off 'enable individual pullups from OPTION reg
WPU = b'110111' 'enable weak pullups so GPIO are in defined states
define pause wait 250 ms
Do forever
' No button..delay instead.....
Wait 6 s
' if button = 0 Then '10k pullup on MCLR
Gosub ZOOM
' end if
loop
sub ZOOM
Gosub ENTER : Gosub ENTER
Repeat 3 : Gosub DOWN : End Repeat
Gosub LEF
Repeat 5 : Gosub DOWN : End Repeat
Gosub ENTER
pause ' Screen change, let camera catch up
Gosub DOWN
Gosub ENTER
end sub
Sub ENTER
Dir ENT Out
Set ENT Off
pause
dir ENT In
Set WPU5 On
pause
End sub
Sub DOWN
dir DWN Out
Set DWN Off
pause
dir DWN In
Set WPU4 On
pause
End sub
Sub LEF
dir LE Out
Set LE Off
pause
dir LE In
Set WPU0 On
pause
End sub
When I enable this
'Set Not_GPPU Off 'enable individual pullups from OPTION reg
The code does not run.. With it off like above the camera works
Still has the same problem.. runs 9 out of 10.
Thanks, I will flip 10K around and go find a Cap
Please understand I do not have a camera menu button tore apart to play with. Also, that example code isn't necessarily going to be the exact solution to an OP (original poster) problem. Code examples are provided in the hope of providing the OP an insight into reaching the solution.
If you are experiencing the same problem as in the original post then I fear that I have failed to help, and have not a clue why the 9 of 10 success rate.
To preserve code formatting in posts, need to click on the menu icon, and then copy/paste code between the tildes ~~~. Here is your latest code without the WPU's. Can double check code format by clicking on the far right eyeball icon of the menu.
Thanks for trying Kent, at least the WPU stuff has been tried and eliminated and I now know how to set them if needed, as well as how to post code.
Thank you
Will keep trying things till I get it working.
Tried a few things today.
Switched the GPIO.3 10K pulldown from - to a + pullup.No noticeable difference.
Tried lm 111 ?? 7, reg, don't remeber 3.3V
No noticeable difference.
(stan cartwright - 2 days ago
You could set gpio as out and set it high, then use a diode on each line. As when the pin is high 5V is > than 3.2V so diode will not conduct but when pin low it will and act as switch pressed.
I think long cable runs and decoupling is the prob. ie "static"
edit As mentioned-is there de bounce built in?)
Tried Stan's idea,
Tried to toggle the ENTER key, not positive how to use diode as switch or if a 1N4001 was ok to use. For an hour I could get nothing, then it worked 1 time, no PIC, just jumpering by hand.
(I think I just touched the wrong pin)
ENTER to the menu is special..I had forgotten. Thats why it needed 2 ENTER routines at the very start of the code. Once in the menu..1 press of the ENTER will work.
Anyhow, by hand, getting into the menu, then setting any other gpio high, then low with diode worked, well at least a jumper io worked.
Kent had mentioned, a cap across the switch to debounce.
The ENTER key, got to me I wanted to ck into it a little more
Well there is no switch right now, but a CAP accross the ENTER key Gpio.2, .MAYBE?
All I could find was a 10uf, tried it accross ENTER.
No difference, still works 9 out of 10 times.
Why not filter them all, put cap across + to -.
Still 9 out of 10 times.
Done for now, will try diodes across all I/O pins next.(maybe not ENTER)
Last edit: Brian Vargo 2018-01-01
there's a bilaterel cmos switch option http://www.ti.com/lit/ds/symlink/cd4066b-q1.pdf
Hello Stan, thanks for the ideas.
I have a question, in regards to the diodes
I asume 3.3v goes to the anode (+) and the 5V from pic pin goes to the (-), and when switched to ground allows the 3.3 to go to ground.
Why is it better to Send the GPIO pin high, than just switch it IN or OUT to ground?
The diode would still act as a filter and not let stray bumps go down to the Camera's internal.
Anyhow, In messing around with IC sockets and aligator clips, its driving me nuts, bad connections..
Ordered a Ziff socket and a small breadboard
I'm on hold till they come in.
Food for thought.
I think my prgm and the led prgm are just about the same, its a proven program that can turn on led's all day. The only diff, is we have to wait here and there for the camera to go redraw the screen and come back in time to see the next keypress
I have a sneaking suspision, that the bumps are comming from the camera end of things.
Maybe the camera goes off and ck's light levels, or performs some other task once ever 10 sec.
Last edit: Brian Vargo 2018-01-02
Hi Brian,
I am late to the party here, and have not read all of the posts in the
thread, but have you tried using a transistor as a switch?
What you are trying to do is not the same as flashing an LED.
To drive an LED you supply a constant current, but to emulate a switch you
need to sink a voltage.
The PIC you are using may have open collector pins that you can use, have a
look in the datasheet.
Alternatively you can drive a transistor base via a resistor and use the
transistor to pull the signal too ground.
If you need a circuit diagram I will try and put something together
tomorrow, it is a bit late here now, but you will need the breadboard to
build the circuit on anyway.
Cheers
Chris
On 2 January 2018 at 20:50, Brian Vargo mrnewbie@users.sf.net wrote:
Forget diodes. My thought is why does it work most times ???
I can imagine the frustration..part of the fun Ha
If the camera zooms that's current loads so decoupling supplies comes to mind.
Intriguing
Brian,
In Nuts and Volts magazine October 2012 Andy Sullivan used reed relays to interface between the controller and the cellphone pushbuttons. "Remote data logger& surveillancer Cam". http://www.nutsvolts.com/magazine/downloads/2012
I have also used reed relays on an old MP3 player for game calling (only needed 3) for remote control.
Relays take away any grounds and voltage differences. Isolationism!
BR
Mike
There's a servo hand project somewhere that could be adapted...or not
exactly 9/10?
is the pic near the camera or on a wire? wire resistance..na
Last edit: stan cartwright 2018-01-04
Breadboard and Ziff came in, but now I don't have any idea what to do with them :)
I was going to try the diodes..then go from there.
This really should be as easy as sending 5 momentary contact switches to ground at a speed the camera's internal menu can handle.
The pic is within 4 inches of the camera. It is a cheap board camera and it does throw off a lot of rf, in fact it effects the video of other cameras if in the same room.
I think I'll just wrap the camera and pic all up in aluminum foil and see if it makes things better.
https://www.dropbox.com/s/xgr8ga9f4ymu2yv/PA1054A-4.jpg?dl=0
https://www.dropbox.com/s/ed2bujim576w59t/PA1054A-2.jpg?dl=0
That looks like a raspi camera. I thought you had a normal digital camera.
I thought you were replacing accessory joypad control on proper camera.
Can you provide a link to the camara data sheet please?
How does it's rf affect other cameras in the room? Same cameras?
The diode idea is just for 3.3v and 5v logic difference but all needed should be drag line low and diodes have 0.6v drop so would 3,2 grounded through diode would still be 0.6v above ground. just a thought idea.
It's the working most times. Why not all the time?
Last edit: stan cartwright 2018-01-07