PDA

View Full Version : Jumper to enter setup



Bobbo_ZA
- 7th May 2010, 11:42
Hi Guys,

Quick question, im using a jumper on a circuit where one side is connected to GPIO.3 and the other via a 1K resistor to +ve, is correct or should I be puling it down to ground rather? (Hope not cause I had boards printed, :-)

Does anyone have any code examples of how to read if the jumper is on and also when its taken off?

Thinking something like:




Jumper var GPIO.4

if jumper then

XXXX

else

YYYY



to check if its on and:



if not jumper then

ZZZ


however not sure if this would work or not (marginal sucess in the early testing).

Thanks
rob

HenrikOlsson
- 7th May 2010, 13:34
You need to either pull the pin high with the resistor (or use internal pull-up,if available) and then short it GND with the jumper OR pull it low with the resistor and short it high with the jumper. The way you have it now leaves the pin floating when the jumper is not in place which makes it highly unreliable.

As for the code, your first version should be fine but I'm not sure if NOT is a valid operator in PBP.

If Jumper THEN
If Jumper = 1 THEN
If Jumper = 0 THEN
If ~Jumper THEN '<---I think this is valid for "not" ...

/Henrik.

Charles Linquis
- 7th May 2010, 13:47
If I understand your circuit correctly, you have a resistor to Vcc that you can either connect or not connect to a pin through a jumper - correct? This would mean that if the jumper was in place, it would pull the pin to Vcc, and if the jumper was not installed, the pin would be disconnected.
If this is the case, you will have trouble reading the state, since an unconnected input pin's voltage state is indeterminate (NOT low). You would be better off connecting the pin directly to GND or Vcc through the resistor, and then use the jumper to connect it to the opposite supply. If you are connected to port B, you could enable weak pull-ups and connect the pin
directly to GND through the jumper.

If your circuit is wired as I think it is, you may have to use a technique that I call a "slam-read": That is, make the pin an output and drive it low. Change it immediately to an input and wait one processor cycle (using the
line "@ nop") then read it. If their is nothing connected to the pin, it will be low on that read (stray capacitiance will keep it low for awhile after the WRITE). If it has a resistor connected and pulling it up, it will be high on that read (since now the resistor will have charged up the stray pin capacitance).

Bobbo_ZA
- 7th May 2010, 14:33
Sorry, attached is the picture. the black circle is the area showing the 2 sets of jumpers connected to GPIO 4 and 5, the red circle is the 0402 SMD 1K resistor. I am using a 12f675/9 as the PIC and I belive they have internal pull-up but im not sure if it would be usefull to pull them up twice?

Acetronics2
- 7th May 2010, 14:42
Hi, Bobbo

Nice R/C Switch ...

Your Pic Input always should be connected to one of the supply rails ( via the resistor )

When I use a jumper ... it's use just is to connect the pin to the other rail ...

"pin grounded if jumper" is my favourite, but diect logics also usable.

Never the pin must be floating ( even using the Pullups !!! ) ...

example of use here:
http://www.rcgroups.com/forums/showthread.php?t=772567&highlight=azlights


It's also possible to check if jumper connected to VDD , VSS or left apart ( 3 possible states ) ... but, this is a bit tricky ... for the moment.

Alain

Bobbo_ZA
- 7th May 2010, 14:54
Damm, so what you are sayins is that im out of luck either way? Spose the only way to do it is to bridge the jumper permanenetly and hardcode the ranges for these boards?

Acetronics2
- 7th May 2010, 20:09
Damm, so what you are sayins is that im out of luck either way? Spose the only way to do it is to bridge the jumper permanenetly and hardcode the ranges for these boards?

Would be easier you to tell what you want to do with those " jumpers " ... a jumper is someting easily removable ... so, there's something I do not understand here ...

Alain

soft example:

Jumper is active LOW



'************************************************* *****************************
' check if programming jumper not forgotten ...
'************************************************* *****************************
delay = 0
BUTTON Prog,0,255,0,delay,1,mesurav

oubli: ' infinite loop ... jumper MUST be placed ...
error = 1 ' Blink the led !!!
PAUSE 50
error = 0
PAUSE 50

GOTO oubli

'************************************************* *****************************
'************************************************* *****************************
' Measure programming pulses
'************************************************* *****************************
'************************************************* *****************************


'************************************************* *****************************
Mesurav: 'Measure Forward Max pulse
'************************************************* *****************************
Show = 1 ' programming led ON
Entree = 0

GOSUB Mes
...

Bobbo_ZA
- 7th May 2010, 20:41
Would be easier you to tell what you want to do with those " jumpers " ... a jumper is someting easily removable ... so, there's something I do not understand here ...

Alain

soft example:

Jumper is active LOW



'************************************************* *****************************
' check if programming jumper not forgotten ...
'************************************************* *****************************
delay = 0
BUTTON Prog,0,255,0,delay,1,mesurav

oubli: ' infinite loop ... jumper MUST be placed ...
error = 1 ' Blink the led !!!
PAUSE 50
error = 0
PAUSE 50

GOTO oubli

'************************************************* *****************************
'************************************************* *****************************
' Measure programming pulses
'************************************************* *****************************
'************************************************* *****************************


'************************************************* *****************************
Mesurav: 'Measure Forward Max pulse
'************************************************* *****************************
Show = 1 ' programming led ON
Entree = 0

GOSUB Mes
...



Sorry, basically, all the jumper is doing is on boot it the Pic check if it is "on" and then goes into a setup mode to sense the Transmitter stick location.

What I have done this evening is resolder another board and manged to bridge accross on another PIN (one I had designed onto the same PCB for LED lighting) and got it to work. Its not "pretty" but now functional. I would still like to find a way to use the pins that are now unconnected untill the jumper is installed and then pulled up to +ve.

Worst case, is there any harm of leaving the pins floating if I am not using them for input or output? would mean I can use these PCBs for now and then fix the design in the next batch I have printed (sounds commercial, :-), not for sale but making some onboard glow / LED light drivers for some mates at the flying field.

mackrackit
- 7th May 2010, 21:02
Make all of the unused pins an OUTPUT and code them LOW near the beginning of your program.

Charles Linquis
- 8th May 2010, 01:23
Again, the method I outline above will allow you to determine if a pin is completely open, or else connected to one of the rails via a resistor.

I had exactly the same case, where a board layout was incorrect. I needed to figure out if a jumper was on or not. "Little green wires" or added resistors were not an option.

I'm not advocating this method for production. But it can fix a bad situation.

Bobbo_ZA
- 10th May 2010, 10:32
Hi Charles,

I will give your option a go tonight, :-), should work for what I need it to do. Was thinking to monitor the pin for a few cycles and if it floated to read it as open and if it was high to read it as closed / Jumper on.

had a closer look at the circuit and I may be able to squeeze a 0402 or 0805 under the PIC's socket from the pin to the GND track, although there are no pads it should solder to the track - 0.25mm track width - if i can get it in there then I would read the pin as LOW for "open / jumper off" and high for "closed / jumper on" :-)

I like your option though as it keeps the compnent count down which is what I was aiming for as hand soldering 0402's is quite a challenge, :-)

Many Thanks

Kind regards
Rob

Bobbo_ZA
- 11th May 2010, 09:17
Error, :-( looked at it last night and cant use the track under the PIC, will have to try the "Slam-read" option which seems viable or use the other PIN and leave that side empty until I have some more printed.

Question to Alain, have you manged to code a section in any programs you could share where you check if the user has a Futaba or a JR TX?

It seems the PIC reads Throttle low-high on a JR as +- 100-200 and a futaba as +- 200-100.

Cheers
Rob